1 Reply Latest reply on Jun 10, 2011 11:12 PM by Flex harUI

    Flex 3 to Flex 4 migration, StyleManager woes.

    gags_78 Level 1

      hi Folks,

       

      I've a multi-module Flex 4 application. It's PureMVC modelled and during one of the startup commands it attempts to get a style. However, with Flex 4's new StyleManager per module approach, I can only get a reference to the topLevelApplication's styleManager which doesn't have the styles loaded that are loaded in the module.

       

      I've scoured the web for a solution to this but to no avail. In a number of places the suggestion is to get the module and from it get it's factory which will allow me to

       

      var info:IModuleInfo = ModuleManager.getModule("<filesystempath to module swf>");

       

      var sm:IStyleManager2 = StyleManager.getStyleManager(info.factory);

       

      which does indeed seem to give me back the correct style manager, however, it's got to be wrong because I can't be having to get the module and from it the StyleManager everytime I want to get a style for something in the code?

       

      I would have hoped there'd at the very least be a ModuleManager method which I could supply the simple name of the swf as opposed to having to cart around the absolute path?

       

      So my question is, from within code in a module, how does one get a handle to the Module specific StyleManager?

       

      Thanks for your time,

      Mark..

        • 1. Re: Flex 3 to Flex 4 migration, StyleManager woes.
          Flex harUI Adobe Employee

          Most of the code in a module can get a reference to a display object in the

          module, which will have the right moduleFactory in most cases.

           

          In the code you showed, that is the correct technique and is somewhat

          difficult, because you are breaking encapsulation by trying to dig into a

          module.

           

          You should be able to use relative paths as well as absolute paths to the

          module.