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”
.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...