Re: [flexcoders] Re: Programatic Icon
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, 0xff); } 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 = 0xFF; 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'.
Re: [flexcoders] Re: Programatic Icon
Michael Schmalle 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. yes, it's a joke. 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; thanks, that is much better. 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, 0xff); } 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 = 0xFF; 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
[flexcoders] Re: Programatic Icon
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 flexcoders@yahoogroups.com, 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, 0xff); } 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 = 0xFF; 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'.
[flexcoders] Re: Programatic Icon
Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set color(value:uint):void { iconColor = value; invalidateDisplayList(); } 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.beginFill(iconColor, 1); graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); graphics.endFill(); } } } I can place this icon in a Panel like this: mx:Panel id=myPanel titleIcon={Icon} ... So far so good -- the red square is drawn in the top left corner of the title area and it appears that I can call the color setter function like this: myPanel.titleIcon.color = 0x00FF00; But when I do this the icon color never changes. It appears that the calling invalidateDisplayList() never results in a call to updateDisplayList(). Any ideas? Paul --- In flexcoders@yahoogroups.com, Paul J DeCoursey [EMAIL PROTECTED] wrote: I've been able to get it to work for buttons and the like by extending ProgrammaticSkin and passing in the class. I've never even used the icon on a TitleWindow to even know how it's supposed to work. It should work, because everything is a class, but it might not know what to do with it. Paul Michael Schmalle wrote: Hi, The simple answer is no. Why? The titleIcon class is of type Class. This class cannot be subclassed. My advice to you is create a subclass of TitleWindow and create the method you are talking about there. Since you cannot load icons at runtime, you could create a simple iconLibraryModule that held your extra icons and then the method you created in the subclass would then load the icons from the icon library on demand through some type of string call into the library. Conclusion, there is no way to create an image like component in components with properties of type Class. In my custom window, I wrap the icon in a UIComponent, this way when I am rendering the icon, I have 2 options. The icon property is the 'source' but not the actual instance that is manipulated in the component UI. Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Would anyone know if there is a way to create an component that can be used as an icon for any component that accepts an icon? For example, TitleWindow accepts a titleIcon. I would like to create an AS3 class that I can instantiate and specify for the TitleWindow's titleIcon. As conditions change in the window, I'd like to be able to make a function call to the icon class and have it update the icon displayed by the TitleWindow. The class would programatically create the icon (i.e., it would not use an embedded asset). Ideally the icon component should be able to be used for any component that accepts an icon. Any idea if this can be done and if so where I should start looking to create such a component? Thanks! Paul
Re: [flexcoders] Re: Programatic Icon
Hi, For one I see you are missing; graphics.clear(); Try that, I don't think you are erasing the old color. Peace, Mike PS hehe I was thinking about something else when I responded and forgot the internal icon is typed IFlexDisplayObject. On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set color(value:uint):void { iconColor = value; invalidateDisplayList(); } 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.beginFill(iconColor, 1); graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); graphics.endFill(); } } } I can place this icon in a Panel like this: mx:Panel id=myPanel titleIcon={Icon} ... So far so good -- the red square is drawn in the top left corner of the title area and it appears that I can call the color setter function like this: myPanel.titleIcon.color = 0x00FF00; But when I do this the icon color never changes. It appears that the calling invalidateDisplayList() never results in a call to updateDisplayList(). Any ideas? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Paul J DeCoursey [EMAIL PROTECTED] wrote: I've been able to get it to work for buttons and the like by extending ProgrammaticSkin and passing in the class. I've never even used the icon on a TitleWindow to even know how it's supposed to work. It should work, because everything is a class, but it might not know what to do with it. Paul Michael Schmalle wrote: Hi, The simple answer is no. Why? The titleIcon class is of type Class. This class cannot be subclassed. My advice to you is create a subclass of TitleWindow and create the method you are talking about there. Since you cannot load icons at runtime, you could create a simple iconLibraryModule that held your extra icons and then the method you created in the subclass would then load the icons from the icon library on demand through some type of string call into the library. Conclusion, there is no way to create an image like component in components with properties of type Class. In my custom window, I wrap the icon in a UIComponent, this way when I am rendering the icon, I have 2 options. The icon property is the 'source' but not the actual instance that is manipulated in the component UI. Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Would anyone know if there is a way to create an component that can be used as an icon for any component that accepts an icon? For example, TitleWindow accepts a titleIcon. I would like to create an AS3 class that I can instantiate and specify for the TitleWindow's titleIcon. As conditions change in the window, I'd like to be able to make a function call to the icon class and have it update the icon displayed by the TitleWindow. The class would programatically create the icon (i.e., it would not use an embedded asset). Ideally the icon component should be able to be used for any component that accepts an icon. Any idea if this can be done and if so where I should start looking to create such a component? Thanks! Paul -- 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'.
Re: [flexcoders] Re: Programatic Icon
Ah, I know why you are not seeing updateDisplayList() called. Since this is ProgrammaticSkin, if the size doesn't change, the method will skip. The layoutManager calls setActualSize() and in that call if height or width did not change, you won't get the call. I had this same problem. In your color property, call validateDisplayList(); that will do the trick. Peace, Mike On 4/27/07, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, For one I see you are missing; graphics.clear(); Try that, I don't think you are erasing the old color. Peace, Mike PS hehe I was thinking about something else when I responded and forgot the internal icon is typed IFlexDisplayObject. On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set color(value:uint):void { iconColor = value; invalidateDisplayList(); } 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.beginFill(iconColor, 1); graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); graphics.endFill(); } } } I can place this icon in a Panel like this: mx:Panel id=myPanel titleIcon={Icon} ... So far so good -- the red square is drawn in the top left corner of the title area and it appears that I can call the color setter function like this: myPanel.titleIcon.color = 0x00FF00; But when I do this the icon color never changes. It appears that the calling invalidateDisplayList() never results in a call to updateDisplayList(). Any ideas? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Paul J DeCoursey [EMAIL PROTECTED] wrote: I've been able to get it to work for buttons and the like by extending ProgrammaticSkin and passing in the class. I've never even used the icon on a TitleWindow to even know how it's supposed to work. It should work, because everything is a class, but it might not know what to do with it. Paul Michael Schmalle wrote: Hi, The simple answer is no. Why? The titleIcon class is of type Class. This class cannot be subclassed. My advice to you is create a subclass of TitleWindow and create the method you are talking about there. Since you cannot load icons at runtime, you could create a simple iconLibraryModule that held your extra icons and then the method you created in the subclass would then load the icons from the icon library on demand through some type of string call into the library. Conclusion, there is no way to create an image like component in components with properties of type Class. In my custom window, I wrap the icon in a UIComponent, this way when I am rendering the icon, I have 2 options. The icon property is the 'source' but not the actual instance that is manipulated in the component UI. Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Would anyone know if there is a way to create an component that can be used as an icon for any component that accepts an icon? For example, TitleWindow accepts a titleIcon. I would like to create an AS3 class that I can instantiate and specify for the TitleWindow's titleIcon. As conditions change in the window, I'd like to be able to make a function call to the icon class and have it update the icon displayed by the TitleWindow. The class would programatically create the icon (i.e., it would not use an embedded asset). Ideally the icon component should be able to be used for any component that accepts an icon. Any idea if this can be done and if so where I should start looking to create such a component? Thanks! Paul -- 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'. -- 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'.
[flexcoders] Re: Programatic Icon
Unfortunately that did not work. It looks like the setter is not really being called after all. When I do this: myPanel.titleIcon.color = 0x00FF00; What seems to be happening is that it is creating a property called color just as if myPanel.titleIcon was a generic Object. I tried creating a doIconColor function (rather than using a setter) in Icon and calling it like this: Icon(myPanel.titleIcon).doIconColor(0xFF00FF); But this results in an TypeError: TypeError: Error #1034: Type Coercion failed: cannot convert components::Icon$ to components.Icon. I can't simply do this: myPanel.titleIcon.doIconColor(0xFF00FF); because I get a compile error (call to a possibly undefined method doIconColor) So the question now becomes, how do I call a function of my Icon class? Thanks for any suggestions! Paul --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Ah, I know why you are not seeing updateDisplayList() called. Since this is ProgrammaticSkin, if the size doesn't change, the method will skip. The layoutManager calls setActualSize() and in that call if height or width did not change, you won't get the call. I had this same problem. In your color property, call validateDisplayList(); that will do the trick. Peace, Mike On 4/27/07, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, For one I see you are missing; graphics.clear(); Try that, I don't think you are erasing the old color. Peace, Mike PS hehe I was thinking about something else when I responded and forgot the internal icon is typed IFlexDisplayObject. On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set color(value:uint):void { iconColor = value; invalidateDisplayList(); } 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.beginFill(iconColor, 1); graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); graphics.endFill(); } } } I can place this icon in a Panel like this: mx:Panel id=myPanel titleIcon={Icon} ... So far so good -- the red square is drawn in the top left corner of the title area and it appears that I can call the color setter function like this: myPanel.titleIcon.color = 0x00FF00; But when I do this the icon color never changes. It appears that the calling invalidateDisplayList() never results in a call to updateDisplayList(). Any ideas? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Paul J DeCoursey paul@ wrote: I've been able to get it to work for buttons and the like by extending ProgrammaticSkin and passing in the class. I've never even used the icon on a TitleWindow to even know how it's supposed to work. It should work, because everything is a class, but it might not know what to do with it. Paul Michael Schmalle wrote: Hi, The simple answer is no. Why? The titleIcon class is of type Class. This class cannot be subclassed. My advice to you is create a subclass of TitleWindow and create the method you are talking about there. Since you cannot load icons at runtime, you could create a simple iconLibraryModule that held your extra icons and then the method you created in the subclass would then load the icons from the icon library on demand through some type of string call into the library. Conclusion, there is no way to create an image like component in components with properties of type Class. In my custom window, I wrap the icon in a UIComponent, this way when I am rendering the icon, I have 2 options. The icon property is the 'source' but not the actual instance that is manipulated in the component UI. Peace, Mike On 4/27/07, Paul Whitelock news@ wrote: Would anyone know if there is a way to create an component that can be used as an icon for any component that accepts an icon? For example, TitleWindow accepts a titleIcon. I would like to create an AS3 class that I can instantiate and specify for the TitleWindow's titleIcon. As conditions change in the window, I'd like to be able to make a function call to the icon class and have it update the icon displayed by the
Re: [flexcoders] Re: Programatic Icon
HAHA, Man, it must be Friday. Ok, the problem is this; titleIcon is the setter for the reference to the class that is creating the icon. You need the actual reference to the icon instance. try this; import mx.core.mx_internal; use namespace mx_internal; myPanel::mx_internal.titleIconObject.color = 0x00FF00; BTW we all know mx_internal is not supported but it will get you what you want. :) Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Unfortunately that did not work. It looks like the setter is not really being called after all. When I do this: myPanel.titleIcon.color = 0x00FF00; What seems to be happening is that it is creating a property called color just as if myPanel.titleIcon was a generic Object. I tried creating a doIconColor function (rather than using a setter) in Icon and calling it like this: Icon(myPanel.titleIcon).doIconColor(0xFF00FF); But this results in an TypeError: TypeError: Error #1034: Type Coercion failed: cannot convert components::Icon$ to components.Icon. I can't simply do this: myPanel.titleIcon.doIconColor(0xFF00FF); because I get a compile error (call to a possibly undefined method doIconColor) So the question now becomes, how do I call a function of my Icon class? Thanks for any suggestions! Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Ah, I know why you are not seeing updateDisplayList() called. Since this is ProgrammaticSkin, if the size doesn't change, the method will skip. The layoutManager calls setActualSize() and in that call if height or width did not change, you won't get the call. I had this same problem. In your color property, call validateDisplayList(); that will do the trick. Peace, Mike On 4/27/07, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, For one I see you are missing; graphics.clear(); Try that, I don't think you are erasing the old color. Peace, Mike PS hehe I was thinking about something else when I responded and forgot the internal icon is typed IFlexDisplayObject. On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set color(value:uint):void { iconColor = value; invalidateDisplayList(); } 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.beginFill(iconColor, 1); graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); graphics.endFill(); } } } I can place this icon in a Panel like this: mx:Panel id=myPanel titleIcon={Icon} ... So far so good -- the red square is drawn in the top left corner of the title area and it appears that I can call the color setter function like this: myPanel.titleIcon.color = 0x00FF00; But when I do this the icon color never changes. It appears that the calling invalidateDisplayList() never results in a call to updateDisplayList(). Any ideas? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com flexcoders%40yahoogroups.com, Paul J DeCoursey paul@ wrote: I've been able to get it to work for buttons and the like by extending ProgrammaticSkin and passing in the class. I've never even used the icon on a TitleWindow to even know how it's supposed to work. It should work, because everything is a class, but it might not know what to do with it. Paul Michael Schmalle wrote: Hi, The simple answer is no. Why? The titleIcon class is of type Class. This class cannot be subclassed. My advice to you is create a subclass of TitleWindow and create the method you are talking about there. Since you cannot load icons at runtime, you could create a simple iconLibraryModule that held your extra icons and then the method you created in the subclass would then load the icons from the icon library on demand through some type of string call into the library. Conclusion, there is no way to create an image like component in components with properties of type Class. In my custom window, I wrap the icon in a UIComponent, this way when I am rendering the icon, I have 2 options. The icon property is the 'source' but not the actual instance that is manipulated in the component UI. Peace, Mike
[flexcoders] Re: Programatic Icon
I got a different error this time: TypeError: Error #1034: Type Coercion failed: cannot convert components::[EMAIL PROTECTED] to Namespace. Are you sure it's not Friday the 13th? Paul --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: HAHA, Man, it must be Friday. Ok, the problem is this; titleIcon is the setter for the reference to the class that is creating the icon. You need the actual reference to the icon instance. try this; import mx.core.mx_internal; use namespace mx_internal; myPanel::mx_internal.titleIconObject.color = 0x00FF00; BTW we all know mx_internal is not supported but it will get you what you want. :) Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Unfortunately that did not work. It looks like the setter is not really being called after all. When I do this: myPanel.titleIcon.color = 0x00FF00; What seems to be happening is that it is creating a property called color just as if myPanel.titleIcon was a generic Object. I tried creating a doIconColor function (rather than using a setter) in Icon and calling it like this: Icon(myPanel.titleIcon).doIconColor(0xFF00FF); But this results in an TypeError: TypeError: Error #1034: Type Coercion failed: cannot convert components::Icon$ to components.Icon. I can't simply do this: myPanel.titleIcon.doIconColor(0xFF00FF); because I get a compile error (call to a possibly undefined method doIconColor) So the question now becomes, how do I call a function of my Icon class? Thanks for any suggestions! Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Ah, I know why you are not seeing updateDisplayList() called. Since this is ProgrammaticSkin, if the size doesn't change, the method will skip. The layoutManager calls setActualSize() and in that call if height or width did not change, you won't get the call. I had this same problem. In your color property, call validateDisplayList(); that will do the trick. Peace, Mike On 4/27/07, Michael Schmalle teoti.graphix@ wrote: Hi, For one I see you are missing; graphics.clear(); Try that, I don't think you are erasing the old color. Peace, Mike PS hehe I was thinking about something else when I responded and forgot the internal icon is typed IFlexDisplayObject. On 4/27/07, Paul Whitelock news@ wrote: Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set color(value:uint):void { iconColor = value; invalidateDisplayList(); } 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.beginFill(iconColor, 1); graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); graphics.endFill(); } } } I can place this icon in a Panel like this: mx:Panel id=myPanel titleIcon={Icon} ... So far so good -- the red square is drawn in the top left corner of the title area and it appears that I can call the color setter function like this: myPanel.titleIcon.color = 0x00FF00; But when I do this the icon color never changes. It appears that the calling invalidateDisplayList() never results in a call to updateDisplayList(). Any ideas? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com flexcoders%40yahoogroups.com, Paul J DeCoursey paul@ wrote: I've been able to get it to work for buttons and the like by extending ProgrammaticSkin and passing in the class. I've never even used the icon on a TitleWindow to even know how it's supposed to work. It should work, because everything is a class, but it might not know what to do with it. Paul Michael Schmalle wrote: Hi, The simple answer is no. Why? The titleIcon class is of type Class. This class cannot be subclassed. My advice to you is create a subclass of TitleWindow and create the method you are talking about there. Since you cannot load icons at runtime, you could create a simple iconLibraryModule
[flexcoders] Re: Programatic Icon
Sorry, that error should be: TypeError: Error #1034: Type Coercion failed: cannot convert mx.containers::[EMAIL PROTECTED] to Namespace. My copying and pasting got a little mixed up there :-) Paul --- In flexcoders@yahoogroups.com, Paul Whitelock [EMAIL PROTECTED] wrote: I got a different error this time: TypeError: Error #1034: Type Coercion failed: cannot convert components::[EMAIL PROTECTED] to Namespace. Are you sure it's not Friday the 13th? Paul --- In flexcoders@yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: HAHA, Man, it must be Friday. Ok, the problem is this; titleIcon is the setter for the reference to the class that is creating the icon. You need the actual reference to the icon instance. try this; import mx.core.mx_internal; use namespace mx_internal; myPanel::mx_internal.titleIconObject.color = 0x00FF00; BTW we all know mx_internal is not supported but it will get you what you want. :) Peace, Mike On 4/27/07, Paul Whitelock news@ wrote: Unfortunately that did not work. It looks like the setter is not really being called after all. When I do this: myPanel.titleIcon.color = 0x00FF00; What seems to be happening is that it is creating a property called color just as if myPanel.titleIcon was a generic Object. I tried creating a doIconColor function (rather than using a setter) in Icon and calling it like this: Icon(myPanel.titleIcon).doIconColor(0xFF00FF); But this results in an TypeError: TypeError: Error #1034: Type Coercion failed: cannot convert components::Icon$ to components.Icon. I can't simply do this: myPanel.titleIcon.doIconColor(0xFF00FF); because I get a compile error (call to a possibly undefined method doIconColor) So the question now becomes, how do I call a function of my Icon class? Thanks for any suggestions! Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Ah, I know why you are not seeing updateDisplayList() called. Since this is ProgrammaticSkin, if the size doesn't change, the method will skip. The layoutManager calls setActualSize() and in that call if height or width did not change, you won't get the call. I had this same problem. In your color property, call validateDisplayList(); that will do the trick. Peace, Mike On 4/27/07, Michael Schmalle teoti.graphix@ wrote: Hi, For one I see you are missing; graphics.clear(); Try that, I don't think you are erasing the old color. Peace, Mike PS hehe I was thinking about something else when I responded and forgot the internal icon is typed IFlexDisplayObject. On 4/27/07, Paul Whitelock news@ wrote: Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set color(value:uint):void { iconColor = value; invalidateDisplayList(); } 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.beginFill(iconColor, 1); graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); graphics.endFill(); } } } I can place this icon in a Panel like this: mx:Panel id=myPanel titleIcon={Icon} ... So far so good -- the red square is drawn in the top left corner of the title area and it appears that I can call the color setter function like this: myPanel.titleIcon.color = 0x00FF00; But when I do this the icon color never changes. It appears that the calling invalidateDisplayList() never results in a call to updateDisplayList(). Any ideas? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com flexcoders%40yahoogroups.com, Paul J DeCoursey paul@ wrote: I've been able to get it to work for buttons and the like by extending ProgrammaticSkin and passing in the class. I've never even used the icon on a TitleWindow to even know how it's supposed to work. It should work, because everything is a class, but it might not know what to do with it.
Re: [flexcoders] Re: Programatic Icon
ok, I have wasted enough time here, listening to music, I will go make it work. Will post the class. :) Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: I got a different error this time: TypeError: Error #1034: Type Coercion failed: cannot convert components::[EMAIL PROTECTED] to Namespace. Are you sure it's not Friday the 13th? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: HAHA, Man, it must be Friday. Ok, the problem is this; titleIcon is the setter for the reference to the class that is creating the icon. You need the actual reference to the icon instance. try this; import mx.core.mx_internal; use namespace mx_internal; myPanel::mx_internal.titleIconObject.color = 0x00FF00; BTW we all know mx_internal is not supported but it will get you what you want. :) Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Unfortunately that did not work. It looks like the setter is not really being called after all. When I do this: myPanel.titleIcon.color = 0x00FF00; What seems to be happening is that it is creating a property called color just as if myPanel.titleIcon was a generic Object. I tried creating a doIconColor function (rather than using a setter) in Icon and calling it like this: Icon(myPanel.titleIcon).doIconColor(0xFF00FF); But this results in an TypeError: TypeError: Error #1034: Type Coercion failed: cannot convert components::Icon$ to components.Icon. I can't simply do this: myPanel.titleIcon.doIconColor(0xFF00FF); because I get a compile error (call to a possibly undefined method doIconColor) So the question now becomes, how do I call a function of my Icon class? Thanks for any suggestions! Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.comflexcoders%40yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Ah, I know why you are not seeing updateDisplayList() called. Since this is ProgrammaticSkin, if the size doesn't change, the method will skip. The layoutManager calls setActualSize() and in that call if height or width did not change, you won't get the call. I had this same problem. In your color property, call validateDisplayList(); that will do the trick. Peace, Mike On 4/27/07, Michael Schmalle teoti.graphix@ wrote: Hi, For one I see you are missing; graphics.clear(); Try that, I don't think you are erasing the old color. Peace, Mike PS hehe I was thinking about something else when I responded and forgot the internal icon is typed IFlexDisplayObject. On 4/27/07, Paul Whitelock news@ wrote: Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set color(value:uint):void { iconColor = value; invalidateDisplayList(); } 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.beginFill(iconColor, 1); graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); graphics.endFill(); } } } I can place this icon in a Panel like this: mx:Panel id=myPanel titleIcon={Icon} ... So far so good -- the red square is drawn in the top left corner of the title area and it appears that I can call the color setter function like this: myPanel.titleIcon.color = 0x00FF00; But when I do this the icon color never changes. It appears that the calling invalidateDisplayList() never results in a call to updateDisplayList(). Any ideas? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.comflexcoders%40yahoogroups.com flexcoders%40yahoogroups.com, Paul J DeCoursey paul@ wrote: I've been able to get it to work for buttons and the like by extending ProgrammaticSkin and passing in the class. I've never even used the icon on a TitleWindow to even know how it's supposed to work. It should work, because everything is a class, but it might not know what to do with it. Paul Michael Schmalle wrote: Hi, The simple answer is no. Why? The titleIcon class is of type Class. This class cannot be
Re: [flexcoders] Re: Programatic Icon
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 = 0xFF; 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 On 4/27/07, Michael Schmalle [EMAIL PROTECTED] wrote: ok, I have wasted enough time here, listening to music, I will go make it work. Will post the class. :) Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: I got a different error this time: TypeError: Error #1034: Type Coercion failed: cannot convert components::[EMAIL PROTECTED] to Namespace. Are you sure it's not Friday the 13th? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: HAHA, Man, it must be Friday. Ok, the problem is this; titleIcon is the setter for the reference to the class that is creating the icon. You need the actual reference to the icon instance. try this; import mx.core.mx_internal; use namespace mx_internal; myPanel::mx_internal.titleIconObject.color = 0x00FF00; BTW we all know mx_internal is not supported but it will get you what you want. :) Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: Unfortunately that did not work. It looks like the setter is not really being called after all. When I do this: myPanel.titleIcon.color = 0x00FF00; What seems to be happening is that it is creating a property called color just as if myPanel.titleIcon was a generic Object. I tried creating a doIconColor function (rather than using a setter) in Icon and calling it like this: Icon(myPanel.titleIcon).doIconColor(0xFF00FF); But this results in an TypeError: TypeError: Error #1034: Type Coercion failed: cannot convert components::Icon$ to components.Icon. I can't simply do this: myPanel.titleIcon.doIconColor(0xFF00FF); because I get a compile error (call to a possibly undefined method doIconColor) So the question now becomes, how do I call a function of my Icon class? Thanks for any suggestions! Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.comflexcoders%40yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Ah, I know why you are not seeing updateDisplayList() called. Since this is ProgrammaticSkin, if the size doesn't change, the method will skip. The layoutManager calls setActualSize() and in that call if height or width did not change, you won't get the call. I had this same problem. In your color property, call validateDisplayList(); that will do the trick. Peace, Mike On 4/27/07, Michael Schmalle teoti.graphix@ wrote: Hi, For one I see you are missing; graphics.clear(); Try that, I don't think you are erasing the old color. Peace, Mike PS hehe I was thinking about something else when I responded and forgot the internal icon is typed IFlexDisplayObject. On 4/27/07, Paul Whitelock news@ wrote: Well here's the deal. I've created an simple icon class that draws a red square like this: package components { import mx.skins.ProgrammaticSkin; public class Icon extends ProgrammaticSkin { private var iconColor:uint = 0xFF; public function Icon() { super(); } public function set
Re: [flexcoders] Re: Programatic Icon
Maybe I should be listening to whatever music you're listening to You have Chemical Brothers :) haha No, my problem is I try to do 20 things at once. I just needed to focus on what you were witting and I could have had it solved 3 hours ago :) mx_internal is the namespace Adobe engineers use as a purgatory. Some properties there might go to heaven and some might go to hell. :) That is why I would wrap calls to anything that is in the mx_internal namespace in your own property or method. But, if it is minor stuff, you should be somewhat safe. Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: It works perfectly now! Maybe I should be listening to whatever music you're listening to :-) I guess I'm going to have to do some studying on mx_internal as I haven't explored that yet. Thank you very much! Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] 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 = 0xFF; 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 On 4/27/07, Michael Schmalle [EMAIL PROTECTED] wrote: ok, I have wasted enough time here, listening to music, I will go make it work. Will post the class. :) Peace, Mike On 4/27/07, Paul Whitelock [EMAIL PROTECTED] wrote: I got a different error this time: TypeError: Error #1034: Type Coercion failed: cannot convert components::[EMAIL PROTECTED] to Namespace. Are you sure it's not Friday the 13th? Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.comflexcoders%40yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: HAHA, Man, it must be Friday. Ok, the problem is this; titleIcon is the setter for the reference to the class that is creating the icon. You need the actual reference to the icon instance. try this; import mx.core.mx_internal; use namespace mx_internal; myPanel::mx_internal.titleIconObject.color = 0x00FF00; BTW we all know mx_internal is not supported but it will get you what you want. :) Peace, Mike On 4/27/07, Paul Whitelock news@ wrote: Unfortunately that did not work. It looks like the setter is not really being called after all. When I do this: myPanel.titleIcon.color = 0x00FF00; What seems to be happening is that it is creating a property called color just as if myPanel.titleIcon was a generic Object. I tried creating a doIconColor function (rather than using a setter) in Icon and calling it like this: Icon(myPanel.titleIcon).doIconColor(0xFF00FF); But this results in an TypeError: TypeError: Error #1034: Type Coercion failed: cannot convert components::Icon$ to components.Icon. I can't simply do this: myPanel.titleIcon.doIconColor(0xFF00FF); because I get a compile error (call to a possibly undefined method doIconColor) So the question now becomes, how do I call a function of my Icon class? Thanks for any suggestions! Paul --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com flexcoders%40yahoogroups.comflexcoders%40yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Ah, I know why you are not seeing updateDisplayList() called. Since this is ProgrammaticSkin, if the size doesn't change, the method will skip. The layoutManager calls setActualSize() and in that call if height or width did not change, you won't get the call. I had this same
[flexcoders] Re: Programatic Icon
Ahhh, the Chemical Brothers -- I haven't heard them in a while. Maybe I should dig them out of my collection :-) Thanks for the colorful description of mx_internal. I also just found a good description here: http://tinyurl.com/3y62jd However, yours is more fun :-) Thanks again for the help. Paul --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Maybe I should be listening to whatever music you're listening to You have Chemical Brothers :) haha No, my problem is I try to do 20 things at once. I just needed to focus on what you were witting and I could have had it solved 3 hours ago :) mx_internal is the namespace Adobe engineers use as a purgatory. Some properties there might go to heaven and some might go to hell. :) That is why I would wrap calls to anything that is in the mx_internal namespace in your own property or method. But, if it is minor stuff, you should be somewhat safe. Peace, Mike
Re: [flexcoders] Re: Programatic Icon
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, 0xff); } 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 = 0xFF; 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