Adobe Flash

Apply ActionScript syntax

All languages, whether computer languages or written and spoken "human" languages, follow specific rules that foster comprehension. These rules are known as the language syntax.

Flash uses dot syntax, which means that the period (.) links parts of a script. Other ActionScript syntax elements include the following:

  • A semicolon (;) in an ActionScript statement, like a period in an ordinary sentence, indicates the end of a statement.

  • Parentheses () group arguments that apply to an ActionScript statement.

  • Curly braces {} group related ActionScript statements. You can use nested braces to create a hierarchy of statements.

Later in this lesson, you'll use Flash features that allow you to test your syntax.

Locate ActionScript reference documentation

During authoring, if you'd like additional information about the ActionScript that you enter, you can select the action in the Actions toolbox or Script pane and click Reference. 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. In the Help panel, click the History Back icon to return to this topic.

  2. Along the top of the Actions panel, click the Help 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 (Windows) or Return (Macintosh).

Text in the Script pane appears as follows:

// Initialize document to hide screen movie clip.

this.screen_mc._visible = false;

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.