Blog

Latest entries from the YAY! blog...

July 20, 2007

File upload watcher with AIR

Writing about web page http://blog.kevinhoyt.org/2007/05/21/file-upload-with-apollo-and-javascript/

Kevin Hoyt has a nice example here of a directory-watching application, using AIR (Apollo) and Javascript. The application watches a directory on the client machine and when it sees a change (in this case the app looks for image files) it resyncs and uploads any added files to a server.

Ultimately this tool could sit in the system tray and work silently, but AIR is still in beta and that functionality isn’t available yet. I don’t know whether this would be subject to the same authentication-on-upload issues we’ve come across in Flash/Flex either.

Worth reiterating that this app is solely AIR and JS. It’s possible to create AIR apps entirely in a HTML editor if you’re that way inclined – no Flash or Flex required.

July 19, 2007

Papervision3D planets

I’ve been looking at the Papervision3D libraries recently. A while ago we had a request for a planets animation in Flash, and no amount of z-axis trickery would make it look realistic enough for me, so we moved the job into Director, which proved difficult (learning curves being what they are) and I ran out of time and gave up.

Papervision3D has achieved what many Flash developers have been waiting for – a proper 3D engine. It has support for primitives, but also allows import of 3D models via collada XML files. With a few simple commands you can set up a scene and instantiate some 3D objects:

private var planet:DisplayObject3D = rootNode.addChild(new Sphere(null ,50, 20, 20), "Planet" );

And there’s your wireframed primitive sphere. Next job is to start it spinning:

planet.rotationY++;

Easy isn’t it? Now all we have to do is make it travel around a centre point. In this case we’ll make the vector a simple circle. Flash talks in radians, so we need to convert degrees to radians when calculating the angle.

private function deg2rad(degree) {
return degree * (Math.PI / 180);
}
private var originX:Number = 0;
private var originY:Number = 0;
private var radius:Number  = 400;
private var radian:Number = deg2rad(angle);
planet.x = originX + radius * Math.cos(radian);
planet.z = originY + radius * Math.sin(radian);

So once you’ve created a couple of those, and made a simple ‘sun’ for them to travel around, here’s the resulting Flash movie. I’ve added some simple controls to allow the mouse to move around the scene: