<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:example="example.*"
layout="vertical" width="100%" height="100%"
xmlns:spicefactory="http://www.spicefactory.org/parsley"
xmlns:cairngorm="com.adobe.cairngorm.*" xmlns:module="com.adobe.cairngorm.module.*">
<mx:Script>
<![CDATA[
import com.adobe.cairngorm.module.ModuleMessageInterceptor;
import com.adobe.cairngorm.module.ParsleyModuleDescriptor;
import example.api.BroadcastMessage;
import example.api.ClearLogMessage;
import example.api.PingMessage;
import example.api.PongMessage;
import mx.logging.LogEventLevel;
import mx.modules.IModuleInfo;
import org.spicefactory.lib.reflect.ClassInfo;
[Bindable]
[Inject(id="moduleA")]
public var moduleA:IModuleInfo;
[Bindable]
[Inject(id="moduleB")]
public var moduleB:IModuleInfo;
[Bindable]
[Inject(id="moduleC")]
public var moduleC:IModuleInfo;
[MessageDispatcher]
public var dispatcher:Function;
private var compile:Array = [PongMessage, ClearLogMessage, ClassInfo];
protected function dispatchPingMessage(moduleId:String=null):void
{
dispatcher( new PingMessage(moduleId) );
}
protected function dispatchBroadcastMessage():void
{
dispatcher( new BroadcastMessage() );
}
private var moduleCount:int = 5;
protected function button1_clickHandler(event:MouseEvent):void
{
var modulePod:ModulePod = new ModulePod();
modulePod.percentWidth=100;
modulePod.percentHeight=100;
modulePod.label=modulePod.moduleId="moduleA"+moduleCount++;
modulePod.moduleInfo=moduleA;
tabNav.addChild(modulePod);
}
]]>
</mx:Script>
<spicefactory:ContextBuilder>
<module:ModuleXMLSupport/>
<spicefactory:XmlConfig file="runtimeContext.xml" />
</spicefactory:ContextBuilder>
<spicefactory:Configure/>
<mx:TraceTarget level="{ LogEventLevel.DEBUG }" includeCategory="true">
<mx:filters>
<mx:Array>
<mx:String>com.adobe.cairngorm.*</mx:String>
<mx:String>org.spicefactory.*</mx:String>
</mx:Array>
</mx:filters>
</mx:TraceTarget>
<cairngorm:CairngormModuleLib />
<mx:HBox width="100%">
<mx:Button label="Ping moduleA" click="dispatchPingMessage('moduleA')" />
<mx:Button label="Ping moduleA2" click="dispatchPingMessage('moduleA2')" />
<mx:Button label="Ping moduleB" click="dispatchPingMessage('moduleB')" />
<mx:Button label="Pong ModuleC" click="dispatcher( new PongMessage() )" />
<mx:Button label="Ping all ModuleA" click="dispatchBroadcastMessage()" />
<mx:Spacer width="10" />
<mx:Button label="CLEAR ALL LOGS" click="dispatcher( new ClearLogMessage() )" />
<mx:Spacer width="100%" />
<mx:Button label="Add new instance of ModuleA" click="button1_clickHandler(event)" />
<mx:TextInput id="moduleIdInput" width="150" text="moduleA3"/>
<mx:Button label="Ping" click="dispatchPingMessage(moduleIdInput.text)" />
</mx:HBox>
<mx:HBox width="100%" height="100%">
<mx:VBox width="350" height="100%">
<example:ModulePod width="100%" height="25%" moduleId="moduleA" moduleInfo="{ moduleA }" label="moduleA" />
<example:ModulePod width="100%" height="25%" moduleId="moduleA2" moduleInfo="{ moduleA }" label="moduleA2" />
<example:ModulePod width="100%" height="25%" moduleId="moduleB" moduleInfo="{ moduleB }" label="moduleB" />
<mx:ViewStack width="100%" height="25%" id="moduleCStack">
<mx:Canvas width="100%" height="100%">
<mx:Button horizontalCenter="0" verticalCenter="0" label="Instantiate ModuleC"
click="moduleCStack.selectedIndex=1"/>
</mx:Canvas>
<example:ModulePod width="100%" height="100%" moduleInfo="{ moduleC }" label="moduleC" />
</mx:ViewStack>
</mx:VBox>
<mx:TabNavigator width="100%" height="400" id="tabNav">
<example:ModulePod width="100%" height="100%" moduleId="moduleA3" moduleInfo="{ moduleA }" label="moduleA3" />
<example:ModulePod width="100%" height="100%" moduleId="moduleA4" moduleInfo="{ moduleA }" label="moduleA4" />
</mx:TabNavigator>
</mx:HBox>
</mx:Application>