The Juggler takes objects that implement IAnimatable (like Tweens) and executes them.

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:

     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 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 { rotation += 0.1; }, 3.0);

@see Tween @see DelayedCall

### Hierarchy

- Juggler

### Implements

- IAnimatable

## Index

### Constructors

- constructor

### Properties

- elapsedTime
- objects
- timeScale

### Methods

- add
- addWithID
- advanceTime
- contains
- containsDelayedCalls
- containsTweens
- delayCall
- get_elapsedTime
- get_objects
- get_timeScale
- purge
- remove
- removeByID
- removeDelayedCalls
- removeTweens
- repeatCall
- set_timeScale
- tween

## Constructors

### constructor

- new Juggler(): Juggler

- - Defined in lib/starling/animation/Juggler.d.ts:37

  Create an empty juggler.

  #### Returns Juggler

## Properties

### elapsedTime

elapsedTime: number

- Defined in lib/starling/animation/Juggler.d.ts:143

The total life time of the juggler (in seconds).

### Protected objects

objects: Vector<IAnimatable>

- Defined in lib/starling/animation/Juggler.d.ts:154

The actual vector that contains all objects that are currently being animated.

### timeScale

timeScale: number

- Defined in lib/starling/animation/Juggler.d.ts:149

The scale at which the time is passing. This can be used for slow motion or time laps effects. Values below '1' will make all animations run slower, values above '1' faster. @default 1.0

## Methods

### add

- add(object: IAnimatable): number

- - Defined in lib/starling/animation/Juggler.d.ts:46

  Adds an object to the juggler.

  @return Unique numeric identifier for the animation. This identifier may be used to remove the object via `removeByID()`.

  #### Parameters

  - ##### object: IAnimatable

  #### Returns number

### addWithID

- addWithID(object: IAnimatable, objectID: number): number

- - Defined in lib/starling/animation/Juggler.d.ts:48

  #### Parameters

  - ##### object: IAnimatable

  - ##### objectID: number

  #### Returns number

### advanceTime

- advanceTime(time: number): void

- - Defined in lib/starling/animation/Juggler.d.ts:140

  Advances all objects by a certain time (in seconds).

  #### Parameters

  - ##### time: number

  #### Returns void

### contains

- contains(object: IAnimatable): boolean

- - Defined in lib/starling/animation/Juggler.d.ts:51

  Determines if an object has been added to the juggler.

  #### Parameters

  - ##### object: IAnimatable

  #### Returns boolean

### containsDelayedCalls

- containsDelayedCalls(callback: Function): boolean

- - Defined in lib/starling/animation/Juggler.d.ts:83

  Figures out if the juggler contains one or more delayed calls with a certain callback.

  #### Parameters

  - ##### callback: Function

  #### Returns boolean

### containsTweens

- containsTweens(target: any): boolean

- - Defined in lib/starling/animation/Juggler.d.ts:80

  Figures out if the juggler contains one or more tweens with a certain target.

  #### Parameters

  - ##### target: any

  #### Returns boolean

### delayCall

- delayCall(call: Function, delay: number, args?: Array<any>): number

- - Defined in lib/starling/animation/Juggler.d.ts:95

  Delays the execution of a until `delay` seconds have passed. This method provides a convenient alternative for creating and adding a DelayedCall manually.

  @return Unique numeric identifier for the delayed call. This identifier may be used to remove the object via `removeByID()`.

  #### Parameters

  - ##### call: Function

  - ##### delay: number

  - ##### Optional args: Array<any>

  #### Returns number

### Protected get_elapsedTime

- get_elapsedTime(): number

- - Defined in lib/starling/animation/Juggler.d.ts:144

  #### Returns number

### Protected get_objects

- get_objects(): Vector<IAnimatable>

- - Defined in lib/starling/animation/Juggler.d.ts:155

  #### Returns Vector<IAnimatable>

### Protected get_timeScale

- get_timeScale(): number

- - Defined in lib/starling/animation/Juggler.d.ts:150

  #### Returns number

### purge

- purge(): void

- - Defined in lib/starling/animation/Juggler.d.ts:86

  Removes all objects at once.

  #### Returns void

### remove

- remove(object: IAnimatable): number

- - Defined in lib/starling/animation/Juggler.d.ts:58

  Removes an object from the juggler.

  @return The (now meaningless) unique numeric identifier for the animation, or zero if the object was not found.

  #### Parameters

  - ##### object: IAnimatable

  #### Returns number

### removeByID

- removeByID(objectID: number): number

- - Defined in lib/starling/animation/Juggler.d.ts:71

  Removes an object from the juggler, identified by the unique numeric identifier you received when adding it.

  It's not uncommon that an animatable object is added to a juggler repeatedly, e.g. when using an object-pool. Thus, when using the `remove` method, you might accidentally remove an object that has changed its context. By using `removeByID` instead, you can be sure to avoid that, since the objectID will always be unique.

  @return if successful, the passed objectID; if the object was not found, zero.

  #### Parameters

  - ##### objectID: number

  #### Returns number

### removeDelayedCalls

- removeDelayedCalls(callback: Function): void

- - Defined in lib/starling/animation/Juggler.d.ts:77

  Removes all delayed and repeated calls with a certain callback.

  #### Parameters

  - ##### callback: Function

  #### Returns void

### removeTweens

- removeTweens(target: any): void

- - Defined in lib/starling/animation/Juggler.d.ts:74

  Removes all tweens with a certain target.

  #### Parameters

  - ##### target: any

  #### Returns void

### repeatCall

- repeatCall(call: Function, interval: number, repeatCount?: number, args?: Array<any>): number

- - Defined in lib/starling/animation/Juggler.d.ts:103

  Runs a at a specified interval (in seconds). A 'repeatCount' of zero means that it runs indefinitely.

  @return Unique numeric identifier for the delayed call. This identifier may be used to remove the object via `removeByID()`.

  #### Parameters

  - ##### call: Function

  - ##### interval: number

  - ##### Optional repeatCount: number

  - ##### Optional args: Array<any>

  #### Returns number

### Protected set_timeScale

- set_timeScale(value: number): number

- - Defined in lib/starling/animation/Juggler.d.ts:151

  #### Parameters

  - ##### value: number

  #### Returns number

### tween

- tween(target: any, time: number, properties: any): number

- - Defined in lib/starling/animation/Juggler.d.ts:137

  Utilizes a tween to animate the target object over `time` seconds. Internally, this method uses a tween instance (taken from an object pool) that is added to the juggler right away. This method provides a convenient alternative for creating and adding a tween manually.

  Fill 'properties' with key-value pairs that describe both the tween and the animation target. Here is an example:

       juggler.tween(object, 2.0, {
           transition: Transitions.EASE_IN_OUT,
           delay: 20, // -> tween.delay = 20
           x: 50      // -> tween.animate("x", 50)
       });

  To cancel the tween, call 'Juggler.removeTweens' with the same target, or pass the returned 'IAnimatable' instance to 'Juggler.remove()'. Do not use the returned IAnimatable otherwise; it is taken from a pool and will be reused.

  Note that some property types may be animated in a special way:

  - If the property contains the string `color` or `Color`, it will be treated as an unsigned integer with a color value (e.g. `0xff0000` for red). Each color channel will be animated individually.
  - The same happens if you append the string `#rgb` to the name.
  - If you append `#rad`, the property is treated as an angle in radians, making sure it always uses the shortest possible arc for the rotation.
  - The string `#deg` does the same for angles in degrees.

  #### Parameters

  - ##### target: any

  - ##### time: number

  - ##### properties: any

  #### Returns number

Generated using TypeDoc