hi Muzak

I proceed to check if individual aspects of that style exists:


                   if(!classStyle.getStyle("playButtonStyle"))
                   {
                       classStyle.setStyle
("playButtonStyle",createDefaultButtonStyle());
                   }
where classStyle is the one you are already checking.

j


On 6/13/07, Muzak <[EMAIL PROTECTED]> wrote:

  I just ran into the following issue and was wondering how others solve
this.

When creating a component and setting default styles, you use a static
method and check for the existance of a StyleDeclaration.

private static function initStyles():Boolean {
var css:CSSStyleDeclaration = StyleManager.getStyleDeclaration
("MyComponent");
if (!css) {
css = new CSSStyleDeclaration();
css.setStyle("tileColors", [0x000000, 0xFFFFFF]);
StyleManager.setStyleDeclaration("StyleComponent", css, false);
}
return true;
}

This works fine as long as there is no CSS style defined in MXML

Let's say I have the following mxml:

<mx:Style>
StyleComponent {
}
</mx:Style>

<controls:StyleComponent id="_comp" />

As you can see, there is a style for the component defined in CSS, but no
styles are defined.
So because a CSSStyleDeclaration will be defined when the static
initStyles method is invoked, default styles (tileColors) will not
be set, in other words, it never reaches past the if(!css) part.

So how and, more important, where (in which method) does one check if
styles have actually been defined and if no default values
exist, set them.

regards,
Muzak




--
j:pn
http://www.lennel.org

Reply via email to