Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 151

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

The following example creates a
// Create a Box container.
var boxContainer:Box = new Box();
// Configure the Box container.
// Create a Button control.
var b:Button = new Button()
// Configure the button control.
b.label = "Submit";
...
// Add the Button control to the Box container.
boxContainer.addChild(b);
The following steps show what occurs when you execute the code to create the Button
control, and add the control to the Box container:
You call the component's constructor, as the following code shows:
1.
// Create a Button control.
var b:Button = new Button()
You configure the component by setting its properties, as the following code shows:
2.
// Configure the button control.
b.label = "Submit";
Component setter methods might call the
invalidateSize()
You call the
3.
addChild()
shows:
// Add the Button control to the Box container.
boxContainer.addChild(b);
Flex performs the following actions:
Sets the
a.
parent
Computes the style settings for the component.
b.
Dispatches the
c.
Calls the component's
d.
Calls the
e.
invalidateProperties()
invalidateDisplayList()
commitProperties()
next
event.
render
The only exception to this rule is that Flex does not call the
the user sets the height and width of the component.
Button
control in ActionScript and adds it to a container:
, or
invalidateDisplayList()
method to add the component to its parent, as the following code
property for the component to reference its parent container.
event on the component.
preinitialize
createChildren()
methods to trigger later calls to the
,
, or
measure()
invalidateProperties()
methods.
method.
,
invalidateSize()
updateDisplayList()
About creating advanced components
,
, and
methods during the
method when
measure()
151

Advertisement

Table of Contents
loading

Table of Contents