Thanks Mike and Paul for the style solution. I changed my class so that the icon is controlled by styles rather than using mx_internal.
The only change I made was to override the styleChanged() function rather than retrieving style information in updateDisplayList(). Paul --- In [email protected], "Michael Schmalle" <[EMAIL PROTECTED]> wrote: > > I agree, styles are better for styles. Again, just answering some ones > question. What I have learned in flex is, there a re a lot of ways to climb > the mountain. > > > Ok, because I'm a big loser and I don't like using mx_internal... sorry > that I'm so lame Mike > > Thats a joke right? I don't like it either unless it gets me somewhere. > > if(this.parent!= null && this.parent is UIComponent) { > if((this.parent as UIComponent).getStyle("arrowColor")) { > _color = (this.parent as > UIComponent).getStyle("arrowColor"); > } > } > > You could replace that block with; > > var color:uint; > if (parent is IStyleClient) > color = IStyleClient(parent).getStyle("arrowColor"); > if (!isNaN(color)) > _color = color; > > > > Peace, Mike > > > On 4/27/07, Paul J DeCoursey <[EMAIL PROTECTED]> wrote: > > > > Ok, because I'm a big loser and I don't like using mx_internal... sorry > > that I'm so lame Mike... but here is a modified version that doesn't > > use mx_internal. > > > > Basically three things change from Mikes example. > > > > private function changeIcon(event:MouseEvent):void { > > myPanel.setStyle("arrowColor", 0xff0000); > > } > > > > I set a style rather than a property on an object we can't safely access. > > > > on the Icon class I add this metadata > > [Style(name="arrowColor",type="uint",format="Color",inherit="yes")] > > > > and updateDisplayList becomes this > > > > override protected function > > updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { > > super.updateDisplayList(unscaledWidth, unscaledHeight); > > if(this.parent!= null && this.parent is UIComponent) { > > if((this.parent as UIComponent).getStyle("arrowColor")) { > > _color = (this.parent as > > UIComponent).getStyle("arrowColor"); > > } > > } > > graphics.clear(); > > graphics.beginFill(_color, 1); > > graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); > > graphics.endFill(); > > } > > > > Might be possible to improve the logic in the part where it gets the > > style. > > > > Paul > > > > > > Michael Schmalle wrote: > > > Ok, I got it; > > > > > > MXML APP > > > ---------------------------------------------------------- > > > <?xml version="1.0" encoding="utf-8"?> > > > <mx:Application > > > xmlns:mx="http://www.adobe.com/2006/mxml" > > > layout="absolute"> > > > > > > > > > <mx:Script> > > > <![CDATA[ > > > > > > import mx.core.mx_internal; > > > use namespace mx_internal; > > > > > > private function changeIcon(event:MouseEvent):void > > > { > > > myPanel.titleIconObject.color = 0xFFCC00; > > > } > > > > > > ]]> > > > </mx:Script> > > > > > > <mx:Panel id="myPanel" > > > titleIcon="{Icon}" > > > title="Icon Panel"> > > > > > > <mx:List/> > > > > > > <mx:Button > > > label="Change" > > > click="changeIcon(event)"/> > > > > > > </mx:Panel> > > > > > > </mx:Application> > > > > > > > > > Icon Class > > > ---------------------------------------------------------- > > > > > > package > > > { > > > > > > import mx.skins.ProgrammaticSkin; > > > > > > public class Icon extends ProgrammaticSkin > > > { > > > private var _color:uint = 0xFF0000; > > > > > > public function get color():uint > > > { > > > return _color; > > > } > > > public function set color(value:uint):void > > > { > > > _color = value; > > > validateDisplayList(); > > > } > > > > > > public function Icon() > > > { > > > super(); > > > } > > > > > > override public function get measuredHeight():Number > > > { > > > return 16; > > > } > > > > > > override public function get measuredWidth():Number > > > { > > > return 16; > > > } > > > > > > override protected function updateDisplayList(unscaledWidth:Number, > > > > > > unscaledHeight:Number):void > > > { > > > super.updateDisplayList(unscaledWidth, unscaledHeight); > > > > > > graphics.clear(); > > > graphics.beginFill(_color, 1); > > > graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); > > > graphics.endFill(); > > > } > > > } > > > } > > > > > > > > > Peace, Mike > > > > > > > > > > > > > -- > Teoti Graphix > http://www.teotigraphix.com > > Blog - Flex2Components > http://www.flex2components.com > > You can find more by solving the problem then by 'asking the question'. >

