|
Slow motion bullet shot effect
Added: 11/27/2008 |
|
Category:
Flash
>
Interactivity |
Ever wanted to make your own bobble head?
In this tutorial, I will walk you through how to create an interactive custom bobble head character in Adobe Flash. All of the animation and interactivity will be accomplished using Actionscript. Coding the animation effects allows us to easily swap out the example graphics to create additional bobble head characters.
Custom Flash Bobble Head Character Features:
To show off the effect, I decided to make the Paris Hilton Bobble Head character. So I searched Google Images for 'Paris Hilton' and picked a good head shot image, got to love that expression, and another of her sidekick, Tinkerbell just to add for fun. Then I searched for 'Bobble Heads' and found a good bobble head body for her. After some photoshop work I had the two components of any bobble head, the body and the head. Since this is a Flash tutorial and not Photoshop, I'm going to supply you with the graphics below: (Save each into your work folder) You can always swap the graphics out later with your own.
|
|
|
Open Adobe Flash and Modify the Document Properties.
Modify > Document
Size: 490 x 540 (Size of my example)
Frame Rate: 30 fps
Background: White
Import the supplied paris_body.jpg onto the Stage.
File > Import > Import to Stage...
With the image selected use the Align Pane to position it. Make sure the "To Stage" button is down, then click the two align options below:
Window > Align

The bobble head body should now be centered horiztonally and vertically.
With the paris_body.jpg selected on stage, convert it into a MovieClip symbol.
Modify > Convert to Symbol
Name: bobble_body

Double click the bobble_body MovieClip
In the Timeline Pane, rename 'layer 1' to 'Body'.

Click the Body graphic and drag it until the MovieClip reference point is centered on the body's neck (see image below). Our actionscript will reference this point to draw the neck from here to the head.

While inside the bobble_body movieclip,
create 1 new layer by clicking Insert Layer,
.
Rename the new layer 'Actionscript' and select frame 1:

Now we'll add actionscript to generate the neck and control user interaction. The main animation code will be added to the bobble_head in the coming steps.
Open the ActionScript Window.
Window > Actions
Copy & Paste the following code: ( All explained in my comments )
Import the supplied paris_head.png onto the Stage.
File > Import > Import to Stage...
With the paris_head.png selected on stage, convert it into a MovieClip symbol.
Modify > Convert to Symbol
Name: bobble_head

With the new 'bobble_head' Movieclip selected, give it an instance name of 'bobble_head' in the properties panel.

Now, double click the bobble_head MovieClip
In the Timeline Pane, rename 'layer 1' to 'Head'.

Click the paris_head.png and drag it until the MovieClip reference point is centered on the mouth (see image below). The actionscript will reference this point to draw the neck from here to the body.

Now we'll add the additional surprised face for when the user clicks on the bobble head. It's a nice added touch.
Click on Frame 2 on the bobble_head movieclip and insert a new keyframe:
Insert > Timeline > Keyframe

Import the supplied paris_head.png onto the Stage.
File > Import > Import to Stage...
Align the mouth with the reference point

Now we are ready to add the main bobble head animation code.
While still inside the bobble_head movieclip,
create 1 new layer by clicking Insert Layer,
.
Rename the new layer 'Actionscript' and select frame 1:

Now we'll add actionscript to animate the bobble head.
Open the ActionScript Window.
Window > Actions
Copy & Paste the following code: ( All explained in my comments )
That concludes the custom bobble head tutorial. Beyond swapping out the character graphics, you can experiment with the code. If your new to Actionscript, start by changing the constant variables like springiness and friction (small changes have big effects). Advanced users might add in additional expressions, a more complex idle animation or allow users to pick up the bobble head. As always, if you have any questions feel free to contact me on my personal site, PixelHiveDesign.com. You will find more of my tutorials here.
Tutorial Author: Maxwell Langdon
Co-founder: TutorialQuest.com
Owner: PixelHiveDesign.com
Post a comment