Created
September 8, 2012 14:49
-
-
Save alebianco/3675603 to your computer and use it in GitHub Desktop.
Robotlegs & Flex: automediate popups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.DisplayObject; | |
import flash.display.DisplayObjectContainer; | |
import mx.core.IUIComponent; | |
import mx.managers.ISystemManager; | |
import robotlegs.bender.extensions.mediatorMap.api.IMediatorMap; | |
import robotlegs.bender.extensions.viewManager.api.IViewManager; | |
public class MyDirtyConfig | |
{ | |
[Inject] | |
public var contextView:DisplayObjectContainer; | |
[Inject] | |
public var mediatorMap:IMediatorMap; | |
[Inject] | |
public var viewManager:IViewManager; | |
private function getTopLevelSystemManager(parent:DisplayObject):ISystemManager | |
{ | |
var sm:ISystemManager; | |
var localRoot:DisplayObjectContainer = DisplayObjectContainer(IUIComponent(parent).systemManager); | |
if (localRoot is ISystemManager) | |
{ | |
sm = ISystemManager(localRoot); | |
if (!sm.isTopLevel()) | |
sm = sm.topLevelSystemManager; | |
} | |
return sm; | |
} | |
[PostConstruct] | |
public function setup():void | |
{ | |
var sm:ISystemManager = getTopLevelSystemManager(contextView); | |
viewManager.removeContainer(contextView); | |
viewManager.addContainer(sm as DisplayObjectContainer); | |
// Now callouts and all kind of popups in general will be auto-mediated | |
mediatorMap.map(CustomCallout).toMediator(CalloutMediator); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment