User Guide
Incorporating existing components within your component 173
Incorporating existing components within
your component
In this section, you will build a simple LogIn component that incorporates Label, TextInput
and Button components. This tutorial demonstrates how existing components are
incorporated in new components by adding their uncompiled Flash (FLA) library symbols.
The completed component files, LogIn.fla, LogIn.as and LogIn.swf are located in the
examples folder on your hard disk:
■ In Windows: the C:\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\Components\Login folder.
■ On the Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/
Samples/Components/Login folder.
The LogIn component provides an interface for entering a name and password. The API for
LogIn has two properties,
name and password for setting and getting the string values in the
name and password TextInput fields. The LogIn component also dispatches a “click” event
when the user clicks a button labeled LogIn.
■ “Creating the LogIn Flash (FLA) file” on page 173
■ “The LogIn class file” on page 176
■ “Testing and exporting the LogIn component” on page 180
Creating the LogIn Flash (FLA) file
Start by creating a Flash (FLA) file that will hold our component symbol.
To create the LogIn FLA file:
1. In Flash, select File > New and create a new document.
2. Select File > Save As and save the file as LogIn.fla.
3. Create Select Insert > New Symbol. Name it LogIn, and select the Movie clip type
radio button.
If the Linkage section of the Create New Symbol dialog isn’t open, click the Advanced
button to reveal it.
4. Select Export for ActionScript and deselect Export in First Frame.
5. Enter a linkage identifier.
The default linkage identifier is LogIn. The rest of these steps assume you use the
default value.