MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 34

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Rather than attaching your scripts to elements like keyframes, movie clips, and buttons, you
should respond to events by calling functions that reside in a central location. One method is
to attach embedded ActionScript to the first or second frame of a timeline whenever possible
so you don't have to search through the FLA file to find all your code. A common practice is
to create a layer called actions and place your ActionScript code there.
When you attach all your scripts to individual elements, you're embedding all your code in the
FLA file. If sharing your code between other Flash applications is important to you, use the
Script window or your favorite text editor to create an external ActionScript (AS) file.
By creating an external file, you make your code more modular and well organized. As your
project grows, this convenience becomes much more useful than you might imagine. An
external file aids debugging and also source control management if you're working on a
project with other developers.
To use the ActionScript code contained in an external AS file, you create a script within the
FLA file and then use the
shown in the following example:
#include "../core/Functions.as"
You can also use ActionScript 2.0 to create custom classes. You must store custom classes in
external AS files and use
SWF file, instead of using
see
"Writing custom class files" on page 235
about importing class files. You can also use components (prebuilt movie clips) to share code
and functionality, such as UI elements and scripts.
ActionScript code in external files is compiled into a SWF file when you publish, export,
test, or debug a FLA file. Therefore, if you make any changes to an external file, you must
save the file and recompile any FLA files that use it.
When you write ActionScript in Flash 8, you use the Actions panel, the Script window, or
both. When you use the Actions panel or Script window is dictated by how you respond to
events, how you organize your code, and, most importantly, coding best practices.
For more information about coding best practices and conventions, see
conventions" on page
34
Writing and Editing ActionScript 2.0
statement to access the code you've stored externally, as
#include
statements in a script to get the classes exported into the
import
statements. For more information on writing class files,
#include
745.
and
"About importing class files" on page 239
"ActionScript coding

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents