Package | com.cmiscm.net |
Class | public class AssetsLoader |
Inheritance | AssetsLoader ![]() |
See also
Method | Defined 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 |
Event | Summary | Defined By | ||
---|---|---|---|---|
AssetsLoader | ||||
AssetsLoader | ||||
AssetsLoader | ||||
AssetsLoader | ||||
AssetsLoader |
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).
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
|
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
|
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
|
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.
|
complete | Event |
error | Event |
inits | Event |
progress | Event |
server_error | Event |
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); } } }