Skip to main content
Participating Frequently
January 29, 2010
Answered

SystemManger registration problem with -isolate-styles=false

  • January 29, 2010
  • 1 reply
  • 1995 views

I am working on a modular application using a bunch of styles. I recently found that loading styles in the main application with isolate-styles set to true, would break the styleChain for the modules.

The workaround was to initiate an instance of StyleManager in the module, but that has now resulted in ActiveWindowManager not being registered with the system manager for the module, and as a result, PopupManager explodes on line 358:

var awm:IActiveWindowManager =

IActiveWindowManager(smp.getImplementation(

"mx.managers::IActiveWindowManager"));

if (window is IFocusManagerContainer)

{

if (IFocusManagerContainer(window).focusManager)

{

awm.

addFocusManager(IFocusManagerContainer(window));

}

because awm is null at this stage.

Does anyone have an idea for how to get this working? It seems the isolate-styles implementation is causing a world of pain in sdk 13099

Any takers?

This topic has been closed for replies.
Correct answer Darrell_Loverin

This seems to be correct - I've modified our ModuleFactory to set this as the moduleFactory when the module is created.

How do we ensure that all child components get the module factory set when the module is loaded?

Currently, our create method in our modulefactory looks like this:

override public function create( ... parameters ) : Object

{

var module : Object = super.create( parameters );

if ( module is IModule )

{

if ( parameters.length >= 1 && parameters[ 0 ] )

IModule( module ).properties = parameters[ 0 ];

if ( parameters.length >= 2 && parameters[ 1 ] )

IModule( module ).viewID = String( parameters[ 1 ] );

}

module.moduleFactory =

this;

return module;

}

but this only sets the module factory on the module itself. When I now try and instantiate an instance of flexSpy within the module, it still blows up with the missing styles.

E:)


The pattern is for a component to propagate its moduleFactory to its children. See UIComponent.moduleFactory and UIComponent.addingChild().

-Darrell

1 reply

Inspiring
January 29, 2010

The first thing I would try if awm is null is to define the PopUpManager class in the main application.

import mx.managers.PopUpManager; PopUpManager;

Can you add more information about what styles are not working in your modules and what you are expecting. It's not clear if you are having a problem when isolate-styles is true or false. The subject of the post says "false" and the body says "true".

You said your work around was to initiate an instance of StyleManager in the module. Only the compiler generated code should be creating style managers. The isolate-styles option controls the creation of a style manager for the application or module being compiled. Setting -isolate-styles to true creates a style manager for the application and setting isolate-styles to false does not (the application or module's style manager is used).

-Darrell

ESkogenAuthor
Participating Frequently
February 1, 2010

The problem occurs when isolate-styles = true.

In my app, this results in the module being able to pick up the styles from the main app stylesheets, but it loses the inherited styles from the framework, which causes all kinds of issues.

The popup manager problem I narrowed down to this:

The awm issue was due to the AWM being registered with Singleton, but not with systemManager, so a temporary workaround was to register the implementation with the systemmanager in the module itself,

(

ISystemManager(

this.root).registerImplementation( "mx.managers::IActiveWindowManager", ActiveWindowManager);

)

but this obviously is not very desirable, so I'd rather figure out why it breaks in the first place. It appears that by isolating the stylemanagers, in certain cases it causes the factory class delegation to fail entirely. I have a feeling the window manager issue is a bit of a red herring, and that if I solve the inheritedStyles issue, the rest will fall into place.

How does the style manager get a reference to the framework styles when instantiated by the module?

Inspiring
February 1, 2010

You should not have to call registerImplementation() from the module. This is done in SystemManager.kickOff(). Adding

import mx.managers.PopUpManager; PopUpManager;

to the main application should register the awm implementation for you.

How are you launching you modules? If you are not using ModuleLoader then make sure you are passing a moduleFactory to IModuleInfo.load().

In my app, this results in the module being able to pick up the styles from the main app stylesheets, but it loses the inherited styles from the framework

What inherited styles from the framework?

What are their values?

What did you expect their values to be?

What are their values when -isolate-styles=false?

>How does the style manager get a reference to the framework styles when instantiated by the module?

Some styles are set by compiler generated code and others are inherited from the module's parent style manager.

-Darrell