Skip to content

Instantly share code, notes, and snippets.

@alebianco
Created September 8, 2012 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alebianco/3675603 to your computer and use it in GitHub Desktop.
Save alebianco/3675603 to your computer and use it in GitHub Desktop.
Robotlegs & Flex: automediate popups
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