EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 30

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
30 Chapter 2: ActionScript Basics
In addition, case sensitivity is implemented for external scripts, such as ActionScript 2.0 class files
or scripts that you import using the
#include command. If you are publishing files for Flash
Player 7 and have previously created external files that you add to your scripts by using the
#include statement, you should review each file and confirm that you used consistent
capitalization throughout. One way to do this is to open the file in the Script window (Flash
Professional only) or, in a new FLA file, set your publish settings to Flash Player 7 and copy the
files contents into the Actions panel. Then use the Check Syntax button (see “Checking syntax
and punctuation on page 66) or publish your file; errors that are caused by naming conflicts
appear in the Output panel.
When Syntax coloring is enabled, language elements written with correct capitalization are blue
by default. For more information, see “Keywords” on page 33 and “Syntax highlighting
on page 61.
Dot syntax
In ActionScript, a dot (
.) is used to indicate the properties or methods related to an object or
movie clip. It is also used to identify the target path to a movie clip, variable, function, or object.
A dot syntax expression begins with the name of the object or movie clip followed by a dot, and
ends with the element you want to specify.
For example, the
_x movie clip property indicates a movie clips x axis position on the Stage. The
expression
ballMC._x refers to the _x property of the movie clip instance ballMC.
As another example,
submit is a variable set in the form movie clip, which is nested inside the
movie clip
shoppingCart. The expression shoppingCart.form.submit = true sets the submit
variable of the instance
form to true.
Expressing a method of an object or movie clip follows the same pattern. For example, the
play() method of the ball_mc movie clip instance moves the playhead in the Timeline of
ball_mc, as shown in the following statement:
ball_mc.play();
Dot syntax also uses two special aliases, _root and _parent. The alias _root refers to the main
Timeline. You can use the
_root alias to create an absolute target path. For example, the
following statement calls the function
buildGameBoard() in the movie clip functions on the
main Timeline:
_root.functions.buildGameBoard();
You can use the alias _parent to refer to a movie clip in which the current object is nested. You
can also use _parent to create a relative target path. For example, if the movie clip dog_mc is
nested inside the movie clip
animal_mc, the following statement on the instance dog_mc tells
animal_mc to stop:
_parent.stop();
Slash syntax
Slash syntax was used in Flash 3 and 4 to indicate the target path of a movie clip or variable. This
syntax is still supported by Flash Player 7, but its use is not recommended, and slash syntax is not
supported in ActionScript 2.0. However, if you are creating content intended specifically for
Flash Player 4, you must use slash syntax. For more information, see “Using slash syntax
on page 797.

Table of Contents

Related product manuals