Class org.as2lib.io.file.SwfFileLoader

Implemented Interfaces

FileLoader FrameImpulseListener

Description

SwfLoader is a implementation of FileLoader to load files with loadMovie (usually .swf files}.

Any content to be loaded with can be load with SwfLoader to a concrete MovieClip instance that has to be passed-in with the constructor.

SwfLoader represents the time consuming part of accessing external .swf' ( SwfFile is the handleable part} and therefore contains a event system to add listeners to listen to the concrete events. It is possible to add listeners using addListener.

Example listener: import org.as2lib.io.file.AbstractFileLoader; import org.as2lib.io.file.LoadProgressListener; import org.as2lib.io.file.LoadStartListener; import org.as2lib.io.file.LoadCompleteListener; import org.as2lib.io.file.LoadErrorListener; import org.as2lib.io.file.FileLoader; import org.as2lib.io.file.SwfFile; class MySwfListener implements LoadProgressListener, LoadStartListener, LoadCompleteListener, LoadErrorListener { public function onLoadComplete(fileLoader:FileLoader):Void { var swf:SwfFile = SwfFile(fileLoader.getFile()); if (swf != null) { // Proper swf available } else { // Wrong event handled } } public function onLoadError(fileLoader:FileLoader, errorCode:String, error):Void { if (errorCode == AbstractFileLoader.FILE_NOT_FOUND) { var notExistantUrl = error; // Use that url } } public function onLoadStart(fileLoader:FileLoader) { // show that this file just gets loaded } public function onLoadProgress(fileLoader:FileLoader) { // update the percentage display with fileLoader.getPercentage(); } }

Example of the usage: import org.as2lib.io.file.SwfLoader; var swfLoader:SwfLoader = new SwfLoader(); swfLoader.addListener(new MySwfListener()); swfLoader.load("test.swf");

Field Index

TIMEOUT

Inherited from AbstractFileLoader

Inherited from LogSupport

Method Index

new SwfFileLoader()
getBytesLoaded(), getBytesTotal(), getFile(), load(), onFrameImpulse()

Inherited from AbstractFileLoader

Inherited from AbstractTimeConsumer

Inherited from EventSupport

Inherited from LogSupport

Inherited from BasicClass

Constructor Detail

SwfFileLoader

public function SwfFileLoader(holder:MovieClip)

Constructs a new SwfLoader instance.

Parameters

holder MovieClip instance to load the .swf into

Field Detail

TIMEOUT

static public TIMEOUT:Time
Time until the method breaks with "File not found".

Method Detail

load

public function load(uri:String, method:String, parameters:Map, callBack:Executable):Void

Loads a certain .swf by a http request.

It sends http request by using the passed-in uri, method and parameters with .loadMovie.

If you only need to listen if the SwfFile finished loading you can apply a callBack that gets called if the File is loaded.

Parameters

urilocation of the file 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 file
callBack(optional) Executable to be executed after the the file was loaded.

Specified By

load() in org.as2lib.io.file.FileLoader

Overrides

load() in org.as2lib.io.file.AbstractFileLoader

getFile

public function getFile(Void):File

Returns the loaded file.

Return

file that has been loaded

Throws

FileNotLoadedExceptionif the file has not been loaded yet

Specified By

getFile() in org.as2lib.io.file.FileLoader

Overrides

getFile() in org.as2lib.io.file.AbstractFileLoader

getBytesLoaded

public function getBytesLoaded(Void):Byte

Returns the total amount of bytes that has been loaded.

Returns null if its not possible to get the loaded bytes.

Return

amount of bytes that has been loaded

Specified By

getBytesLoaded() in org.as2lib.io.file.FileLoader

Overrides

getBytesLoaded() in org.as2lib.io.file.AbstractFileLoader

getBytesTotal

public function getBytesTotal(Void):Byte

Returns the total amount of bytes that will approximately be loaded.

Returns null if its not possible to get the total amount of bytes.

Return

amount of bytes to load

Specified By

getBytesTotal() in org.as2lib.io.file.FileLoader

Overrides

getBytesTotal() in org.as2lib.io.file.AbstractFileLoader

onFrameImpulse

public function onFrameImpulse(impulse:FrameImpulse):Void

Handles a frame execution.

Helper that checks every frame if the .swf finished loading.

Parameters

impulse FrameImpulse that sent the event

Specified By

onFrameImpulse() in org.as2lib.env.event.impulse.FrameImpulseListener