AS를 통한 Module 개발

3249 단어 .net
1. ModuleLoader 사용

/*****************************************************
 * ModuleLoader load Module
 * **************************************************/

private function useModuleLoader(event:MouseEvent):void
{
 oldMLoader=new ModuleLoader();
 oldMLoader.percentHeight=100;
 oldMLoader.percentWidth=100;
 oldMLoader.x=oldMLoader.y=0;
 ModuleCanvas.addChild(oldMLoader);
 loadModules("net/diding/module/ASModuleOne.swf")
}

private function loadModules(url:String):void{
 oldMLoader.url=url;
 oldMLoader.loadModule();
 oldMLoader.addEventListener(ModuleEvent.PROGRESS, OnModuleProgress);
 oldMLoader.addEventListener(ModuleEvent.READY, OnModuleReady);

}

private function OnModuleProgress(event:ModuleEvent):void
{
 var percent:Number=event.bytesLoaded / event.bytesTotal;
 var mypercent:String=int(percent * 100) + "%";
 trace(" :" + mypercent);
}

private function OnModuleReady(event:ModuleEvent):void
{
 var MyModule:ASModuleOne=oldMLoader.child as ASModuleOne;
 MyModule.moduleName="ModuleLoader "
 MyModule.doGetArg("hello!");
}


2. IModuleInfo 사용

************************************************
   IModuleInfo
 ***************************************************/
private var _moduleInfo:IModuleInfo;

private function useModulManager(event:MouseEvent):void
{
 _moduleInfo=ModuleManager.getModule('net/diding/module/ASModuleOne.swf');
 _moduleInfo.addEventListener(ModuleEvent.PROGRESS, OnModuleProgress);
 _moduleInfo.addEventListener(ModuleEvent.READY, moduleLoadHandler);
 _moduleInfo.load();
}


private function moduleLoadHandler(evt:ModuleEvent):void
{
 var MyModule:ASModuleOne=_moduleInfo.factory.create()as ASModuleOne;
 MyModule.moduleName="ModuleManage "
 MyModule.doGetArg("hello!");}

ASModuleOne 모듈

package  net.diding.module
{

 import mx.controls.DataGrid;
 import mx.controls.dataGridClasses.DataGridColumn;
 import mx.modules.Module;
 

 public class ASModuleOne extends Module
 {
  private var MyDataDG:DataGrid;
  private var _moduleName:String;
  
  public function ASModuleOne()
  {
   super();
   DDinit()
  }
  private function DDinit():void{
  
  }
  /*******************************************
   *  
   * *****************************************/
  public function set moduleName(arg:String):void{
   _moduleName=arg
  }
  public function get moduleName():String{
   return _moduleName;
  }
  /*************************************************
   *  
   * ***********************************************/
    public function doGetArg(arg:String):void{
     trace(_moduleName)
   trace(arg)
    }
  //--------------------------
 }
}

좋은 웹페이지 즐겨찾기