Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 191

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

Advertisement

// 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,
graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
}
}
}
}
fillColorsData, alphas, ratios);
Example: Creating style properties
191

Advertisement

Table of Contents
loading

Table of Contents