Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f8f45b99a6
Fetching contributors…

Cannot retrieve contributors at this time

110 lines (95 sloc) 3.936 kb
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:modulardoodads="robotlegs.examples.modulardoodads.*"
xmlns:logger="robotlegs.examples.modulardoodads.modules.logger.*"
width="450" height="700" xmlns:doodad="robotlegs.examples.modulardoodads.modules.doodad.*" xmlns:view="robotlegs.examples.modulardoodads.view.*">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.IVisualElement;
import mx.events.ModuleEvent;
import mx.modules.IModuleInfo;
import mx.modules.ModuleManager;
import robotlegs.examples.modulardoodads.common.events.LoggingEvent;
import robotlegs.examples.modulardoodads.common.events.ModuleCommandTriggerEvent;
// This is only a linkage so the LoggingEvent class gets compiled into the main swf.
// If this isn't linked into the main swf an error will be thrown.
protected var loggingEventLinkage:LoggingEvent;
protected var info:IModuleInfo;
protected function addDoodad_clickHandler(event:MouseEvent):void
{
if (createModuleInfo())
{
info.load(ApplicationDomain.currentDomain, null, null, moduleFactory);
}
}
protected function createModuleInfo():Boolean
{
if (!info)
{
info = ModuleManager.getModule('robotlegs/examples/modulardoodads/modules/doodad/DoodadModule.swf');
info.addEventListener(ModuleEvent.READY, moduleInfo_readyHandler);
info.addEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler);
return true;
}
return false;
}
protected function destroyModuleInfo():void
{
if (info)
{
info.removeEventListener(ModuleEvent.READY, moduleInfo_readyHandler);
info.removeEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler);
info = null;
}
}
protected function moduleInfo_readyHandler(event:ModuleEvent):void
{
doodadHolder.addElement(info.factory.create() as IVisualElement);
destroyModuleInfo();
}
protected function moduleInfo_errorHandler(event:ModuleEvent):void
{
Alert.show(event.errorText);
destroyModuleInfo();
}
public function setFocusOnAddDoodadButton():void
{
focusManager.setFocus(addDoodad);
}
protected function triggerCommand_clickHandler(event:MouseEvent):void
{
dispatchEvent(new ModuleCommandTriggerEvent(ModuleCommandTriggerEvent.TRIGGER_MODULE_COMMAND));
}
]]>
</fx:Script>
<fx:Declarations>
<modulardoodads:ModularDoodadsContext contextView="{this}"/>
</fx:Declarations>
<s:layout>
<s:VerticalLayout paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5"/>
</s:layout>
<s:HGroup width="100%">
<s:Button id="addDoodad" label="Add a Doodad" click="addDoodad_clickHandler(event)"/>
<s:Button id="triggerCommand" label="Trigger" click="triggerCommand_clickHandler(event)"/>
</s:HGroup>
<s:Scroller width="440" height="100%" horizontalScrollPolicy="off">
<s:Group height="100%" width="440">
<s:Group id="doodadHolder" width="440">
<s:layout>
<s:TileLayout />
</s:layout>
</s:Group>
<s:Rect width="100%" height="100%">
<s:stroke>
<s:SolidColorStroke color="#C7C7C7"/>
</s:stroke>
</s:Rect>
</s:Group>
</s:Scroller>
<mx:ModuleLoader url="robotlegs/examples/modulardoodads/modules/logger/LoggerModule.swf"
applicationDomain="{ApplicationDomain.currentDomain}" width="100%"
error="Alert.show(event.errorText)"/>
</s:Application>
Jump to Line
Something went wrong with that request. Please try again.