Class org.as2lib.io.file.Loader

Implemented Interfaces

LoadStartListener LoadCompleteListener LoadErrorListener LoadProgressListener

Description

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());

Field Index

Inherited from LogSupport

Method Index

new Loader()
getInstance(), load(), loadSwf(), loadText(), onLoadComplete(), onLoadError(), onLoadProgress(), onLoadStart(), setFileFactory()

Inherited from EventSupport

Inherited from LogSupport

Inherited from BasicClass

Constructor Detail

Loader

public function Loader(Void)

Constructs a new Loader.

Method Detail

getInstance

static public function getInstance():Loader

Returns a Loader instance.

Return

Loader instance.

loadSwf

public function loadSwf(uri:String, mc:MovieClip, parameters:Map, method:String, callBack:Executable):SwfFileLoader

Loads a .swf to a MovieClip instance.

Parameters

urilocation 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

Return

SwfFileLoader that loads the resource

loadText

public function loadText(uri:String, method:String, parameters:Map, callBack:Executable):TextFileLoader

Loads a external text file.

Parameters

urilocation 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

Return

TextFileLoader that loads the certain file

setFileFactory

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".

Parameters

textFileFactory TextFileFactory to be used by loadFile

load

public function load(url, target)

onLoadComplete

public function onLoadComplete(fileLoader:FileLoader):Void

(implementation detail) Handles the response of a finished FileLoader.

Parameters

fileLoader FileLoader that loaded the certain resource

Specified By

onLoadComplete() in org.as2lib.io.file.LoadCompleteListener

onLoadStart

public function onLoadStart(resourceLoader:FileLoader):Void

(implementation detail) Handles the response if a FileLoader started working.

Parameters

resourceLoader FileLoader that loaded the certain resource

Specified By

onLoadStart() in org.as2lib.io.file.LoadStartListener

onLoadError

public function onLoadError(resourceLoader:FileLoader, errorCode:String, error):Boolean

(implementation detail) Handles the response if a FileLoader could not find a resource.

Parameters

resourceLoader FileLoader that loaded the certain resource

Specified By

onLoadError() in org.as2lib.io.file.LoadErrorListener

onLoadProgress

public function onLoadProgress(resourceLoader:FileLoader):Void

(implementation detail) Handles the response if a FileLoader progressed loading.

Parameters

resourceLoader FileLoader that loaded the certain resource

Specified By

onLoadProgress() in org.as2lib.io.file.LoadProgressListener