LoaderClass

Package:
Class:
Inheritance:
biz.flashscript.utils
public class LoaderClass
N/A
The LoaderClass class allows loading movies and bitmaps, all objects usually loaded with the Loader class and allows transferring variables over event listeners. Although these variables are optional they need to be added as function parameters to the function listening to the event (see Example). Use the constructor new LoaderClass() to create a new LoaderClass object and add parameters as desired.

See also

   biz.flashscript.utils.LoaderClassStatic

   biz.flashscript.utils.LoaderClassAlternate

Public Properties
Property Defined By
All inherited properties of the Sprite class. N/A
loaderBarX : int
Specifies the x position of the loaderbar.
LoaderClass
loaderBarY : int
Specifies the x position of the loaderbar.
LoaderClass
Public Methods
Method Defined By
LoaderClass()
Creates a new instance of the LoaderClass class.
LoaderClass
initLoader(myURL:String, loadFinished:Function, myTarget:Object, lBar:String=null, aNum:Object=null, bStr:Object=null, cBool:Object=null)
Proceeds with loading.
LoaderClass
Events
Event Defined By

loadFin

This event is dispatched when the loading is finished.

LoaderClass
All inherited events for the Sprite class. N/A
Property Detail
loaderBarX property
loaderBarX:int [read-write]

Specifies the x position of the loaderbar.

The default value is 0.

Implementation

public function get loaderBarX():int
public function set loaderBarX(value:int):void
loaderBarY property
loaderBarY:int [read-write]

Specifies the y position of the loaderbar.

The default value is 0.

Implementation

public function get loaderBarY():int
public function set loaderBarY(value:int):void
Constructor Detail
LoaderClass ()  Constructor
public function LoaderClass()
Intializes a new LoaderClass instance with the specified parameters.
Method Detail
initLoader ():void  method
public function initLoader(myURL:String, loadFinished:Function, myTarget:Object, lBar:String=null, aNum:Object=null, bStr:Object=null, cBool:Object=null)

Parameters

  • myURL:String ____ The server-side file used to handle the variables.
  • loadFinished:Function ____ The name of the function for the completed event.
  • myTarget:Object ____ The object to dispatch the event to.
  • lBar:String=null ____ Optional: The class name for a 100 frames loader animation, must stay in the library.
  • aNum:Object=null ____ Optional: Any object to be transferred to the loadFinished function.
  • bStr:Object=null ____ Optional: Any object to be transferred to the loadFinished function.
  • cBool:Object=null ____ Optional: Any object to be transferred to the loadFinished function.
Event Detail

loadFin event

Event Object Type: biz.flashscript.utils.LoaderClass
Event.type property = biz.flashscript.components.utils.LoaderClass.LOAD_FIN

Dispatched when the loading is finished.

Examples
Create a new fla file and name it Loaderclass.fla. Place the fla in the same folder as the biz folder. Have an 100 frames animation in the library with the class name "LoaderBar". Then create an Actionscript file, name it Loaderclass.as and place this script. Replace the name "testmovie.swf" with the path for any image or movie of your choice and test movie.
package 
{
	import flash.display.Sprite;
	import flash.display.*;
	import flash.events.*;
	import biz.flashscript.utils.LoaderClass;
	import flash.events.*;
	public class Loaderclass extends Sprite
	{
		public var mc:Sprite;
		public var message:String;
		public static const LOAD_FIN:String = "loadFin";
		public function Loaderclass ():void
		{
			var myLoader:LoaderClass = new LoaderClass();
			var url:String = "xml_files/testmovie.swf";
			mc=new Sprite();
			var cont:Container=new Container();
			cont.mouseChildren = false;
			addChild (cont);
			var cl:Clip=new Clip();
			cl.name = "CLIP";
			cont.addChild (cl);
			cont.addEventListener (MouseEvent.CLICK,mcHandler);
			addEventListener (LOAD_FIN,lf);
			myLoader.initLoader (url,completed,this,"LoaderBar",10000, false);
		}
		private function completed (e:Event,a:Object,b:Object,c:Object):void
		{
			e.target.content.width = 550;
			trace ("A: "+e.currentTarget.content.parent);
			trace("a:Object :"+a);
			var mm:Object = e.target.content;
			mm.rotationY = 20;
			dispatchEvent (new Event(LOAD_FIN));
		}
		private function mcHandler (event:MouseEvent):void
		{
			trace (event.target);
		}
		private function lf (ev:Event):void
		{
			var myLoad:Loader = Loader(getChildByName("urlLoader"));
			trace ("finished");
			trace (getChildByName("urlLoader"));
			//myLoad.unloadAndStop ();
		}
	}
}