![MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual Download Page 51](http://html1.mh-extra.com/html/macromedia/flex-developing-components-and-themes/flex-developing-components-and-themes_manual_3388115051.webp)
Writing the component’s ActionScript code
51
The following example adds the
symbolName
,
symbolOwner
, and
className
properties to the
MyButton class:
class MyButton extends mx.controls.Button {
static var symbolName:String = "myPackage.MyButton";
static var symbolOwner = myPackage.MyButton;
var className:String = "MyButton";
...
}
About the component instantiation life cycle
When you instantiate a new component, Flex calls a number of methods, and those methods call
other methods that you can override. Instantiating a new control in your application triggers the
following method calls by Flex:
1.
Class constructor
After the class constructor is called, Flex calls the
constructObject2()
method.
2.
The
constructObject2()
method
When you implement the
constructObject2()
method, you must call the
super.constructObject2()
method or make manual calls to the
init()
and
createChildren()
methods.
3.
The
init()
method
Flex calls the
init()
method from the parent class’s
constructObject2()
method.
4.
The
createChildren()
method
Flex calls the
createChildren()
method from the parent class’s
constructObject2()
method.
5.
The
measure()
method
Flex calls the
measure()
method.
6.
The
layoutChildren()
method
Flex calls the
layoutChildren()
method.
7.
The
draw()
method
Flex calls the
draw()
method.
Each of the
measure()
,
layoutChildren()
, and
draw()
methods has a corresponding invalidate
function. For more information, see
“About invalidation” on page 68
.
The remaining sections describe each of these methods. For the purposes of initialization, you do
not need to add any explicit calls to these methods, because Flex initiates each call. However, you
might be required to explicitly call some of these methods to refresh the object’s state after it has
been created and displayed.