To define an item renderer in ActionScript, override the
necessary methods from the parent class, and call any necessary
invalidation methods from within your overrides. For general information
on this process, see Create advanced Spark visual components in ActionScript.
The methods that you have to override in your class depend on
the parent class of the item renderer. You optionally can override
one or more of the following protected methods of the parent class:
Method
|
Description
|
|
|
Commits any changes to component properties,
either to make the changes occur at the same time or to ensure that
properties are set in a specific order.
For more information,
see Implementing the commitProperties() method for MX components.
|
|
|
Creates any child components of the component.
For example, the ComboBox control contains a TextInput control and
a Button control as child components.
For more information,
see Implementing the createChildren() method for MX components.
|
|
|
Sets the default size and default minimum
size of the component.
For more information, see Implementing the measure() method for MX components.
|
styleChanged()
|
Detects changes to style properties.
For
more information, see Overriding the styleChanged() method.
|
|
|
Sizes and positions the children of the
component on the screen based on all previous property and style settings,
and draws any skins or graphic elements used by the component. The
parent container for the component determines the size of the component
itself.
Note: You typically only have to implement this method
when you use the mx.core.UIComponent class as the base class of
your item renderer. You do not have to implement it when creating
a subclass of the LabelItemRenderer class. Override LabelItemRenderer.drawBackground() and LabelItemRenderer.layoutContent() instead.
For
more information, see Implementing the updateDisplayList() method for MX components.
|
If the parent class is the LabelItemRenderer, you typically override
one or both of the following methods:
Method
|
Description
|
drawBackground()
|
Defines the background display of the item
renderer.
|
layoutContents()
|
Lays out the children of the item renderer.
|
Flex uses an invalidation mechanism to synchronize modifications
to components. Flex implements the invalidation mechanism as a set
of methods that you call to signal that something about the component
has changed and requires Flex to call the component’s commitProperties(), measure(),
or updateDisplayList() methods.
The following table describes the invalidation methods:
Invalidation method
|
Description
|
|
|
Marks a component so that its commitProperties() method
gets called during the next screen update.
|
|
|
Marks a component so that its measure() method
gets called during the next screen update.
|
|
|
Marks a component so that its updateDisplayList() methods
get called during the next screen update.
|
When a component calls an invalidation method, it signals to
Flex that the component must be updated. When multiple components
call invalidation methods, Flex coordinates the updates so that
they all occur together during the next screen update. For more
information on these methods, see About the invalidation methods for MX components.