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

Chapter 18. ActionScript: Use Script Ass... > Add frame scripts to the Timeline by...

Add frame scripts to the Timeline by using Script Assist mode

Rather than adding scripts to individual objects, and acting on objects directly but also dispersing code in many different places in your Flash document, place the scripts in a frame in the timeline instead. This section demonstrates how you add scripts to a timeline.

1.
On the main Timeline, select Frame 1 of the Actions layer.

2.
In the Actions panel toolbar, click Script Assist to display the Script Assist window.

3.
From the Actions toolbox, select ActionScript 2.0 Classes > Movie > Button > Events and locate the on(release) event handler.

Double-click the on(release) event handler to insert it into the ActionScript editor.

Using the Actions toolbox to insert functions into the script

You’ll notice that code placed on a timeline behaves differently than code placed on objects. In the previous example, you had to specify the target object for the on(release) event handler. This is because you’re not adding the script directly to the object, but rather, you’re referring to it from the code in the timeline. It also explicitly uses the function keyword to declare a function. You’ll see how to use Script Assist mode to handle these in the following steps.

4.
Click in the Object text box.

On the Actions panel toolbox, the Insert a Target Path button is enabled.

5.
Click the Insert a Target Path button to display the Insert Target Path dialog box.

Selecting the target object from the Insert Target Path dialog box

6.
Select the About button (about_btn) from the tween_mc movie clip.

7.
Make sure that the Relative Path option is selected and then click OK.

The target object (the Menu tween) is added.

The path to the target object is added to the event handler.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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