Recently, I did a kids game that featured bugs dropping from the sky on parachutes. I handled the vertical motion using script, but thought I’d do the back and forth swinging on the chute using the timeline. Minus the vertical motion I got something like this:
It works, but as you can see Flash doesn’t rotate bitmaps very well, and the client was less than thrilled with it. So, I did a bit of looking and found that if I used pure code I could make a bitmap object from my library items and use the smoothing option. Instead of what I had, I got this:
Much nicer. Here’s the AS3 code I used:
var bug = new Bitmap(new BugA(50,56), "auto", true); var par = new Bitmap(new Parachute(60,60), "auto", true); var rot = 1.8; var c = new Sprite(); c.addChild(par); par.x = -30; par.y = -20; c.addChild(bug); bug.x = -20; bug.y = 22; addChild(c); c.x = 100; c.y = 70; addEventListener(Event.ENTER_FRAME, loop); function loop(e:Event) { c.rotation += rot; if(rot > 0){ if(c.rotation > 25){rot *= -1;} }else{ if(c.rotation < -25){ rot *=-1;} } }
The first two lines are what make the magic happen. A bug and parachute bitmap object is created from simple .png graphics in the library. They have their linkage properties set to export for ActionScript like so:

Their base class is of type BitmapData because they are images. The final parameter of the Bitmap constructor is the smoothing parameter. By default it is false. Setting it to true, gives us the smooth rotation we’re after.
The remainder of the code creates a Sprite object, places the two Bitmap objects into it, and then places the Sprite so it can be see – with addChild. An Enter Frame listener is added so that the loop function is called. All it does it rotate the object back and forth. All in all, pretty simple and the client was much happier with the result.
