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.
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
**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:
**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.
- Open a new movie.
- 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.
- 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.
- 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.
- Place a pause script in frame 10, 20 and 30.
- 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.
- 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.
- Create a sprite behavior (script) for the next push-button
you created, which reads:
**go to next
The go to next statement tells Director to go to the next consecutive marker in the score.
- Create a sprite behavior for the previous button
**go to previous
The go to previous statement tells Director to go to the previous marker in the score.
- 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:
- Create another set of push buttons giving them the same names as your shapes.
- 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:
**go to "square"
- Play the movie and click on the new set of buttons you created.