User Guide

Write a function for a button 31
Later in this lesson, you’ll use Flash features that allow you to test your syntax.
Locate ActionScript reference documentation
During authoring, if youd like additional information about the ActionScript that you enter, you
can select the action in the Actions toolbox or Script pane and click the Reference button. The
Help panel displays information about the selected action.
1.
In the Script pane of the Actions panel, double-click visible to select the term.
Note: After completing the next step, you’ll change topics in the Help panel and you will no longer
be on this lesson topic. Click the How Do I tab to return to this topic.
2.
Along the top of the Actions panel, click the Reference icon.
The
visible entry in the Help panel appears.
Add comments to ActionScript
In ActionScript, text after double slashes (//) is commented text, which Macromedia Flash Player
ignores. Commented text often documents script functionality so that other developers can
understand your script, but you can also use comments to deactivate sections of your script when
debugging. As a best practice, always add comments that explain your scripts.
In the Script pane of the Actions panel, place the insertion point at the beginning of the line
of code and type
//Initialize document to hide screen movie clip. Press Enter
or Return.
Text in the Script pane appears as follows:
//Initialize document to hide screen movie clip.
this.screen_mc._visible = false;
Note: If your commented text is many lines, you can use /* instead of double slashes for the
beginning of the comment, and */ to mark the end of the comment.
Write a function for a button
A command in ActionScript is called a function. A function is a script that you can write once
and use repeatedly in a document to perform a certain task. Youre going to write a function
that makes the screen_mc movie clip appear (
visible = true) when the user releases the
mouse button.
1.
In the Script pane of the Actions panel, click after the last line of code, press Enter or Return
twice, and type
//function to show animation.
2.
Press Enter or Return and click Insert Target Path, along the top of the Actions panel. Select
onButton_btn from the hierarchical tree, and click OK.
3.
In the Script pane, type a period (.) and double-click onRelease from the list of code hints
that appears.