Loader is a central distributor for loading files.
Loader should be used for loading files if you do not like to
bother about the certain loading mechianism.
If you want to reduces the occurences of Loader instances you can
use Loader.getInstance that contains a Loader instance.
Loader.getInstance().load("uri") is available to load any common file.
Loading a external .swf requires a MovieClip to load therefore
you should use loadSwf or use the overloaded load with passing
the MovieClip as second parameter.
Loader uses paralell loading, this means it starts as much requests
as allowed paralell.
Loader publishes the same event line FileLoader.
Example for using Loader.load:
import org.as2lib.io.file.Loader;
var loader:Loader = Loader.getInstance();
loader.addListener(...); // Add your listener for the file loading.
loader.load("content.txt");
loader.load("content.xml");
loader.load("content.swf", _root.createEmptyMovieClip("content", _root.getNextHighestDepth());
new Loader()static public function getInstance():Loader
Returns a Loader instance.
Loader instance.
public function loadSwf(uri:String, mc:MovieClip, parameters:Map, method:String, callBack:Executable):SwfFileLoader
Loads a .swf to a MovieClip instance.
uri | location of the resource to load |
mc | MovieClip as container for the .swf content
|
parameters | (optional) parameters for loading the resource |
method | (optional) POST/GET as method for submitting the parameters,
default method used if method was not passed-in is POST.
|
callBack | (optional) Executable to be executed if the resource was complete loaded |
SwfFileLoader that loads the resource
public function loadText(uri:String, method:String, parameters:Map, callBack:Executable):TextFileLoaderLoads a external text file.
uri | location of the resource to load |
method | (optional) POST/GET as method for submitting the parameters,
default method used if method was not passed-in is POST.
|
parameters | (optional) parameters for loading the resource |
callBack | (optional) Executable to be executed if the resource was complete loaded |
TextFileLoader that loads the certain file
public function setFileFactory(textFileFactory:TextFileFactory):Void
Defines the TextFileFactory to be used by loadText.
loadText requires a TextFileFactory to generate the
concrete TextFile instance that represents the resource. This
methods allows configuration of the supported file formats.
The default configuration contains a CompositeTextFileFactory with
SimpleTextFileFactory as default
TextFileFactory and XmlFileFactory for the extension "xml".
textFileFactory | TextFileFactory to be used by loadFile
|
public function onLoadComplete(fileLoader:FileLoader):Void
(implementation detail) Handles the response of a finished FileLoader.
fileLoader | FileLoader that loaded the certain resource
|
public function onLoadStart(resourceLoader:FileLoader):Void
(implementation detail) Handles the response if a FileLoader
started working.
resourceLoader | FileLoader that loaded the certain resource
|
public function onLoadError(resourceLoader:FileLoader, errorCode:String, error):Boolean
(implementation detail) Handles the response if a FileLoader
could not find a resource.
resourceLoader | FileLoader that loaded the certain resource
|
public function onLoadProgress(resourceLoader:FileLoader):Void
(implementation detail) Handles the response if a FileLoader
progressed loading.
resourceLoader | FileLoader that loaded the certain resource
|