User Guide

180 Creating Components
Testing and exporting the LogIn component
Youve created the Flash file that contains the graphical elements, the base classes and the
class file that contains all the functionality of the LogIn component. Now it’s time to test
the component.
Ideally, you would test the component as you work, especially while youre writing the class
file. The fastest way to test as you work is to convert the component to a compiled clip and
use it in the components FLA file.
When youre completely finished creating a component, export it as a SWC file. For more
information, see “Exporting and distributing a component” on page 182.
To test the LogIn component:
1. In the LogIn.fla file, select the LogIn movie clip in the library and select Convert
to Compiled Clip from the Library context menu (Windows: Right-click, Mac:
control-click).
A compiled clip is added to the library with the name LogIn SWF. You are compiling the
movie clip to test it, only. Otherwise, you would follow the instructions later in this
section to export the LogIn movie clip.
2. Drag LogIn SWF to the Stage in frame 1 of the main Timeline (make sure you’re in the
main Timeline, Scene 1, not the movie clip timeline).
You can set the name and password property in the Parameters tab or the Component
Inspector. This is useful if you want default text such as “Enter your name here” to appear
before the user has entered anything. When you set its name and/or password property,
the default text in the name and password InputText sub-components will change
accordingly at runtime.
To t e s t th e
value property at runtime, name the LogIn instance on the Stage myLogin
and add the following code to Frame 1 in the main Timeline:
// Creates a text field in which to view the login values.
createTextField("myLoginValues",10,10,10,340,40)
myLoginValues.border = true;
// Event handler for the login component instance’s dispatched click
event.
function click(evt){
/* Here is where authentication would occur.
NOTE
If you’ve already created a compiled clip (for example, if this is the second or third
time you’re testing), a Resolve Library Conflict dialog box appears. Select Replace
Existing Items to add the new version to the document.