Imprint

sickworks.com

 

Example of the Preloader-Class

Download source

 

Documentation:

/*
* 1.) import the class to use it
*/

import com.sickworks.utils.Preloader;

/*
* 2.) create a new instance of the class and set the main parameters:
*
* public function Preloader(clipToLoad:String, target:MovieClip, callback:Function)
*
* parameters:
* - clipToLoad = the URL of the swf or image you want to load.
* - target = the MovieClip that shall hold the loaded clip. if target == null, a new MovieClip will be created
* on the _root of the calling swf.
* - callback = the function to call when the clip has finished loading.
*/

var pl1:Preloader = new Preloader("gecko_big.png", pr1, loadinit);

/*
* 3.) add MovieClips to be transformed during loadprogress
*
* public function addTransforms(clipsToTransform:Array, pctTextField:TextField, textToAdd:String):Void
*
* MovieClips can be added as one big Array using [mc:MovieClip, TransformParameters:Object, mc:MovieClip, TransformParameters:Object, ...]
* or via multiple calls of the function.
* parameters:
* - clipsToTransform = an Array of MovieClips to be transformed during loadprogress
* usage: [mc:MovieClip, TransformParameters:Object, mc:MovieClip, TransformParameters:Object, ...]
* - pctTextField (optional) = dynamic TextField where the loadpercentage shall be displayed
* - textToAdd (optional and only if pctTextField is used) = text to add behind loaderpercentage
*
* TransformParameters can contain a special property named "keepProps". if this property is set to true,
* the original properties of the transformObject are kept as they are. otherwise the become 0 whe loading starts.
*/

pl1.addTransforms([transform_mc, {keepProps: true, _xscale: 25, _yscale: 25, _rotation: 1440}], prtext1, " %");

pl1.addTransforms([transform_mc2, {_xscale: 100}]);

/*
* 4.) set additional parameters (see 5.) or start the loader
*
* public function start():Void
*
*/

pl1.start();

/*
* 5.) additional methods
*
* public function showBytesLoaded(targetTextField:TextField, textToAdd:String, useKB:Boolean):Void
*
* show the amount of bytes that are currently loaded
* parameters:
* - targetTextField = the TextField where the amount of loaded bytes shall be shown
* - textToAdd = text to add behind the number of the loaded bytes
* - useKB = if set to true, the ymount of bytes loaded is displayed as kilobytes
*/

pl1.showBytesLoaded(prtext2, " bytes loaded");

/*
*
* public function showBytesTotal(targetTextField:TextField, textToAdd:String, useKB:Boolean):Void
*
* show the total amount of bytes of the MovieClip that is loading
* parameters:
* - targetTextField = the TextField where the amount of total bytes shall be shown
* - textToAdd = text to add behind the number of the total bytes
* - useKB = if set to true, the ymount of bytes loaded is displayed as kilobytes
*/

pl1.showBytesTotal(prtext3, " KB total ", true);

/*
*
* public function showBytesLoadedTotal(targetTextField:TextField, textToAddAfterLoaded:String, textToAddAfterTotal:String, useKB:Boolean):Void
*
* show the amount of bytes that are currently loaded and the total amount of bytes
* parameters:
* - targetTextField = the TextField where the amount of loaded bytes shall be shown
* - textToAddAfterLoaded = text to add behind the number of the loaded bytes
* - textToAddAfterTotal = text to add behind the number of the total amount of bytes
* - useKB = if set to true, the ymount of bytes loaded is displayed as kilobytes
*/

pl1.showBytesLoadedTotal(prtext4, " KB of ", " KB loaded", true);

/*
*
* public function showPercent(targetTextField:TextField, textToAdd:String):Void
*
* show the percentage that are currently loaded
* parameters:
* - targetTextField = the TextField where the loadingpercentage shall be shown
* - textToAdd = text to add behind the percentage number
*/

pl1.showPercent(prtext5, " % loaded");