Flash 4 ActionScript had only one true data type: string. It used different types of operators in expressions to indicate whether the value should be treated as a string or as a number. In subsequent releases of Flash, you can use one set of operators on all data types.
When you use Flash 5 or later to open a file that was created in Flash 4, Flash automatically converts ActionScript expressions to make them compatible with the new syntax. You'll see the following data type and operator conversions in your ActionScript code:
=
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 ==
. +
, ==
, !=
, <>
, <
, >
, >=
, <=
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 any 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
).
\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
. &
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. Get Timer
, Set Variable
, Stop
, and Play
. To create consistent syntax, the getTimer
function and all actions now require closing parentheses. These parentheses are automatically added during the conversion. 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
). Flash fixes 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 in Matador. To fix this problem, rename your variables in all locations. See Keywords.
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. However, if you are creating content intended specifically for Flash Player 4, you need to use slash syntax.
In slash syntax, slashes are used instead of dots; also, to indicate a variable, you precede it with a colon:
myMovieClip/childMovieClip:myVariable
To write the same target path in dot syntax, which is supported by Flash 5 and later, you would use the following code:
myMovieClip.childMovieClip.myVariable
Slash syntax was most commonly used with the tellTarget
action, whose use is also no longer recommended. The with
action is now preferred over tellTarget
because it is more compatible with dot syntax. For more information, see tellTarget
and with
.