the singularity of being and nothingness
Posts tagged ActionScript 3

Fun with Flash and ActionScript
Jan 8th
My brother recently approached me with an interesting project: He wanted to make a flash movie that would have enable someone to control the mouth movements of a "bobblehead" with keystrokes.
Although I have not done this before, I was certain it would be something fairly easy to do. ActionScript 3's "Keyboard" class has a plethora of functions and methods that allow one to do just about anything with a keyboard and a flash animation.
So here's the breakdown: The animation needed to have five "states": Default, profile, wobble, "ooh" and talk; and each needed to be assigned to a separate key.
Cake.
The first step was to create the background movie. My brother did this in Motion 3, and we set it inside a Movie Clip on the first frame of the flash movie. Next, we defined another movie clip that contained all of the movements for the head "states".
Beyond that, all that was left to do was to define the keyboard actions. The following is the totality of the code:
function doTheBobble(event:KeyboardEvent):void { if(event.keyCode == Keyboard.SPACE) { Mouth.gotoAndPlay(2); } if(event.keyCode == Keyboard.LEFT) { Mouth.gotoAndPlay(21); } if(event.keyCode == Keyboard.RIGHT) { Mouth.gotoAndPlay(31); } if(event.keyCode == Keyboard.UP) { Mouth.gotoAndPlay(41); } if(event.keyCode More >