There is an example in the doc explaining this process:
http://livedocs.adobe.com/flex/3/html/skinstyle_3.html
 
Stephen

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: Thursday, March 13, 2008 10:47 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Custom component with custom style - help
please



I assume you removed the getter/setters?

Try:

.wax {
waxColor: #F0F0F0;
}



________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of dbronk
Sent: Thursday, March 13, 2008 7:24 PM
To: flexcoders@yahoogroups.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

 

Reply via email to