Using Flash 8 to create content for Flash Player 4 789
■ The = operator in Flash 4 was used for numeric equality. In Flash 5 and later, == is the
equality operator and
= is the assignment operator. Any = operators in Flash 4 files are
automatically converted to
==.
■ Flash automatically performs type conversions to ensure that operators behave as
expected. Because of the introduction of multiple data types, the following operators have
new meanings:
+, ==, !=, <>, <, >, >=, <=
In Flash 4 ActionScript, these operators were always numeric operators. In Flash 5 and
later, they behave differently, depending on the data types of the operands. To prevent
semantic differences in imported files, the
Number() function is inserted around all
operands to these operators. (Constant numbers are already obvious numbers, so they are
not enclosed in
Number().) For more information on these operators, see the operator
table in “About operator precedence and associativity” on page 179 and “Deprecated Flash
4 operators” on page 779.
■ In Flash 4, the escape sequence \n generated a carriage return character (ASCII 13). In
Flash 5 and later, to comply with the ECMA-262 standard,
\n generates a line-feed
character (ASCII 10). An
\n sequence in Flash 4 FLA files is automatically converted
to
\r.
■ The & operator in Flash 4 was used for string addition. In Flash 5 and later, & is the bitwise
AND operator. The string addition operator is now called
add. Any & operators in Flash 4
files are automatically converted to
add operators.
■ Many functions in Flash 4 did not require closing parentheses; for example, Get Timer,
Set Variable, Stop, and Play. To create consistent syntax, the getTimer function and
all actions now require parentheses [
()]. These parentheses are automatically added
during the conversion.
■ In Flash 5 and later, when the getProperty function is executed on a movie clip that
doesn’t exist, it returns the value
undefined, not 0. The statement undefined == 0 is
false in ActionScript after Flash 4 (in Flash 4, undefined == 1). In Flash 5 and later,
solve this problem when converting Flash 4 files by introducing
Number() functions in
equality comparisons. In the following example,
Number() forces undefined to be
converted to
0 so the comparison will succeed:
getProperty("clip", _width) == 0
Number(getProperty("clip", _width)) == Number(0)
NOTE
If you used any Flash 5 or later keywords as variable names in your Flash 4
ActionScript, the syntax returns an error when you compile it in Flash 8. To solve this
problem, rename your variables in all locations. For information, see “About reserved
words” on page 139 and “About naming variables” on page 91.