Preloader

Package:
Class:
Inheritance:
biz.flashscript.utils
public class Preloader
Sprite
The Preloader class allows to preload a movie and external images and movies but not using a component. When preloading is completed an event is dispatched. To initiate the Preloader use the constructor new Preloader().

See also

   biz.flashscript.components.preloader.Preloader

   biz.flashscript.utils.MultiPreloader

Public Properties
Property Defined By
All inherited proerties of the Sprite class. N/A
Public Methods
Method Defined By
Preloader()
Constructor
Preloader
timelineLoader(target:Object, xPos:int=0, yPos:int=0, nLoaderBar:String=null)
Function to preload a timeline.
Preloader
imageLoader(target:Object, xPos:int=0, yPos:int=0, nLoaderBar:String=null)
Function to preload external movies and images.
Preloader
Events
Event Defined By

loadComplete

This event is dispatched when preloading is completed.

Preloader
All inherited events for the Sprite class. N/A
Constructor Detail
Preloader ()  Constructor
public function Preloader()
Intializes a new Preloader instance.
Method Detail
Preloader ()  Constructor
public function Preloader()
Intializes a new Preloader instance.

timelineLoader ():void  method
public function timelineLoader()
Intializes a the loading of the main timeline.

Parameters

  • target:Object ____ The object to preload.
  • xPos:int ____ Optional: The x position of a 100 frames loaderbar object.
  • yPos:int ____ Optional: The y position of a 100 frames loaderbar object.
  • nLoaderBar:String ____ Optional: The name (String) of a class of a 100 frames loaderbar object.

imageLoader ():void  method
public function imageLoader()
Intializes the loading of the main timeline.

Parameters

  • target:Object ____ The object to preload.
  • xPos:int ____ Optional: The x position of a 100 frames loaderbar object.
  • yPos:int ____ Optional: The y position of a 100 frames loaderbar object.
  • nLoaderBar:String ____ Optional: The name (String) of a class of a 100 frames loaderbar object.
Event Detail

loadComplete event

Event Object Type: biz.flashscript.utils.Preloader
Event.type property = biz.flashscript.utils.Preloader.LOAD_COMPLETE

Dispatched when preloading is completed.

Examples
Create a new fla file and name it Preloader.fla. Place the fla in the same folder as the biz folder. Create two frames and name them "frame1" and "frame2". Add a 100 frames animation MovieClip in the library and name it "LoaderBar". Then have an image in the same folder as the fla file. Place a button component on the timeline and name it startBut. Then create an Actionscript file, name it Preloaders.as and place this script. Rename the image URL ("image.jpg") in the script. Test movie. The timeline should go to the second frame.

package 
{
	import flash.display.MovieClip;
	import biz.flashscript.utils.Preloader;
	import flash.events.*;
	import fl.controls.Button;

	public class Preloaders extends MovieClip
	{
		public var startBut:Button;
		private var preload:Preloader;
		
		public function Preloaders ():void
		{
			startBut.label = "PRELOAD";
			startBut.addEventListener (MouseEvent.CLICK, clickHandler);
		}
		private function clickHandler (ev:MouseEvent):void
		{
			gotoAndStop ("frame1");
			preload = new Preloader();
			preload.imageLoader("images/A2.jpg",25,100,"LoaderBar");
			addChild (preload);
			preload.addEventListener (Preloader.LOAD_COMPLETE, completeHandler);
		}
		private function completeHandler (ev:Event):void
		{
			trace ("Loading is now complete!");
			gotoAndStop ("frame2");
			removeChild(preload);
		}
	}
}