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
>

Reply via email to