9.
Select File > Save to save the Flash document.
10.
Select Control > Test Movie to test the code in the authoring environment.
In the SWF file, an error message is displayed if you click the Button instance on the Stage
when you do not have text in the
appears in the Label component and informs users that they need to enter a first name.
The next example using curly braces shows how to create and define properties within an
object. In this example, properties are defined in the object by specifying the variable names
within the curly brace (
var myObject:Object = {id:"cst94121", firstName:"John", middleName:"H.",
lastName:"Doe"};
var i:String;
for (i in myObject) {
trace(i + ": " + myObject[i]);
}
/*
id: cst94121
firstName: John
middleName: H.
lastName: Doe
*/
You can also use empty curly braces as a syntax shortcut for the
example, the following code creates an empty Object instance:
var myObject:Object = {};
Remember to make sure each opening curly brace has a matching closing brace.
Parentheses
When you define a function in ActionScript, you place parameters inside parentheses [
punctuators, as shown in the following lines of code:
function myFunction(myName:String, myAge:Number, happy:Boolean):Void {
// Your code goes here.
}
When you call a function, you also include any of the parameters you pass to the function in
parentheses, as shown in the following example:
myFunction("Carl", 78, true);
You can use parentheses to override the ActionScript order of precedence or to make your
ActionScript statements easier to read. This means you can change the order in which values
are computed by placing brackets around certain values, as seen in the following example:
var computedValue:Number = (circleClip._x + 20) * 0.8;
firstName_ti
) punctuators:
{}
TextInput component. This error
new Object()
About language punctuators
function. For
]
()
129
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?