Basic Flash Tutorial 1Author: Bill Trikojus
| |
 |
Adding actions
|
| |
| |
Now would be a good time to save your movie. Under the file menu choose "save as" and save it as "my_nav.fla". OK now with your button on the stage selected go to the the Property Inspector and give it an instance name of "button1" - without the "". Now click on frame 1 of the actions layer and underneath the stop action that is already on there put
button1.onRelease=function(){
gotoAndStop("start");
}
TIP - put the actions panel into expert mode and you can copy and paste the action directly from this webpage.
What this action does is say "When button 1 is click, the timeline the button1 is on (in this case _root - the main timeline) should go to and stop at a frame label named "start"."
Now your actions should look like this (colours may vary)

|
| |
 |
Frames and keyframes
|
| |
| |
In the buttons layer select frame 60 and hit F5 - this adds new frames but no keyframes. Select frame 10 of the actions layer and hit F6 - this will create a new keyframe for that layer. Insert a stop action in the new keyframe and label the frame "sec1". Do the same for frames 20, 30 and 40 of the actions layer, putting a stop action in each and labeling them "sec2", "sec3" etc. Put a keyframe in frame 50 and give it a frame label of "sec5" but do not put in a stop action. Put another keyframe in frame 60 and just insert a stop action there. You should end up with a timeline that looks like this

OK now in your library double click on the only thing in there - the button - to get inside the main button. Click in the over state frame and hit F6 to create a new keyframe. Give your button a different fill colour for the over state. Now do the same for the down state.

|
| |
 |
Motion and shape tweens
|
| |
| |
Now click on the frame 10 keyframe again and in the Property Inspector click on the Tween drop down menu and choose "Motion". Set the keyframe on frame 1 to have motion tweening as well.
Your ball timeline should now look like this
ok back to the main timeline. Select frame 50 in the content layer and hit F7. Select the type tool and type a big white "1". Select the black arrow tool again and with the "1" selected go to the "modify" menu and choose "break apart" down the bottom. Now in frame 60 of the content layer hit F7 again to create a blank keyframe and draw a box in about the spot that the "1" used to be. Now select the keyframe on frame 50 again and in the Property Inspector select "tween - shape"
Save your movie. That's it!! If you have bothered to get this far then you have covered many of the basic concepts of Flash animation and interactivity.
Now go to the Control menu up the top and choose "Test Movie" - hopefully it will work!
|
| |
 |
Summary
|
| |
| |
- to motion tween something (ie animate its scale, alpha, x position etc) it must be a symbol and on it's own layer.
- to shape tween 2 objects, neither of them can be symbols.
- you will notice with our movie that the animation within the ball movieclip continues to play
- even though our main timeline (_root) has stopped.
- to target a movieclip (or a button or a text field) with actionscript it must have an instance name (not just a name in the library).
- use frame labels instead of frame numbers when possible
You can download the source file for this tute from here.
|
Back
ShareLike this? Click a link below to share it...    
Subscribe and Download
Post a comment
Garbage posts and SPAM will be deleted.
|