Hi, Johannes,

proceed to check if individual aspects of that style exists:

Using the default factory, styles will never exist before, this is a catch
22 where your are implying a TypeSelector default.

So this,

(!classStyle.getStyle("playButtonStyle")

will never happen because where I use this is class initialization and that
only happens once.

Peace, Mike

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

  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




--
Teoti Graphix
http://www.teotigraphix.com

Blog - Flex2Components
http://www.flex2components.com

You can find more by solving the problem then by 'asking the question'.

Reply via email to