Package : com.danehansen.display Class : public class Preloader Inheritance : Preloader > EventDispatcher > Object
A preloader class designed to easily create a customizable animated canvas preloader. This class depends on TweenLite.js which is available at http://greensock.com/ as well as EventDispatcher.js. It is assumed that it is desired that the canvas element will want to not be shown when the load is full, so either the canvas or the content to be shown after or both will have to have proper positioning added to it so that when the canvas has display:none applied to it that it won’t ruin your layout.
Public Properties
element : Element
[Read-only] Canvas Element that the preloader is to be drawn in.
duration : Number
Duration for the Preloader to make 1 revolution.
Public Methods
Preloader(element:Element, color:uint = "#000", hole:Number = 0, duration:Number = 1)
Creates a Preloader object, using a provided canvas element, color to draw it in, and how big the hole in the center is in relation to the size of the Preloader. The size of the Preloader is the smallest between the width and height of the canvas. The duration is the amount of time, in seconds, for the Preloader to make 1 revolution.
play()
Causes the Preloader to begin looping, at the current duration. This method would be used when the user is waiting for something that would take an undetermined amount of time, such as waiting for a callback. They may see the Preloader animate through just a single time, or many times.
progress(value:Number):*
Gets or sets the instances’s progress. A value of 0 would have the Preloader look empty, 1 would have it look full, and 2 would have it look empty again.
revolve()
Causes the Preloader to make one revolution. This method would be used once the instance’s progress has reached 1, and it is desired for it to make 1 last revolution for it to disappear.
stop()
Causes the Preloader to stop looping at the next occurance that it will not be visible. This method would typically be used after calling the “play” method.
Public Constants
COMPLETE : String = "complete"
[static] The Preloader.COMPLETE constant defines the value of the type property of a complete event object.
Events
complete
Dispatched when the progress has reached a whole number when the instance is not currently playing.
EXAMPLE 1: WAITING FOR A CALLBACK
var autoPreloader=new Preloader(document.getElementById("auto"));
EXAMPLE 2: SHOWING ACTUAL PROGRESS
var progressPreloader=new Preloader(document.getElementById("progress"), "#F0F", 0.25);