Key
Points about Flash MX ActionScript Parameters.
- Point one
- Point two
- Point three
- Point four
|
Flash MX ActionScript Parameters...
Clip Actions
Pr 1
Pr 2
The easiest way to add Actions is to first select one from the Toolbox List
on the left. Either double-click the desired Action or drag it to the right
side of the Actions panel (the Script Area). Each Action you add
occupies one line on the right. Rarely is an Action just one word; more often
an Action is complex enough to require a whole sentence, or statement. A statement
is a code sentence that uses only words from the ActionScript language. The
entire assembly of statements is a script.
After you add an Action, there are a few ways to modify it. As
you add Actions, each appears as a complete statement in the order that you
add them, and they'll occur in that order. You can change the order of any statement
either by clicking its line in the Script Area and dragging it to another
position or by selecting it in the Script Area and clicking the Up or
Down arrow at the top right.
Another way you'll likely need to modify an Action is to specify parameters.
For example, the Action called gotoAndPlay makes the playback head jump
to a different frame. However, you need to specify the frame to which you want
to go. In this case, the frame number is a parameter. To view the Parameters
Area of the Actions panel, make sure the panel is in Normal mode and
you've selected a line of code that was added to the script area. Some Actions
don't need parameters.
Specifying Actions with Parameters
Now is a chance for you to try out Actions and parameters. You'll see that
some Actions are quite simple. However, most Actions are more complicated.
Actions That Loop Parts Of Your Movie
Actions That Loop Parts Of Your Movie
- In a new file, use the Text tool to create a text block containing
the word Welcome. Select the block and convert to symbol (Ctrl+F8).
Make it a Movie Clip and name it "Welcome Text".
- Position the clip instance in the center of the screen, and insert
keyframes at frame 20 and frame 30.
- Move the red current frame marker to frame 1 and move Welcome
Text all the way off the stage to the left. Set Motion
Tweening for both frame 1 and frame 20. In frame 20,
use the Properties panel to make the tween rotate one time clockwise
(CW) on it way from frame 20 to frame 30. Test the
movie. Notice that the whole movie loops over and over. Instead we're going
to make the rotation part (from frame 20 to frame 30) loop forever.
- We need to make a new layer just for the Actions. Name the first
layer "Animation" and then choose Insert > Layer and
name the new one "Actions." Make sure the current layer is
Actions (you'll see a pencil in the layer). Select frame 30
in your Actions layer, insert a keyframe (F6), and then access
the Actions panel (either by selecting Window > Actions or right-clicking
on the keyframe and selecting Actions). Make sure frame 30
remains selected when you edit the Actions panel. We're going to set an
Action to execute when the playback head reaches frame 30.

- Insert a gotoAndPlay
Action, click
the plus button and then Actions > Movie Control > goto (or
"gotoAndPlay"
if you don't see goto listed). You should see a gotoAndPlay
Action added
to your script in the Script Area on the right. Notice that in the Timeline,
a small a
appears in the keyframe where you added the Action.

- If your Parameters Area is not revealed, make sure you're in Normal
mode by selecting the Options menu or View Options menu
(both in the Actions panel).
- The Parameters Area is where you specify all the details for the selected
Action (gotoAndPlay,
in this case). For this exercise, leave most of the the defaults but
enter 20 in the Frame field. The final Action in the script area should
read gotoAndPlay(20).
- Test the movie (don't just play in the authoring environment).
It plays once, and then every time it get to frame 30 it goes back to frame
20 and plays again.
There is a better way to accomplish the above so that
if you change the frames for better timing, you don't mess up your animation.
Instead of making the destination of your gotoAndPlay an explicit frame
number, you can change the parameters to make the destination a named frame
label, which will be the same for the frame no matter where it is located
in the Timeline.
Hide Practice Session
1
Using Frame Labels as the Destination of a GoTo
Using Frame Labels as the Destination of a GoTo
Using the session from above let's make life a bit easier for you.
- In the file you just finished, click frame 20 of the Animation
layer. In the Properties panel you should see a place where you can type
a frame label. Label this frame "Loop Start".
- Go back and click on frame 30 in the Actions layer and open the
Actions panel.
- You are going to modify the gotoAndPlay
line in the Frame Actions panel. Select the line and change the Type
drop-down list to Frame Label. Then, select the Frame drop-down
list and you should see all the labels available in the current Timeline.
Since you only have "Loop Start", that's all that's availablebut
if you had more, they'd be there. Select Loop Start.


- Test the movie; it doesn't look any different to the user. Now
go back to the Timeline and click and drag the Loop Start keyframe
to frame 10.

- Test the movie again. The animation now loops back to frame 10,
where you moved the Loop Start keyframe. This little trick will help
you work with your movies without the grief!
Hide Practice Session
2
Actions are instructions that we want Flash to follow. Actions do
things. You can modify Actions by changing their parameters. So if
Actions are instructions, how does Flash follow those instructions?
The answer depends on where you put the Action. The three places you
can put Actions are in keyframes, on Button instances, and on
Movie Clip instances. We just did a couple of exercises with frames,
if you put an Action in a frame, it will not be followed until the playback
head reaches that frame.
This is powerful stuff, but it's not interactivity with the
user, it happens all by itself. If you wanted an animation to stop by itself,
all you'd need to do is place a keyframe where you want it to stop and add a
Stop Action. In the next section you'll see how to work with the remaining
two places to put Actions.
Back to Contents
Clip Actions
Top
Page Updated on
March 2, 2003