
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Flash 4 Versus Flash 5 (and Later)
|
985
in Flash 5 and later. The old syntax is deprecated and no longer recommended.
Table C-2 shows equivalencies between Flash 4 and Flash 5 and later syntax when
addressing variables. See Table C-1 for other syntactical differences.
Local Variables in Flash 4–Style Subroutines
Although functions are the preferred mechanism for producing portable code mod-
ules, Flash 5 and Flash 6 still support Flash 4–style subroutines. In Flash 4, a subrou-
tine could be created by attaching a block of code to a frame with a label. Later, the
subroutine could be executed remotely via the Call action. But in Flash 4, any vari-
able declared in a subroutine was nonlocal and persisted for the lifetime of the time-
line on which it was defined. In Flash 5 and later, you can create local variables in
subroutines the same way we create them in functions—using the var statement.
However, variables defined with var in a subroutine are created as local variables
only when the subroutine is executed via the Call function. If the script on the sub-
routine frame is executed as a result of the playhead simply entering the frame, the
var statement declares a normal timeline nonlocal variable. Regardless, the more
modern functions and local function variables should be used instead ...