Overview of a component class file
The following procedure is an overview of the creation of an ActionScript file for a component.
Some steps may be optional, depending on the type of component you create.
To write a component class file:
(Optional) Import classes. (See
1.
This allows you to refer to classes without writing out the package (for example, Button instead
of mx.controls.Button).
Define the class using the
2.
"Defining the class and its superclass" on page
Define the
3.
symbolName
symbol, and owner names" on page
These variables are necessary only in version 2 components.
Define member variables. (See
4.
These can be used in getter/setter methods.
Define a constructor function. (See
5.
Define an
6.
init()
This method is called when the class is created if the class extends UIComponent. If the class
extends MovieClip, call this method from the constructor function.
Define a
7.
createChildren()
on page
946).
This method is called when the class is created if the class extends UIComponent. If the class
extends MovieClip, call this method from the constructor function.
Define a
8.
size()
This method is called when the component is resized, if the class extends UIComponent. In
addition, this method is called when the component's live preview is resized during authoring.
Define a
9.
draw()
This method is called when the component is invalidated, if the class extends UIComponent.
Add a Metadata tag and declaration. (See
10.
Adding the tag and declaration causes getter/setter properties to appear in the Property
inspector and Component inspector in Flash.
Define getter/setter methods. (See
11.
on page
935).
(Optional) Create variables for every skin element/linkage used in the component. (See
12.
assigning skins" on page
This allows users to set a different skin element by changing a parameter in the component.
932
Chapter 7: Creating Components
"Importing classes" on page
keyword; use the
class
,
, and
symbolOwner
933).
"Defining variables" on page
"Defining the constructor function" on page
method. (See
"Defining the init() method" on page
method. (See
method. (See
"Defining the size() method" on page
method. (See
"About invalidation" on page
"Using getter/setter methods to define parameters"
950).
933).
keyword to extend a parent class. (See
extend
933).
variables. (See
className
934).
"Defining the createChildren() method"
948).
"Adding component metadata" on page
"Identifying the class,
944).
945).
947).
935).
"About
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?
Questions and answers