EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Actionscript and Flash Player Optimization

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
762 Best Practices and Coding Conventions for ActionScript 2.0
About stopping code repetition
The onEnterFrame event handler is useful because Flash can use it to repeat code at the frame
rate of a SWF file. However, limit the amount of repetition that you use in a Flash file as
much as possible so that you do not affect performance. For example, if you have a piece of
code that repeats whenever the playhead enters a frame, it is processor intensive. This
behavior can cause performance problems on computers that play the SWF file. If you use the
onEnterFrame event handler for any kind of animation or repetition in your SWF files, delete
the
onEnterFrame handler when you finish using it. In the following ActionScript 2.0 code,
you stop repetition by deleting the
onEnterFrame event handler:
circleClip.onEnterFrame = function() {
circleClip._alpha -= 5;
if (circleClip._alpha<=0) {
circleClip.unloadMovie();
delete this.onEnterFrame;
trace("deleted onEnterFrame");
}
};
Similarly, limit the use of setInterval, and remember to clear the interval when you finish
using it to reduce processor requirements for the SWF file.
ActionScript and Flash Player
optimization
If you compile a SWF file that contains ActionScript 2.0 with publish settings set to Flash
Player 6 and ActionScript 1.0, your code functions as long as it does not use ActionScript 2.0
classes. No case sensitivity is involved with the code, only Flash Player. Therefore, if you
compile your SWF file with Publish Settings set to Flash Player 7 or 8 and ActionScript 1.0,
Flash enforces case sensitivity.
Data type annotations (strict data types) are enforced at compile time for Flash Player 7 and 8
when you have publish settings set to ActionScript 2.0.
ActionScript 2.0 compiles to ActionScript 1.0 bytecode when you publish your applications,
so you can target Flash Player 6, 7, or 8 while working with ActionScript 2.0.
For more information on optimizing your applications, see “Optimizing your code”.

Table of Contents

Related product manuals