Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Pausing the RoboDemo Movie while Playing the Animation

Pausing the RoboDemo Movie while Playing the Animation

Pausing the RoboDemo movie while the animation plays is easy; you simply instruct the animation to stop the RoboDemo movie when it starts playing and continue the RoboDemo movie when it finishes.

In this third example, you’ll add some ActionScript to a Flash SWF file so it can control a RoboDemo movie, then you’ll insert the SWF into the movie as an animation:

  1. In Flash, open Example3_a.fla.

    You’ll see that this is basically the same as Example1_a.fla used in the first example, but I’ve added two new layers: one to display the shaking arrow, the second to hold the ActionScript.

  2. Preview the movie by selecting Control > Test Movie.

    You’ll see that the shaking arrow fades in after the “Welcome” message displays, then the movie stops and waits for the user to click the arrow. In its current state, if you inserted it into a RoboDemo movie, it would simply play for 5 seconds, and then disappear.

    You need to add some ActionScript at the start of the animation to stop the RoboDemo movie, then some at the end to restart the RoboDemo movie.

  3. Click frame 1 of the Script layer and add the following ActionScript:


    RoboDemo movie.swf consists of a collection of movie clips on _root, which contain all the elements of the movie. These movie clips include:

    • rdpbHost_mc contains the slides, captions, etc, that compose the actual movie.
    • rdInsertmc10002_mc contains the first inserted animation.
    • rdPlay bar_mc contains all elements of the play bar.

    Therefore parent.stop() will stop the animation’s parent movie clip, that is, the main RoboDemo movie contained in _root. This is the equivalent of _root.stop(), but as previously stated, don’t use _root unless you really know what you’re doing.

  4. Click frame 95 of the Script layer and add the following ActionScript:


    This code triggers the pbhForward() function which normally executes when a user presses the forward button on the play bar. This causes the RoboDemo movie to jump to the next slide and restarts playback.

    You could have issued a command, however, in this case it would cause a short delay before moving to the next frame as the playhead waits for any remaining objects on the slide to play.

    Other useful play bar functions include:

    // Press the Forward button. _parent.rdpbHost_mc.pbhPause()
    // Press the Pause button. _parent.rdpbHost_mc.pbhPlay()
    // Press the Play button. _parent.rdpbHost_mc.pbhBack()
    // Press the Back button. _parent.rdpbHost_mc.pbhRewind()
    // Press the Rewind button. _parent.rdpbHost_mc.pbhInfo()
    // Press the Info button. _parent.rdpbHost_mc.pbhExit()
    // Press the Exit button.

    Note: The play bar functions are available whether the movie uses a play bar or not.

    Notice there is a frame 100 after our ActionScript on frame 95. This is required because RoboDemo fails to play the last frame of an inserted animation. If frame 95 were the last frame of our animation, our ActionScript would not execute, and the main RoboDemo movie would fail to restart.

  5. Now you can save the file (File > Save) and export it as Example3_a.swf (File > Export Movie).
  6. In RoboDemo, open Example3_rd.rd.
  7. Double-click slide 3 to open it in the Edit window.
  8. Select Insert > Animation, then navigate to and open Example3_a.swf.
  9. Leave all options at their defaults and press OK.
  10. Drag the sizing handle at the top of the animation down slightly to resize the animation to 400 x 270 pixels. This prevents the welcome message from displaying too close to the caption “Slide 3.”
  11. Now you can save the file (File > Save) and preview it (File > Preview).

    Notice how the slider on the play bar stops moving when the animation displays, then restarts once the animation has finished.

Now you’ll have a look at how you can display the animation over multiple frames.