Created
November 13, 2010 00:28
-
-
Save andrerocker/674956 to your computer and use it in GitHub Desktop.
Flex: Carga de modulo dinamica em Action Script 3
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
[Bindable] | |
protected var moduleInfo: IModuleInfo; | |
protected function menuClick(event:MenuEvent):void | |
{ | |
var className:String = event.item.@data; | |
var executa:Function = function():void | |
{ | |
var definition:Class = Class(getDefinitionByName(className)); | |
var instance:MDIWindow = new definition(); | |
parentDocument.mdiCanvas.windowManager.add(instance); | |
}; | |
getDefinitionByNameWrapper(executa); | |
} | |
private function getDefinitionByNameWrapper(callback:Function):void | |
{ | |
try { | |
callback.call(); | |
} | |
catch(e:Error){ | |
tryLoadModule(callback); | |
} | |
} | |
private function tryLoadModule(callback:Function):void | |
{ | |
var postLoad:Function = function(e:Event):void { callback.call(); }; | |
moduleInfo = ModuleManager.getModule("modules/xpto.swf"); | |
moduleInfo.addEventListener(ModuleEvent.READY, postLoad); | |
moduleInfo.addEventListener(ModuleEvent.ERROR, moduleError); | |
moduleInfo.load(ApplicationDomain.currentDomain, null, null, moduleFactory); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment