Packagecom.cmiscm.net
Classpublic class AssetsLoader
InheritanceAssetsLoader Inheritance flash.events.EventDispatcher

Assets Loader.

View the examples

See also

NetEvent


Public Methods
 MethodDefined By
  
This package was created to assist in more easily loading the SWF file.
AssetsLoader
  
createImg($name:String):BitmapData
this method converts the file to type sound.
AssetsLoader
  
createSound($name:String):Sound
this method converts the file to type sound.
AssetsLoader
  
createSwf($name:String):DisplayObject
this method converts the file to type image.
AssetsLoader
  
garbage():void
this encapsulates the stop, load, clear and garbage collection functionality of the stopLoad and removeEventListener and makeNull calls of the native Load class.
AssetsLoader
  
load($url:String, $context:LoaderContext = null, $is_cache:Boolean = false):void
this method loads the SWF file; it sets and calls the load and addEventLister methods of the native Load class.
AssetsLoader
Events
 Event Summary Defined By
  AssetsLoader
  AssetsLoader
  AssetsLoader
  AssetsLoader
  AssetsLoader
Constructor Detail
AssetsLoader()Constructor
public function AssetsLoader()

This package was created to assist in more easily loading the SWF file. If you use the native SWF loading functionality, you much write code around many event listeners and consider many error types. This wrapper code makes it easier to use the load class – specifically if you want to stop the loading process, you only need to call one function rather than having to remove a set of event listeners and then explicitly stopping the loading process. This code also allows the programmer to more easily convert to their load file type (e.g. image, sound and swf).

Method Detail
createImg()method
public function createImg($name:String):BitmapData

this method converts the file to type sound. It takes the library file name as its one argument and returns a Sound type.

Parameters

$name:String — Linkage Name

Returns
BitmapData
createSound()method 
public function createSound($name:String):Sound

this method converts the file to type sound. It takes the library file name as its one argument and returns a Sound type.

Parameters

$name:String — Linkage Name

Returns
Sound
createSwf()method 
public function createSwf($name:String):DisplayObject

this method converts the file to type image. It takes the library file name as its one argument and returns a BitmapData type.

Parameters

$name:String — Linkage Name

Returns
DisplayObject
garbage()method 
public function garbage():void

this encapsulates the stop, load, clear and garbage collection functionality of the stopLoad and removeEventListener and makeNull calls of the native Load class.

load()method 
public function load($url:String, $context:LoaderContext = null, $is_cache:Boolean = false):void

this method loads the SWF file; it sets and calls the load and addEventLister methods of the native Load class.

Parameters

$url:String — the load file url
 
$context:LoaderContext (default = null) — the security context
 
$is_cache:Boolean (default = false) — a Boolean cache flag: if the cache flag is true you will always get a new file; if false, you will get the cached version of the file.

Event Detail
complete Event
Event Object Type: com.cmiscm.net.events.NetEvent

error Event  
Event Object Type: com.cmiscm.net.events.NetEvent

inits Event  
Event Object Type: com.cmiscm.net.events.NetEvent

progress Event  
Event Object Type: com.cmiscm.net.events.NetEvent

server_error Event  
Event Object Type: com.cmiscm.net.events.NetEvent

Examples
     package {
        import com.cmiscm.net.AssetsLoader;
        import com.cmiscm.net.events.NetEvent;
        
        public class TestLoader
        {
            private var _loader:AssetsLoader;
            
            public function TestLoader()
            {
                _loader = new AssetsLoader();
                _loader.addEventListener(NetEvent.COMPLETE, onComplete);            
                _loader.addEventListener(NetEvent.PROGRESS, onProgress);
                _loader.addEventListener(NetEvent.INITS, onInit);
                _loader.addEventListener(NetEvent.ERROR, onError);
                _loader.addEventListener(NetEvent.SERVER_ERROR, onServerError);
                _loader.load("test.swf");
            }
            
            private function onComplete(evt:NetEvent):void
            {
                trace(evt.content);
                
                _loader.removeEventListener(NetEvent.COMPLETE, onComplete);            
                _loader.removeEventListener(NetEvent.PROGRESS, onProgress);
                _loader.removeEventListener(NetEvent.INITS, onInit);
                _loader.removeEventListener(NetEvent.ERROR, onError);
                _loader.removeEventListener(NetEvent.SERVER_ERROR, onServerError);
                _loader.garbage();
                _loader = null;
            }
            
            private function onProgress(evt:NetEvent):void
            {
                trace(evt.percent);
            }
            
            private function onInit(evt:NetEvent):void
            {
                trace("init load");
            }
            
            private function onError(evt:NetEvent):void
            {
                trace(evt.message);
            }
            
            private function onServerError(evt:NetEvent):void
            {
                trace(evt.message);
            }
        }
     }