styleChaned is only when someone calls setStyle after the component is initialized. It would be poor performance to call it for 100 styles you inherit at init time so we don't.
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of dbronk Sent: Friday, March 14, 2008 7:14 AM To: [email protected] Subject: [flexcoders] Re: Custom component with custom style - help please I actually did have waxColor: #F0F0F0, simply a typo when posting to the forum. I did remove the getters/setters and it still did not work. I started looking at different things and found out that setStyle and styleChanged are simply not called when styles are set via a css. I think this is very bad, but I was able to work with it. This did tell me that the styles were actually being set, but since I had code in the styleChanged to set a boolean, I now simply do the check in updateDisplayList which actually is a bit easier to follow code. I still believe that styleChanged should be called no matter how the style is changed. Thanks for you help. It didn't answer my question, but it led me to look in the right place which is better because I learned something else. Dale --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <[EMAIL PROTECTED]> wrote: > > I assume you removed the getter/setters? > > > > Try: > > > > .wax { > waxColor: #F0F0F0; > } > > > > ________________________________ > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of dbronk > Sent: Thursday, March 13, 2008 7:24 PM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Custom component with custom style - help please > > > > I've made a custom component and on it I want to place a custom style > named "waxColor". I started by simply creating getter/setters for > waxColor. Worked great when I include waxColor="#F0F0F0" to the mxml, > but I want this to be property driven. So I added > > [Style(name="waxColor", format="Color", type="unit", inherit="no")] > > to my as file. I then coded: > > override public function setStyle(styleProp:String, newValue:*) : void > > override public function styleChanged(styleProp:String) : void > > override protected function updateDisplayList(unscaledWidth:Number, > unscaledHeight:Number) : void > > to do what I needed. In my component that instantiates my custom > component I do myComp.setStyle("waxColor", 0xF0F0F0) and it works great. > > But, the entire reason that I've added this as a style was that I > wanted to control the color via a style sheet. So in my css file I added > > .wax { > waxColor: 0xF0F0F0; > } > > and removed the setStyle code. Now my mxml does not have > waxColor="#F0F0F0" and instead has styleName="wax". This does not > work. I have trace statements in all of my overridden functions and > while styleChanged gets triggered, never with styleProp of "waxColor". > setStyle is never called. > > What am I doing wrong? I really want waxColor to be able to be set > via my css file. > > Thanks, > Dale >

