Building Your First Component - MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual

Using components
Hide thumbs Also See for FLASH MX 2004-USING COMPONENTS:
Table of Contents

Advertisement

Building your first component

In this section, you will build a Dial component. The completed component files, Dial.fla,
Dial.as, Dial.swf, and DialAssets.fla are located in the examples folder on your hard disk:
Macromedia/Flash MX 2004/Samples/HelpExamples/DialComponent
The Dial component is a potentiometer. A user can click on the needle and drag it to change its
position. The API for the Dial has one property,
position of the needle.
"Creating the Dial Flash (FLA) file" on page 918
"Creating the Dial class file" on page 920
"Testing and exporting the Dial component" on page 922
This section is much like a tutorial. These same procedures are discussed in more detail in
subsequent sections. (See
Creating the Dial Flash (FLA) file
First you must create a Flash (FLA) file.
To create the Dial FLA file:
In Flash, choose File > New and create a new document.
1.
Choose File > Save As and save the file as Dial.fla.
2.
The file can have any name, but giving it the same name as the component is practical.
Choose Insert > New Symbol.
3.
Give it the name Dial, and the behavior Movie clip.
If the Linkage section of the Create New Symbol dialog isn't open, click the Advanced button
4.
to reveal it.
Select Export for ActionScript and deselect Export in First Frame.
5.
Enter the AS 2.0 Class Dial.
6.
This value is the component class name. If the class is in a package (for example,
mx.controls.Button), enter the entire package name.
Click OK.
7.
Flash opens into Edit Symbol mode.
Insert a new layer.
8.
Name the top layer Actions and the bottom layer Assets.
Select Frame 2 in the Assets layer and insert a keyframe (F6).
9.
This is the structure of the component movie clip: an Actions layer and an Assets layer. The
Actions layer has 1 keyframe and the Assets layer has 2 keyframes.
Select Frame 1 in the Actions layer and open the Actions panel (F9). Enter a
10.
This prevents the movie clip from proceeding to Frame 2.
918
Chapter 7: Creating Components
"Selecting a parent class" on page
, that you can use to get and set the
value
924.)
action.
stop();

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx

Table of Contents