Writing with Dot Syntax
As in other foreign languages, you must learn the rules of grammar to put words together. Dot syntax is the convention that ActionScript uses to put objects, properties, and methods together into statements. You connect objects, properties, and methods with dots (periods) to describe a particular object or process.
Zeke.weight = 188 Betty.weight = 135
The first statement assigns the value 188 to the weight of Zeke. The second statement assigns the value 135 to the weight of Betty. The dot separates the object name from the property (weight) (Figure 3.4).
Figure 3.4 The hypothetical weight property describes Betty and Zeke. In Flash, the properties of objects can be both read and modified with ActionScript.
Betty.shirt.color = "gray"
This statement describes the object Betty that is linked to the object shirt. The object shirt, in turn, has the property color, which is assigned the value "gray". Notice that with dot syntax, you use multiple dots to maintain object hierarchy. When you have multiple objects linked in this fashion, it's often easier to read the statement backward. So you could read it as "Gray is the color of the shirt of Betty."
Zeke.run ()
This statement causes the object Zeke to call the method run (). The parentheses after run signify that run is a method and not a property. You can think of this construction as noundotverb (Figure 3.5). Methods often have parameters, or arguments, within the parentheses. These parameters affect how the method is executed.
Figure 3.5 Dot syntax lets you make objects call methods. Just as the hypothetical method run() could make the Adam object begin to jog, the real Flash method hide(), when applied to the Mouse object, makes the pointer disappear.
Zeke.run (fast) Adam.run (slow)
Both of these statements will make the Zeke and Adam objects call the run () method, but because each method contains a different parameter, the way the run is performed is different: Zeke runs fast, and Adam runs slowly.
Each method has its own set of parameters that you must learn. Consider the basic Flash action gotoAndPlay("Scene 1",20). gotoAndPlay is a method of the MovieClip class. The parenthetical parameters, ("Scene1", 20), refer to the scene and the frame number, so the playhead of the object will jump to Scene 1, Frame 20, and begin playing.
TIP
The dot syntax replaces the slash syntax used in previous versions of Flash. Although you can still use the slash syntax, the dot syntax is recommended because it's more compatible with all the new actions. Use slash syntax only if you are authoring for the Flash 4 Player or earlier.