Add event listener for module loading progress with ActionScript : ModuleLoader « Development « Flex






Add event listener for module loading progress with ActionScript

Add event listener for module loading progress with ActionScript
           
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
  <mx:Script>
    
      import mx.events.FlexEvent;
      import mx.events.ModuleEvent;
      import mx.modules.ModuleManager;
      
      private var flag:Boolean = true;
      private var dynamicModule:ModuleLoader;
      
      private function changeMac():void 
      {
            dynamicModule = new ModuleLoader();
            dynamicModule.url = "a.swf";
            dynamicModule.addEventListener( ModuleEvent.PROGRESS, eventHandler );           
            this.addChild( dynamicModule );
  
            dynamicModule.loadModule();
            dynamicModule.unloadModule();
      }
      
      private function eventHandler( event:Event ):void
      {
        trace( "Control: " + event.currentTarget + " type: " + event.type );
      }
  
  </mx:Script>
  <mx:Button label="Change Mac" click="changeMac()" />
  <mx:ModuleLoader id="mlRuntimeCSS" 
                    url="a.swf"
                    loading="eventHandler( event )"
                    progress="eventHandler( event )"
                    ready="eventHandler( event )"
                    setup="eventHandler( event )"
                    unload="eventHandler( event )" />
  <mx:ModuleLoader id="mlDateWidget2"
                    url="a.swf"
                    loading="eventHandler( event )"
                    progress="eventHandler( event )"
                    ready="eventHandler( event )"
                    setup="eventHandler( event )"
                    unload="eventHandler( event )" />
    
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Load and unload a module by using the Button controlsLoad and unload a module by using the Button controls
2.Load module using MXML
3.Unloading a module using ActionScript
4.Use multiple Use multiple <mx:AddChild>
5.Preload modulePreload module
6.Using the ModuleLoader class to load modules
7.Build a unique query string for the module loadingBuild a unique query string for the module loading
8.Report the level of completion during the module's loading processReport the level of completion during the module's loading process
9.Loads and unloads the module when you click the buttonLoads and unloads the module when you click the button
10.Add event listener for loading a Module with ActionScriptAdd event listener for loading a Module with ActionScript
11.Add event listener when module loading is ready with ActionScriptAdd event listener when module loading is ready with ActionScript
12.Add event listener for unloading a module with ActionScriptAdd event listener for unloading a module with ActionScript
13.Module load, progress, ready, setup and unload eventsModule load, progress, ready, setup and unload events