User Guide
Building your first component 127
It’s a good idea to save the component’s FLA and AS files in the same folder and give them the
same name. If the AS file is not saved in the same folder, you must verify that the folder is in
the classpath so the FLA file can find it. For more information about the classpath, see
“Classes” in Learning ActionScript 2.0 in Flash.
Building your first component
In this section, you will build a Dial component. The completed component files, Dial.fla,
Dial.as, and DialAssets.fla are located in the examples folder on your computer:
■ In Windows: the C:\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\Components\DialComponent folder.
■ On the Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/
Samples/Components/DialComponent folder.
The Dial component is a potentiometer, like those used to measure potential difference in
voltage. A user can click on the needle and drag it to change its position. The API for the Dial
component has one property,
value, that you can use to get and set the position of
the needle.
This section takes you through the steps of creating a component. These procedures are
discussed in more detail in subsequent sections (including “Selecting a parent class”
on page 136, “Creating a component movie clip” on page 138, “Creating the ActionScript
class file” on page 143, and “Exporting and distributing a component” on page 182).This
section contains the following topics:
■ “Creating the Dial Flash (FLA) file” on page 127
■ “Creating the Dial class file” on page 130
■ “Testing and exporting the Dial component” on page 133
Creating the Dial Flash (FLA) file
The first steps for creating a component include creating the component movie clip within a
FLA document file.
To create the Dial FLA file:
1. In Flash, select File > New and create a new document.
2. Select File > Save As and save the file as Dial.fla.
The file can have any name, but giving it the same name as the component is practical.
3. Select Insert > New Symbol. The component itself is created as a new MovieClip symbol
so it will be available through the library.
Name the component Dial, and assign it the behavior Movie clip.