Adobe FLASH CS3 PRO User Manual page 503

Hide thumbs Also See for FLASH CS3 PRO:
Table of Contents

Advertisement

• Always try to access properties directly rather than using ActionScript getter and setter methods, which have more
overhead than other method calls.
• Manage events wisely. Keep event listener arrays compact by using conditions to check whether a listener exists
(is not
) before calling it. Clear any active intervals by calling
null
listeners by calling
removeListener
. Flash does not re-collect SWF data memory (for example, from intervals and listeners) if any Action-
tionClip
Script functions are still referring to the SWF data when a movie clip is unloaded.
• When variables are no longer needed, delete them or set them to
Deleting variables helps optimize memory use during run time, because unneeded assets are removed from the
SWF file. It is better to delete variables than to set them to
• Explicitly remove listeners from objects by calling
• If a function is being called dynamically and passing a fixed set of parameters, use
• Make namespaces (such as paths) more compact to reduce startup time. Every level in the package is compiled to
an
statement and causes a new
IF
with the levels
com.xxx.yyy.aaa.bbb.ccc.funtionName
com.xxx.yyy.aaa.bbb.ccc
identifier, such as
58923409876.functionName
• If a file consists of multiple SWF files that use the same ActionScript classes, exclude those classes from select SWF
files during compilation. This can help reduce file download time and run-time memory requirements.
• Avoid using
Object.watch
to determine whether a change notification must be sent.
• If ActionScript code that executes on a keyframe in the timeline requires more than 1 second to complete, consider
splitting up that code to execute over multiple keyframes.
• Remove
statements from the code when publishing the SWF file. To do this, select the Omit Trace Actions
trace
check box on the Flash tab in the Publish Settings dialog box.
• Inheritance increases the number of method calls and uses more memory: a class that includes all the functionality
it needs is more efficient at run time than a class that inherits some of its functionality from a superclass.
Therefore, you may need to make a design trade-off between extensibility of classes and efficiency of code.
• When one SWF file loads another SWF file that contains a custom ActionScript class (for example,
foo.bar.CustomClass
explicitly delete any custom classes in unloaded SWF files. Use the
qualified class name, such as:
• Limit the use of global variables, because they are not marked for garbage collection if the movie clip that defined
them is removed.
• Avoid using the standard user interface components (available in the Components panel in Flash). These compo-
nents are designed to run on desktop computers and are not optimized to run on mobile devices.
• Whenever possible, avoid deeply nested functions.
• Avoid referencing nonexistent variables, objects, or functions. Compared to the desktop version of Flash Player,
Flash Lite 2 looks up references to nonexistent variables slowly, which can significantly affect performance.
• Avoid defining functions using anonymous syntax. For example,
Explicitly defined functions are more efficient, such as
.
myFunc;
before removing content using
call, so having fewer levels in the path saves time. For example, a path
Object
. Some Flash developers use preprocessor software to reduce the path to a unique
, before compiling the SWF code.
and
Object.unwatch
) and then unloads the SWF file, the class definition remains in memory. To save memory,
delete foo.bar.CustomClass.
clearInterval
unloadapplication
, which marks them for garbage collection.
null
.
null
before garbage collection.
removeListener
causes an object to be instantiated for
, because every change to an object property requires the player
statement and specify the fully
delete
myObj.eventName = function{ ...}
function myFunc { ...}; my Obj.eventName =
FLASH CS3
User Guide
, and remove any active
or
removeapplica-
instead of
.
call
apply
.
497

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash cs3 professional

Table of Contents