views:

1115

answers:

2

I'm trying to compile existing Flex 4 project but having an error:

Call to underfined method getStyleManager of StyleManager class.

The code is:

var styleManager:IStyleManager2 = StyleManager.getStyleManager(null);

I found the method in Flex documentation but when I open StyleManager.as I can't find the method declaration.

Used Flex SDK 4.0.0.10485 from here.

A: 

Try upgrading your version of Flex, is that possible? It's working for me, I do this:

import mx.managers.SystemManagerGlobals;

public static function getStyleManager():IStyleManager2
{
    return mx.styles.StyleManager.getStyleManager(SystemManagerGlobals.topLevelSystemManagers[0]);
}

I'm using Flex 13645.

It also depends on when you're calling StyleManager possibly: if you're calling that method in a Preloader, that could be a problem.

viatropos
A: 

Each app has its own StyleManager in Flex 4. You access it with the styleManager property (note the lowercase "s"), whereas before you used the static class StyleManager to get an instance.

Here's a page that describes how to use the StyleManager class: http://help.adobe.com/en_US/Flex/4.0/UsingSDK/WS2db454920e96a9e51e63e3d11c0bf69084-7f7c.html

hth, matt horn flex docs

matt horn