Use loadStyleDeclarations(url, false);
Call registerColorName
Get the IStyleManager (how to do it depends on your version of Flex)
Call IStyleManager.styleDeclarationsChanged()


On 2/2/10 9:34 AM, "cyril ronseaux" <cyril.ronse...@gmail.com> wrote:






Hi,

background : we are trying to simplify maintenance of CSS stylesheets by 
declaring "theme colors" once, and using them everywhere else. We intend to 
read a specific style declaration (e.g. getStyleDeclaration("global", 
"maincolor") ), to then register color names for that color : 
StyleManager.registerColorName("maincolor", 
theColorWeJustReadFromGlobalDeclaration), and use that just-registered 
colorname everywhere we need that color in our CSS.

For now, i'm stuck with an issue : components that use styles that reference my 
custom color, do not pick the color until I RE-load the CSS.

I'm loading style dynamically :
StyleManager.loadStyleDeclarations(url, true); // a swf containing the CSS

On style complete :
StyleManager.registerColorName("mycolor", 0x00FF00);

In the CSS :
. test {
    color: prout;
}

Component :
<mx:Label text="hello, i'm testing custom colors" styleName="test" />

To make it works I had to add : StyleManager.loadStyleDeclarations(url, true);
a second tome after the registerColorName :

On style complete :
StyleManager.registerColorName("mycolor", 0x00FF00);
StyleManager.loadStyleDeclarations(url, true);


But I wish I could do it without having to reload the stylesheet.
I tried : this.styleChanged(null); // this is application
and
this.styleInitialized();


Any idea ?

Thanks in advance.
Cyril





--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to