Adding Actions to a Frame

I l @ ve RuBoard

You can assign actions to just one keyframe at a time, but a keyframe can contain multiple actions. Flash executes the actions in the order in which they appear in the Script pane. To change a selected action's place in the script, click the Up and Down buttons . To get a feel for working with the Actions panel, practice adding, moving, and deleting actions. Don't worry about filling in any parameters that may appear; this exercise is strictly for familiarizing yourself with the mechanics of the Actions Toolbox and Script pane. You will learn more about how the actions and parameters operate in later exercises.

Because you wil be creating actions that involve moving from frame to frame, it wil be useful to create a multiframe document that has identifying text in each frame.

To set up a document for testing frame actions:

  1. Open a new Flash document, and create two layers : Contents and Actions.

  2. In the Contents layer, create keyframes in frames 1 through 5.

  3. Add text that identifies each keyframe (Scene 1Frame 1, Scene 1Frame 2, and so on).

  4. Save the document as a template for use throughout this chapter, and name it FrameActions Template.

    (For detailed instructions for saving documents as templates, see Chapter 1.)

To add one action to a keyframe:

  1. Open a new copy of the FrameActions Template document you created in the preceding exercise (choose File > New from Template).

  2. In the Timeline for Scene 1, in the Actions layer, select Keyframe 1.

  3. In the Actions-Frame panel, in the Actions Toolbox, click the category icon for Actions.

    The category expands to reveal a list of actions subcategories (Figure 12.11).

    Figure 12.11. Click a category icon to reveal subcategories and/or individual actions in the Actions Toolbox.

    graphics/12fig11.gif

  4. Click the subcategory icon for Movie Control.

    A list of actions for controlling movie playback appears.

  5. Double-click the action stopAllSounds .

    Flash adds stopAllSounds (); to Line 1 in the Script pane for Keyframe 1.

    The message No Parameters appears in the Parameters area (Figure 12.12). If an action has parameters, those parameters appear above the Script pane when you select the action in the Actions Toolbox.

    Figure 12.12. When an action has no parameters, Flash tells you so.

    graphics/12fig12.gif

    (The stopAllSounds (); action turns off any event sounds that were initiated by earlier frames and that are still playing. To learn more about sounds, see Chapter 14.)

  6. In the Timeline, deselect Keyframe 1.

    A small letter a now appears in Keyframe 1 of the Actions layer, indicating that this frame contains actions (Figure 12.13).

    Figure 12.13. The letter a in Keyframe 1 indicates that actions are assigned to that frame.

    graphics/12fig13.gif

graphics/01icon02.gif Tips

  • You must at ach scripts to keyframes, but you don't have to select a keyframe to do so. Select any frame within a keyframe span, and Flash assigns the script to the keyframe that begins the span.

  • The line number for selected actions in the Script pane always appears in the line-by-line display at the bottom of the Actions panel. To display line numbers inside the Script pane, from the Action panel's Options menu, choose View Line Number; press Shift- graphics/01icon01.gif -L (Mac) or Shift-Ctrl-L (Windows); or from the View Options pop-up menu, choose View Line Numbers.


To add multiple actions to a keyframe:

  1. Continuing with the file that you created in the preceding exercise, in the Timeline for Scene 1, select Keyframe 1.

    This frame should already contain the stopAllSounds (); action.

  2. In the Actions-Frame panel in Line 1 in the Script pane, select the stopAllSounds (); action.

  3. From the Actions-Frame panel's Add menu, choose Actions > Browser/ Network > getURL .

    Flash adds getURL (""); to Line 2 in the Script pane, below stopAllSounds (); . The parameters for this action appear in the parameters area.

    (The getURL (""); action tells the Web browser to open a URL; the action's parameters define what kind of window to open the URL in and whether or not to send variables . You'll learn more about this action in Chapter 15.)

  4. With getURL (""); selected in Line 2 in the Script pane, from the Add menu, choose Actions > Movie Control > stop .

    Flash adds stop (); to Line 3 in the Script pane, below the getURL (""); action. The message No Parameters appears in the parameters area (Figure 12.14).

    Figure 12.14. As you choose additional actions in the Actions Toolbox or from the Add menu (top), Flash adds them below whatever action was selected in the Script pane for that frame (bottom).

    graphics/12fig14.gif

    (The stop action makes the movie pause in the current frame until another instruction tells Flash to resume playback.)

graphics/01icon02.gif Tip

  • If you want to add an action to a particular spot in the Script pane, drag the action from the Actions Toolbox to the Script pane. You get the dog-eared page icon with the name of the action you are dragging at ached. A highlighted line indicates where in the script the new action will go (Figure 12.15).

    Figure 12.15. When you drag an action from the Actions Toolbox (top), you can scroll the Script pane and position the action where you want it (bottom).

    graphics/12fig15.gif


I l @ ve RuBoard


Macromedia Flash MX for Windows and Macintosh. Visual QuickStart Guide
Macromedia Flash MX 2004 for Windows and Macintosh (Visual QuickStart Guides)
ISBN: 0582851165
EAN: 2147483647
Year: 2002
Pages: 243

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net