User Guide
Example: Creating style properties 187
Typically, you use a flag to indicate that a style changed. In the updateDisplayList()
method, you check the flag and update the component based on the new style setting, as the
following example shows:
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void {
super.updateDisplayList(unscaledWidth, unscaledHeight);
// Check to see if style changed.
if (bBackgroundColor==true)
{
// Redraw the component using the new style.
...
}
}
By using flags to signal style updates to the updateDisplayList() method, the
updateDisplayList() method has to perform only the updates based on the style changes; it
may not have to redraw or recalculate the appearance of the entire component. For example, if
you are changing only the border color of a component, it is more efficient to redraw only the
border, rather than redrawing the entire component every time someone changes a style.
Example: Creating style properties
When you create a component, you might want to create a style property so that component
users can configure it by using styles. For example, you create a component, named
StyledRectangle, that uses a gradient fill pattern to define its color, as the following example
shows: