| Package | starling.animation |
| Class | public class Juggler |
| Inheritance | Juggler Object |
| Implements | IAnimatable |
A juggler is a simple object. It does no more than saving a list of objects implementing "IAnimatable" and advancing their time if it is told to do so (by calling its own "advanceTime"-method). When an animation is completed, it throws it away.
There is a default juggler available at the Starling class:
var juggler:Juggler = Starling.juggler;
You can create juggler objects yourself, just as well. That way, you can group your game into logical components that handle their animations independently. All you have to do is call the "advanceTime" method on your custom juggler once per frame.
Another handy feature of the juggler is the "delayCall"-method. Use it to execute a function at a later time. Different to conventional approaches, the method will only be called when the juggler is advanced, giving you perfect control over the call.
juggler.delayCall(object.removeFromParent, 1.0);
juggler.delayCall(object.addChild, 2.0, theChild);
juggler.delayCall(function():void { doSomethingFunny(); }, 3.0);
See also
| Property | Defined By | ||
|---|---|---|---|
| elapsedTime : Number [read-only] The total life time of the juggler. | Juggler | ||
| isComplete : Boolean [read-only] Always returns 'false'. | Juggler | ||
| Method | Defined By | ||
|---|---|---|---|
Juggler() Create an empty juggler. | Juggler | ||
add(object:IAnimatable):void Adds an object to the juggler. | Juggler | ||
advanceTime(time:Number):void Advanced all objects by a certain time (in seconds). | Juggler | ||
delayCall(call:Function, delay:Number, ... args):DelayedCall Delays the execution of a function until a certain time has passed. | Juggler | ||
purge():void Removes all objects at once. | Juggler | ||
remove(object:IAnimatable):void Removes an object from the juggler. | Juggler | ||
removeTweens(target:Object):void Removes all tweens with a certain target. | Juggler | ||
| elapsedTime | property |
elapsedTime:Number [read-only] The total life time of the juggler.
public function get elapsedTime():Number| isComplete | property |
isComplete:Boolean [read-only] Always returns 'false'.
public function get isComplete():Boolean| Juggler | () | Constructor |
public function Juggler()Create an empty juggler.
| add | () | method |
public function add(object:IAnimatable):voidAdds an object to the juggler.
Parameters
object:IAnimatable |
| advanceTime | () | method |
public function advanceTime(time:Number):voidAdvanced all objects by a certain time (in seconds). Objects with a positive 'isComplete'-property will be removed.
Parameters
time:Number |
| delayCall | () | method |
public function delayCall(call:Function, delay:Number, ... args):DelayedCallDelays the execution of a function until a certain time has passed. Creates an object of type 'DelayedCall' internally and returns it. Remove that object from the juggler to cancel the function call.
Parameters
call:Function | |
delay:Number | |
... args |
DelayedCall |
| purge | () | method |
public function purge():voidRemoves all objects at once.
| remove | () | method |
public function remove(object:IAnimatable):voidRemoves an object from the juggler.
Parameters
object:IAnimatable |
| removeTweens | () | method |
public function removeTweens(target:Object):voidRemoves all tweens with a certain target.
Parameters
target:Object |