Flashscript classes (ActionScript 3) | Home | MX | MX 2004 | Flash 8 | Flash 9 |Flash 10 |PHP |Components | Snippets | Contact |

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 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
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.
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
	{
		private 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 = "testmovie.swf";//HOME.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);
			var mm:Object = e.target.content;
			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 ();
		}
	}
}