• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 8. Film Loops and Buttons > Adding a Second Behavior

Adding a Second Behavior

Now you will use the Behavior Inspector to set up the Backward button. You will use a different method than you did for the Forward button, so you can see another way to use the Behavior Inspector.

Click anywhere in the score where there is no sprite. Then choose Window > Inspectors > Behavior.

If a sprite had been selected, any behavior created in the Behavior Inspector would be attached to that sprite. At the moment, you want to create a behavior that is not associated with any sprite, so you selected an unoccupied cell in the score before opening the Behavior Inspector.

If the Events and Actions panes are not visible in the Behavior Inspector, click the uppermost of the two expansion arrows at the bottom left of the window.

Choose New Behavior from the Behavior menu, type Reversein the Name Behavior dialog box, and click OK.

As in the previous task, you start by giving the new behavior a name so you can identify it in the Cast window.

Choose Mouse Down from the Events menu.

As with the Normal behavior you created in the previous task, you are telling Director that you want to trigger a script immediately when a user clicks the Backward button.

Choose Navigation > Go to Frame from the Actions menu. Type 41 in the Specify Frame dialog box. Then click OK to close the dialog box. Close the Behavior Inspector.

Now when this script runs in response to a mouse click, the playback head will branch to frame 41, the beginning of the reversed animation.

Examine the cast. Cast member 13 is the behavior you just created. At the moment, it is not attached to any other cast member because,when you created it, you made sure no sprites were selected in the score. Now you will learn a quick way to assign a behavior to a sprite.

Figure .

Drag the Reverse cast member from the cast to the Backward button on the stage.

You have just assigned the Reverse behavior to the Backward button. You could have achieved the same result by dragging the Reverse cast member to sprite 11 (the Backward button) in the score.

Right-click (Windows) or Control+click (Macintosh) channel 9 (the Backward button) in the score and select Behaviors from the pop-up menu.

The Behavior Inspector opens, and you should see the Reverse behavior attached to channel 9, the Backward button.

Play the movie and click the Backward button at random times.

You should see the reverse animation begin each time you click the button.

Stop the movie and save your work.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint