Example: Creating style properties
191
// Define the variable to hold the current gradient fill colors.
private var fillColorsData:Array;
private var bFillColorsChanged:Boolean = true;
// Define variables for additional controls on the fill.
// You can create style properties for these as well.
private var alphas:Array = [1.0, 1.0];
private var ratios:Array = [0x00, 0xFF];
// Override styleChanged() to detect changes in your new style.
override public function styleChanged(styleProp:String):void {
super.styleChanged(styleProp);
// Check to see if style changed.
if (styleProp=="fillColors")
{
bFillColorsChanged=true;
invalidateDisplayList();
return;
}
}
// Override updateDisplayList() to update the component
// based on the style setting.
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void {
super.updateDisplayList(unscaledWidth, unscaledHeight);
// Check to see if style changed.
if (bFillColorsChanged==true)
{
// Redraw gradient fill only if style changed.
fillColorsData=getStyle("fillColors");
graphics.beginGradientFill(GradientType.LINEAR,
fillColorsData, alphas, ratios);
graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
}
}
}
}
Содержание FLEX 2 - CREATING AND EXTENDING COMPONENTS
Страница 1: ...Creating and Extending Flex 2 Components Adobe Flex 2...
Страница 6: ...6 Contents...
Страница 10: ...10 About Flex Documentation...
Страница 12: ......
Страница 24: ...24 Creating Flex Components...
Страница 74: ...74 Compiling Components...
Страница 76: ......
Страница 118: ...118 Creating Advanced MXML Components...
Страница 120: ......
Страница 182: ...182 Creating Advanced Visual Components in ActionScript...
Страница 194: ...194 Creating Custom Style Properties...
Страница 204: ...204 Creating Template Components...
Страница 206: ......
Страница 216: ...216 Creating Custom Formatters...
Страница 254: ...254 Index...