Modules and Singleton Manager

This isn’t out there enough, so I’m writing it down. Any singleton based manager, such as PopUpManager or DragManager must be initialized in the parent application before use in the module. This is so that the parent application becomes the first to register the manager as a singleton (first in wins) permitting, therefore, the manager to be shared across modules. The easiest workaround is to simply add an import of the manager you’re using and a dummy variable to the main Application class.

import mx.managers.PopUpManager;
public var pum:PopUpManager;

For reference, here’s the error I was getting…

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:433]
at mx.managers::PopUpManager$/addPopUp()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\PopUpManager.as:193]

PS: I noticed the effects of this mostly on Window7 using Internet Explorer. My typical development browser, Opera, was much more forgiving in regular mode although the debugger would blow up. Not sure if that has to do with different Flash plugins or not, but I suspect so.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s