You can alter CSSStyleDeclarations by calling setStyle on them at
runtime.

 

________________________________

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Jason Yarrington
Sent: Monday, December 04, 2006 12:23 PM
To: [email protected]
Subject: Re: [flexcomponents] Re: adding a CSS programmatically in ".as"
file ?

 

This all still sets the CSS at compile time, doesn't it?  Is there
anyway to set the CSS style at run time?  Thus allowing components to be
styled differently in response to events?

Jason

On 12/4/06, Bruce Denham <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

Or you can go the extra mile and use CSSStyleDeclaration class along 
with the StyleManager to create styles in actionscript and then 
reference those styles from other actionscript files or mxml using 
the styleName property, something like:

MXML file: 
<MyComponent styleName="myTitleStyle"/>

Actionscript file:
var myTitleStyle:CSSStyleDeclaration = new CSSStyleDeclaration
("myTitleStyle"); 
myTitleStyle.setStyle('fontFamily', 'Tahoma'); 
myTitleStyle.setStyle('fontWeight', "bold");
myTitleStyle.setStyle('fontSize', 18);
myTitleStyle.setStyle('color', 0x333333);
StyleManager.setStyleDeclaration
(".myTitleStyle",myTitleStyle,true); 

Bruce

--- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> , "Andrew Trice" 
<[EMAIL PROTECTED]> wrote:
>
> In actionscript you can also use the setStyle method to 
programmatically
> set any of the styles for that element.
> 
> 
> 
> myTextBox.setStyle("color", 0xFF0000);
> 
> 
> 
> 
> 
> -Andy
> 
> 
> 
> _____________________________________
> 
> Andrew Trice
> 
> Cynergy Systems, Inc.
> 
> http://www.cynergysystems.com <http://www.cynergysystems.com> 
> 
> 
> 
> Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
<http://www.cynergysystems.com/blogs/page/andrewtrice> 
> 
> Email: [EMAIL PROTECTED]
> 
> Office: 866-CYNERGY 
> 
> 
> 
> ________________________________
> 
> From: [email protected]
<mailto:flexcomponents%40yahoogroups.com> 
> [mailto:[email protected]
<mailto:flexcomponents%40yahoogroups.com> ] On Behalf Of amey admulwar
> Sent: Monday, December 04, 2006 4:29 AM
> To: [email protected]
<mailto:flexcomponents%40yahoogroups.com> 
> Subject: Re: [flexcomponents] adding a CSS programmatically in ".as"
> file ?
> 
> 
> 
> Hi Arpan
> 
> You can do this in .as file by just creating CSS classes in action
> script. by contol name
> 
> Text
> {
> color : #ffffff;
> ...
> };
> 
> or
> .class_name
> {
> color : #ffffff;
> ...
> }
> 
> and just set style Name attribut in resp. control 
styleName="class_name"
> it will work just same as <mx:Script> tag
> 
> Amey.
> 
> 
> 
> 
> Amey.
> 
> arpan srivastava <[EMAIL PROTECTED]> wrote:
> 
> Hi,
> Is there anyway we can add CSS programmatically in ".as"
> file rather than adding in the mxml file with <mx:style /> tag.
> 
> 
> 
> 
> ________________________________
> 
> 
> Access over 1 million songs - Yahoo! Music Unlimited.
> 
<http://pa.yahoo.com/*http:/us.rd.yahoo.com/evt=36035/*http:/music.yah
<http://pa.yahoo.com/*http:/us.rd.yahoo.com/evt=36035/*http:/music.yah> 
oo
> .com/unlimited/> 
> 
> 
> 
> 
> 
> ________________________________
> 
> Everyone is raving about the all-new Yahoo! Mail beta.
> 
<http://us.rd.yahoo.com/evt=45083/*http:/advision.webevents.yahoo.com/
<http://us.rd.yahoo.com/evt=45083/*http:/advision.webevents.yahoo.com/> 
ma
> ilbeta>
>

 

 

Reply via email to