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

Lesson 12. Nonlinear Flash Interactions > Programming the Down Button

Programming the Down Button

In this task, you'll program the button that enables users to access the lower half of the Inferno. You'll use a script much like the ones you learned in Lesson 10, “Building Basic Interactivity.” As you program the button this time, keep in mind the preceding discussion, so that you can begin internalizing it.

Open dante.fla from the dante/flash/folder in your local site.

This file is already partially built, with the graphics in place. This enables us to focus on the architectural and scripting aspects of the movie.

Click the red button with the down-pointing arrow in the lower-right corner to select it.

This button was created for you in advance, and its purpose is to enable the user to access Lower Hell. Currently, it lacks an instance name and no script has been written to do anything with the button.

Use the Property inspector to give it an instance name of down_btn.

The instance name exposes the button to ActionScript.

Click Frame 1 of the actions layer, and press F9 to open the Actions panel.

The panel currently has only a stop() action.

Beneath the existing script, add the following code:

// Powers the Down button
down_btn.onRelease = function() {

The ActionScript tells Flash that whenever a user clicks the down_btn instance, the timeline should skip to the frame label called “lower.” onRelease is an event handler, built into all button instances. gotoAndStop() is a method built into all timelines.

Test the movie by pressing Ctrl+Enter (Windows) or Command+Return (Macintosh). Click the button and make sure that Lower Hell appears.

Lower Hell has an up-pointing button that returns the user to Upper Hell, and it has already been programmed, so you should be able to go back and forth.



Not a subscriber?

Start A Free Trial

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