130
Syntax and Language Fundamentals
Because of order of precedence, if you didn’t use parentheses or use two separate statements,
the multiplication would be computed first, meaning that the first operation would be 20 *
0.8. The result, 16, would then be added to the current value of circleClip._x and finally
assigned to the
computedValue
variable.
If you don’t use parentheses, you must add a statement to evaluate the expression, as shown in
the following example:
var tempValue:Number = circleClip._x + 20;
var computedValue:Number = tempValue * 0.8;
As with brackets and braces, you need to make sure each opening parentheses has a closing
parentheses.
About literals
A
literal
is a value that appears directly in your code. Literals are constant (unchanging) values
within your Flash documents. Examples of a literal include
true
,
false
,
0
,
1
,
52
, or even the
string
“foo”
.
The following examples are all literals:
17
"hello"
-3
9.4
null
undefined
true
false
Literals can also be grouped to form compound literals. Array literals are enclosed in bracket
punctuators (
[]
) and use the comma punctuator (
,
) to separate array elements. An array
literal can be used to initialize an array. The following examples show two arrays that are
initialized using array literals. You can use the
new
statement and pass the compound literal as
a parameter to the Array class constructor, but you can also assign literal values directly when
instantiating instances of any built-in ActionScript class.
// using new statement
var myStrings:Array = new Array("alpha", "beta", "gamma");
var myNums:Array = new Array(1, 2, 3, 5, 8);
// assigning literal directly
var myStrings:Array = ["alpha", "beta", "gamma"];
var myNums:Array = [1, 2, 3, 5, 8];
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...