Apr 28 2010

Using new StyleManager in Flex 4

Published by at 2:32 pm under Flex

With Flex 4 the StyleManager is no longer a Singleton class. Its implementation has changed so that every loaded module has its own instance of StyleManager.

This post by Gaurav Jain explains how you can use it so that the loaded modules have their own separate style manager.

But it doesn’t say how you can access the toplevel or default StyleManager.

The old, Flex 3, way of accessing it would be,

var tempStyle:CSSStyleDeclaration = StyleManager.getStyleDeclaration(“.tempStyle”);

the above method is deprecated and will give you a warning.

The correct way now of using the StyleManager would be the following,

var tempStyle:CSSStyleDeclaration = StyleManager.getStyleManager(null).getStyleDeclaration(“.tempStyle”);

StyleManager.getStyleManager(null);, returns the top level instance of StyleManager.

5 responses so far

5 Responses to “Using new StyleManager in Flex 4”

  1. Althafon 08 Mar 2011 at 12:14 pm

    Thanks.

  2. Peteron 09 Jun 2011 at 2:54 am

    Or FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration(“someStyle”);

  3. Nayanon 07 Apr 2014 at 2:45 pm

    Sure i don’t mind it.

  4. And what’s more unimaginable is that you don’t must be a tech savvy to
    use this hack.

  5. gratis v bucks generatoron 22 Nov 2022 at 10:32 pm

    gratis v bucks generator

    Blog for Nayan » Using new StyleManager in Flex 4

Trackback URI | Comments RSS

Leave a Reply