Controlling Movie Playback

I l @ ve RuBoard

Some of the most basic scripting tasks involve frame actions for controlling movie playback: making your movie stop and start and jump from place to place. Of course sophisticated scripts that do complicated things (such as sending instructions that manipulate objects and gathering and reusing human input) can be at ached to frames ; and scripts at ached to objects can also control movie playback and navigation. But let's start by at aching two movie-control actions stop and goto to frames. These actions live in the Actions Toolbox in the Actions > Movie Control category. Both actions are easy to use, and they'll introduce you to working with actions and parameters, as wel as viewing the playback of actions.

When you export a movie (covered in Chapter 16) as a Flash Player (.swf) file or as a stand-alone projector, the movie is set to play as soon as your audience opens it. You can override that default setting by placing a stop action in the first frame of your movie.

To set the movie to pause at startup:

  1. Open a new copy of the FrameActions Template document you created in "Adding Actions to a Frame" earlier in this chapter (choose File > New from Template.)

  2. In the Actions layer, select Keyframe 1.

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

    A list of subcategories appears.

    More About stop , goto , and play

    Think of the stop action as being like the Pause button on a VCR remote control. You can add a stop action to any keyframe in a movie. The stop action makes the playhead pause in the current frame until another instruction tells the playhead to resume playback. You might want to pause in Frame 10 while the script at ached to Frame 10 carries and adds new movie clips to the Stage. Or you might want a movie to pause in Frame 10, because the user must make choices or enter text there.

    If you don't need user input, you could add the play action to the end of the script in Frame 10. If you want your user to be able to control playback of the movie, use an object-based script to trigger the play action. You might, for example, at ach a script containing a play action to a button or movie clip in the frame where the user enters text. You can set up the object-based script to respond to mouse or keyboard input by issuing the instruction to resume playback of the movie.

    The goto action works more like a TV's remote control; you punch in some numbers , and the remote whisks you away to a new channel. An added feature of goto is that you can pause the show when you get there (by using gotoAndStop ) or move to the new channel and have it play immediately (by using gotoAndPlay ).

    Although you could use the goto action by itself in frames in the Timeline (simply as a way to organize the order in which things play back in your movie), goto works best in combination with other actions. You learn more about complex forms of interactivity in Chapters 13 and 15.

  4. Click the icon for the Movie Control subcategory .

    A list of actions appears.

  5. Double-click stop .

    Flash adds stop (); to Line 1 in the Script pane for Keyframe 1. The stop action has no additional parameters (Figure 12.24).

    Figure 12.24. In Actions > Movie Control in the Actions Toolbox, double-clicking stop adds stop (); to the current frame's script.

    graphics/12fig24.gif

  6. In the Timeline, deselect Keyframe 1.

    A small letter a now appears in Keyframe 1 of the Actions layer, indicating that this frame has actions. When you export the movie to a Flash Player file (or create a stand-alone projector) and open the movie, it will not play until it receives further instructions that tell it to do so.

A goto action has parameters that you must fill in to make the action work. The parameters identify a specific scene and frame in your movie and tell Flash either to pause there or start playback from there. Playing around with goto is a good way to familiarize yourself with the way the parameters area helps you enter parameters in your script.

To use actions to jump to a new location:

  1. Open a new copy of the FrameActions Template document you created in "Adding Actions to a Frame" earlier in this chapter (choose File > New from Template.)

  2. Add one or more new scenes to the movie (choose Insert > Scene), and place identifying text in them.

  3. In the Timeline in the Actions layer for Scene 1, create a keyframe in Frame 3 or in another frame where you want to stop the movie's sequential playback and make Flash jump to a new location in the Timeline.

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

  5. Click the icon for the Movie Control category.

    A list of actions appears.

  6. Double-click goto .

    Flash adds the action gotoAndPlay (1); to Line 1 in the Script pane and displays parameters that direct Flash to a particular frame (Figure 12.25). By default, the parameters for goto tel Flash to start playing the new frame immediately.

    Figure 12.25. Adding goto to a frame's script brings up parameters for the target frame.

    graphics/12fig25.gif

    The default target scene is the current scene, and the default target frame is Keyframe 1. In other words, the default parameters direct Flash to the first frame of the scene that you're in right now. You can change these parameters to make Flash go somewhere else.

  7. To make Flash pause after switching to a new location, click the Go To and Stop button in the Parameters area (Figure 12.26).

    Figure 12.26. The default goto action starts playback immediately after switching to a new location in the Timeline. To have Flash pause in the new location, click Go To and Stop.

    graphics/12fig26.gif

  8. To tell Flash which scene to jump to, do one of the following:

    • In the Scene field, type the name of the scene (Scene 2, for example).

    • From the Scene pop-up menu, choose the scene.

      Flash lists all the current scenes by name in this pop-up menu, along with the descriptive choices <current scene>, < next scene>, and <previous scene> (Figure 12.27).

      Figure 12.27. You define the target scene by typing its name or choosing it from the list of scenes.

      graphics/12fig27.gif

    Terminology: Expressions

    One of the frame-type choicesExpression may be mysterious to anyone who's not used to scripting. Expressions are formulas that allow Flash to calculate numeric values or enter text strings based on external information, such as information that users type in text boxes. Expressions can also test whether certain conditions are true, such as whether the playhead is in Frame 5. (To learn more about expressions and variables , see Chapter 15.)

  9. To specify the frame that Flash should jump to in the finished movie, do one of the following:

    • From the Type pop-up menu, choose Number, and type the target frame number in the Frame field (Figure 12.28).

      Figure 12.28. You define a target frame by choosing one of the frame types and then, as needed, entering a frame number or label in the Frame field.

      graphics/12fig28.gif

    • From the Type pop-up menu, choose Frame Label, and enter the target frame's label in the Frame field.

    • From the Type pop-up menu, choose Expression, and enter an expression in the Frame field that describes the target frame.

    • From the Type pop-up menu, choose Next Frame.

    • From the Type pop-up menu, choose Previous Frame.

  10. Choose Control > Test Movie. Play with this exercise, specifying different scenes and frames in steps 8 and 9. Try setting the goto action to play when it reaches its new destination (step 7).

    When the playhead reaches the frame containing the goto action, it jumps to whatever scene and frame you specified.

graphics/01icon02.gif Tips

  • When you resize the Actions panel to make it narrower, the triangles indicating pop-up menus for the Scene, Type, and Frame fields may disappear. To access these menus , make the window wider.

  • You can enter the name of a scene or frame as the target even if that scene or frame doesn't exist yet. If you have created a storyboard or outline for your movie, and you know for sure what you will name the crucial scenes and frames that will be targeted by actions, you can go ahead and type the names as you create the actions. When Flash encounters an action that tells it to go to a frame or scene that doesn't exist, Flash simply ignores the goto action.


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