Director Tutorials


Tutorial 12: Adding interactivity

In the first scripting tutorial, you wrote simple commands within a script, telling Director to beep and open an alert window. Often you will use scripting to add navigation to your presentation. This gives users control over the flow of the presentation, allowing them to explore movies at their own pace, pause or repeat parts of the movie or exit the presentation.

Creating Loops

This is the process of continuously returning the playback head to the same location it has come from, until the user gives instructions to exit the loop.

Double click frame 5 of the scripting channel and type the following script:
on exitFrame
**go to frame 1

Make sure the looping option in the control panel is turned off, play the movie and watch what happens in the score.

Pausing a movie

To pause a movie, simply create a script that loops the playback head in the current frame. The script is as follows:
on exitFrame
**go to the frame

The go to command sends the playback head to a specific point in your movie. In the above script, the frame represents the current frame.

Moving between sequences creating markers

Director allows you to mark certain frames in your movie so they can be identified by buttons and links.

  1. Open a new movie.
  2. We are going to identify 3 points in the movie by placing various shapes on the stage. Using the Vector Shape tool, create a square, circle, and some other shape you like.
  3. Place the square in the score so it extends from frame 10-19, the circle over frames 20-29 and the 'other' over frames 30-39.
  4. As in tutorial 11, create 2 push buttons cast members. Place the casts in the score and make sure they are extended over frame 1 to frame 39. Label one push button next and the other previous.
  5. Place a pause script in frame 10, 20 and 30.
  6. Click in the marker channel in frame 10, as soon as you click a marker is created with text naming it as New Marker. Type in square over this text.
  7. Create markers at frame 20 and 30, naming them circle and other (or another name to identify your other shape) respectively. You can delete a marker by clicking the triangle and dragging it below the marker channel.
  8. Create a sprite behavior (script) for the next push-button you created, which reads:
    on mouseUp
    **go to next

    The go to next statement tells Director to go to the next consecutive marker in the score.
  9. Create a sprite behavior for the previous button which reads:
    on mouseUp
    **go to previous

    The go to previous statement tells Director to go to the previous marker in the score.
  10. Play the movie, click on the buttons and see how they work.

In the above set of steps you created movement over consecutive markers. With Director you can make a button jump to as a specific point. To do this, do as follows:

  1. Create another set of push buttons giving them the same names as your shapes.
  2. For each button, create a cast member script which uses the statement:
    go to "markerName"
    For example the button for the square will have the following script:
    on mouseUp
    **go to "square"
  3. Play the movie and click on the new set of buttons you created.