<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:popup="com.adobe.cairngorm.popup.*"
layout="vertical"
minWidth="1024" minHeight="768"
xmlns:commands="samples.commands.*"
addedToStage="buildContext()">
<mx:Script>
<![CDATA[
import com.adobe.cairngorm.popup.PopUpEvent;
import samples.commands.ParentContext;
import org.spicefactory.parsley.flex.FlexContextBuilder;
import org.spicefactory.parsley.core.context.Context;
[Inject]
public var context:Context;
private function buildContext():void
{
FlexContextBuilder.build(ParentContext, this);
dispatchEvent(new Event('configureIOC', true));
}
private function openingHandler(event:PopUpEvent):void
{
context.viewManager.addViewRoot(DisplayObject(event.popup))
}
private function closingHandler(event:PopUpEvent):void
{
context.viewManager.removeViewRoot(DisplayObject(event.popup))
}
]]>
</mx:Script>
<mx:Button label="Open popup 1" click="popup1.open = true" />
<mx:Button label="Open popup 2" click="popup2.open = true" />
<popup:PopUpWrapper id="popup1"
opening="openingHandler(event)"
closing="closingHandler(event)">
<commands:MyPopup/>
</popup:PopUpWrapper>
<popup:PopUpWrapper id="popup2"
opening="openingHandler(event)"
closing="closingHandler(event)">
<commands:MyPopup/>
</popup:PopUpWrapper>
</mx:Application>