User Guide
176 Creating Components
16. Use the Info panel to resize the BoundingBox to the size of the LogInFinal movie clip (340,
150), and position it at 0, 0.
The BoundingBox instance is used to create the component’s live preview and allow the
user to handle resize the component during authoring. You must set the size of the
bounding box so that it can enclose all the graphical elements in your component.
17. Select the LogIn movie clip in the library, and select Component Definition from the
Library context menu (Windows: Right-click, Mac: control-click).
18. In the AS 2.0 Class text box, enter LogIn.
This value is the name of the ActionScript class. If the class is in a package, the value is the
full package. For example, mx.controls.CheckBox denotes the CheckBox class in the
mx.controls package.
19. Click OK.
20.Save the file.
The LogIn class file
The following code is the ActionScript class for the LogIn component. Please read the
comments in the code for a description of each section. (For detailed information on the
elements of a component class file, see “Overview of a component class file” on page 144).
To create this file, you can create a new ActionScript file in Flash, or use any other text editor.
Save the file as LogIn.as in the same folder as the LogIn.fla file.
You can copy or type the following LogIn component ActionScript class code into your new
LogIn.as file. Typing rather than copying the code will help you become familiar with each
element of the component code.
/* Import the packages so they can be referenced
from this class directly. */
import mx.core.UIComponent;
import mx.controls.Label;
import mx.controls.TextInput;
import mx.controls.Button;
// Event metadata tag
[Event("change")]
NOTE
If you are extending a component (including any version 2 component) you must
keep instance names already in use by that component as its code will refer to those
instance names. For example, if you include a version 2 component that is already
using the instance name boundingBox_mc, do not rename it. For your own
components, you can choose any instance name that is unique and that does not
conflict with an existing name within the same scope.