User Guide

Optimizing ActionScript performance 77
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 trace() statements from your code when you publish the SWF file. To do this,
select the Omit Trace Actions 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 runtime 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 your classes and efficiency of your code.
When one SWF file loads another SWF file that contains a custom ActionScript class (for
example,
foo.bar.CustomClass) and then unloads the SWF file, the class definition
remains in memory. To save memory, explicitly delete any custom classes in unloaded
SWF files. Use the
delete statement and specify the fully qualified class name, as the
following example shows:
delete foo.bar.CustomClass
Limit the use of global variables, because they are not garbage collected if the movie clip
that defined them was removed.
Avoid using the standard user interface components (available in the Components panel
in Flash Professional 8). These components 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.0 looks up references to nonexistent variables slowly,
which can significantly affect application performance.
Managing application memory
Flash Lite regularly clears from memory any objects and variables that your application no
longer references. This is known as garbage collection. Flash Lite runs its garbage collection
process once every 60 seconds, or whenever usage of application memory increases suddenly
by 20% or more.