About initialization
For the initial values for variables, assign a default value or allow the value of
the following class example shows. When you initialize properties inline, the expression on the
right side of an assignment must be a compile-time constant. That is, the expression cannot
refer to anything that is set or defined at runtime. Compile-time constants include string
literals, numbers, Boolean values, null, and undefined, as well as constructor functions for the
following top-level classes: Array, Boolean, Number, Object, and String. This class sets the
initial values of
m_username
class User {
private var m_username:String = "";
private var m_password:String = "";
function User(username:String, password:String) {
this.m_username = username;
this.m_password = password;
}
}
Delete variables or make variables
can still enhance performance. This process is commonly called garbage collection.
null
Deleting variables helps optimize memory use during runtime, because unneeded assets are
removed from the SWF file. It is better to delete variables than to set them to
information on performance, see
Flash Player 8 has made improvements in garbage collection within Flash Player.
For information on naming variables, see
information on deleting objects, see delete statement in ActionScript 2.0 Language
Reference.
754
Best Practices and Coding Conventions for ActionScript 2.0
and
to empty strings:
m_password
when you no longer need them. Setting variables to
null
"Optimizing your code" on page
"Naming variables" on page
undefined
. For more
null
763.
736. For more
, as
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?