안녕하세요, 아주 간단한 mxml 예제입니다. 모듈이 원격 http://edofiles.s3.amazonaws.com/calculator.swf 준비 이벤트가 발생되지 않습니다플렉스로드 모듈 READY 이벤트가 시작되지 않았습니다. 이유가 무엇입니까?
같은 경우
플렉스 SDK 3.4.0와 플렉스 빌더를 사용하여, 나는 그 이유를 이해하지 않습니다.
동일한 문제가 발생합니까?
모든 단서가에서입니까?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
applicationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.modules.Module;
import mx.events.ModuleEvent;
import mx.modules.ModuleManager;
import mx.modules.IModuleInfo;
protected var _moduleInfo:IModuleInfo;
private function initApp():void {
addToLog ("Application initialised");
// create the module - note, we're not loading it yet
_moduleInfo = ModuleManager.getModule("http://edofiles.s3.amazonaws.com/calculator.swf");
// add some listeners
_moduleInfo.addEventListener(ModuleEvent.READY, onModuleReady);
_moduleInfo.addEventListener(ModuleEvent.SETUP, onModuleSetup);
_moduleInfo.addEventListener(ModuleEvent.UNLOAD, onModuleUnload);
_moduleInfo.addEventListener(ModuleEvent.PROGRESS, onModuleProgress);
}
protected function getModuleInfo() : IModuleInfo {
// return the module info
return _moduleInfo;
}
/**
* Adds output to the log
**/
protected function addToLog (msg:String) : void {
log.text += msg + "\n";
// scroll to the bottom on the next frame
callLater(scrollToBottom);
}
protected function scrollToBottom() : void {
// scroll to the bottom
log.verticalScrollPosition = log.maxVerticalScrollPosition;
}
/**
* Called when the "load" button is pressed
*
* Starts loading the module - when the module has been
* loaded, an instance of the module will be created
* and added to the tile control
*
**/
private function loadModule() : void {
addToLog ("Loading module");
// load the module
getModuleInfo().load();
}
/**
* Called when the "unload" button is pressed
*
* Removes all the instances of the module from the
* tile control, then unloads the module
*
*/
private function unloadModule() : void {
addToLog ("Unloading module");
// clear out all the the instances
// of the module from the tile
tile.removeAllChildren();
// unload the module
getModuleInfo().release();
//getModuleInfo().un
}
/**
* Handler for the ModuleEvent.PROGRESS event
**/
protected function onModuleProgress (e:ModuleEvent) : void {
addToLog ("ModuleEvent.PROGRESS received: " + e.bytesLoaded + " of " + e.bytesTotal + " loaded.");
}
/**
* Handler for the ModuleEvent.SETUP event
**/
private function onModuleSetup (e:ModuleEvent) : void {
addToLog ("ModuleEvent.SETUP received");
// cast the currentTarget
var moduleInfo:IModuleInfo = e.currentTarget as IModuleInfo;
addToLog ("Calling IModuleInfo.factory.info()");
// grab the info and display information about it
var info:Object = moduleInfo.factory.info();
for (var each:String in info) {
addToLog (" " + each + " = " + info[each]);
}
}
/**
* Handler for the ModuleEvent.READY event
**/
private function onModuleReady (e:ModuleEvent):void {
addToLog ("ModuleEvent.READY received");
// cast the currentTarget
var moduleInfo:IModuleInfo = e.currentTarget as IModuleInfo;
// Add an instance of the module's class to the
// display list.
addToLog ("Calling IModuleInfo.factory.create()");
tile.addChild(moduleInfo.factory.create() as Module);
addToLog ("SomeModule instance created and added to Display List");
}
/**
* Handler for the ModuleEvent.UNLOAD event
**/
public function onModuleUnload (e:ModuleEvent) : void {
addToLog ("ModuleEvent.UNLOAD received");
}
]]>
</mx:Script>
<mx:HBox width="100%" height="100%">
<mx:Tile id="tile" width="100%" height="100%" />
<mx:TextArea id="log" width="100%" height="100%"/>
</mx:HBox>
<mx:ApplicationControlBar>
<mx:Button label="Load" click="loadModule()" />
<mx:Button label="Unload" click="unloadModule()"/>
</mx:ApplicationControlBar>
</mx:Application>
null 정보에 addEventListener를 시도해 볼 수 있습니다. –