A Tween animates numeric properties of objects. It uses different transition functions to give the animations various styles.

The primary use of this class is to do standard animations like movement, fading, rotation, etc. But there are no limits on what to animate; as long as the property you want to animate is numeric (`int, uint, Number`), the tween can handle it. For a list of available Transition types, look at the "Transitions" class.

Here is an example of a tween that moves an object to the right, rotates it, and fades it out:

    						tween:Tween = new Tween(object, 2.0, Transitions.EASE_IN_OUT);
    						tween.animate("x", object.x + 50);
    						tween.animate("rotation", deg2rad(45));
    						tween.fadeTo(0);    // equivalent to 'animate("alpha", 0)'
    					Starling.juggler.add(tween);

Note that the object is added to a juggler at the end of this sample. That's because a tween will only be executed if its "advanceTime" method is executed regularly - the juggler will do that for you, and will remove the tween when it is finished.

@see Juggler @see Transitions

### Hierarchy

- EventDispatcher
  - Tween

### Implements

- IAnimatable

## Index

### Constructors

- constructor

### Properties

- currentTime
- delay
- isComplete
- nextTween
- onComplete
- onCompleteArgs
- onRepeat
- onRepeatArgs
- onStart
- onStartArgs
- onUpdate
- onUpdateArgs
- progress
- repeatCount
- repeatDelay
- reverse
- roundToInt
- target
- totalTime
- transition
- transitionFunc

### Methods

- addEventListener
- advanceTime
- animate
- animatesProperty
- dispatchEvent
- dispatchEventWith
- fadeTo
- getEndValue
- get_currentTime
- get_delay
- get_isComplete
- get_nextTween
- get_onComplete
- get_onCompleteArgs
- get_onRepeat
- get_onRepeatArgs
- get_onStart
- get_onStartArgs
- get_onUpdate
- get_onUpdateArgs
- get_progress
- get_repeatCount
- get_repeatDelay
- get_reverse
- get_roundToInt
- get_target
- get_totalTime
- get_transition
- get_transitionFunc
- hasEventListener
- moveTo
- removeEventListener
- removeEventListeners
- reset
- rotateTo
- scaleTo
- set_delay
- set_nextTween
- set_onComplete
- set_onCompleteArgs
- set_onRepeat
- set_onRepeatArgs
- set_onStart
- set_onStartArgs
- set_onUpdate
- set_onUpdateArgs
- set_repeatCount
- set_repeatDelay
- set_reverse
- set_roundToInt
- set_transition
- set_transitionFunc

## Constructors

### constructor

- new Tween(target: any, time: number, transition?: any): Tween

- Overrides EventDispatcher.constructor

  - Defined in lib/starling/animation/Tween.d.ts:34

  Creates a tween with a target, duration (in seconds) and a transition function.

  #### Parameters

  - ##### target: any

    the object that you want to animate

  - ##### time: number

    the duration of the Tween (in seconds)

  - ##### Optional transition: any

    can be either a String (e.g. one of the constants defined in the Transitions class) or a function. Look up the 'Transitions' class for a documentation about the required signature.

  #### Returns Tween

## Properties

### currentTime

currentTime: number

- Defined in lib/starling/animation/Tween.d.ts:110

The time that has passed since the tween was created (in seconds).

### delay

delay: number

- Defined in lib/starling/animation/Tween.d.ts:118

The delay before the tween is started (in seconds). @default 0

### isComplete

isComplete: boolean

- Defined in lib/starling/animation/Tween.d.ts:88

Indicates if the tween is finished.

### nextTween

nextTween: Tween

- Defined in lib/starling/animation/Tween.d.ts:187

Another tween that will be started (i.e. added to the same juggler) as soon as this tween is completed.

### onComplete

onComplete: Function

- Defined in lib/starling/animation/Tween.d.ts:161

A that will be called when the tween is complete.

### onCompleteArgs

onCompleteArgs: Array<any>

- Defined in lib/starling/animation/Tween.d.ts:181

The arguments that will be passed to the 'onComplete' function.

### onRepeat

onRepeat: Function

- Defined in lib/starling/animation/Tween.d.ts:156

A that will be called each time the tween finishes one repetition (except the last, which will trigger 'onComplete').

### onRepeatArgs

onRepeatArgs: Array<any>

- Defined in lib/starling/animation/Tween.d.ts:176

The arguments that will be passed to the 'onRepeat' function.

### onStart

onStart: Function

- Defined in lib/starling/animation/Tween.d.ts:145

A that will be called when the tween starts (after a possible delay).

### onStartArgs

onStartArgs: Array<any>

- Defined in lib/starling/animation/Tween.d.ts:166

The arguments that will be passed to the 'onStart' function.

### onUpdate

onUpdate: Function

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

A that will be called each time the tween is advanced.

### onUpdateArgs

onUpdateArgs: Array<any>

- Defined in lib/starling/animation/Tween.d.ts:171

The arguments that will be passed to the 'onUpdate' function.

### progress

progress: number

- Defined in lib/starling/animation/Tween.d.ts:114

The current progress between 0 and 1, as calculated by the transition function.

### repeatCount

repeatCount: number

- Defined in lib/starling/animation/Tween.d.ts:124

The number of times the tween will be executed. Set to '0' to tween indefinitely. @default 1

### repeatDelay

repeatDelay: number

- Defined in lib/starling/animation/Tween.d.ts:129

The amount of time to wait between repeat cycles (in seconds). @default 0

### reverse

reverse: boolean

- Defined in lib/starling/animation/Tween.d.ts:135

Indicates if the tween should be reversed when it is repeating. If enabled, every second repetition will be reversed. @default false

### roundToInt

roundToInt: boolean

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

Indicates if the numeric values should be cast to Integers. @default false

### target

target: any

- Defined in lib/starling/animation/Tween.d.ts:92

The target object that is animated.

### totalTime

totalTime: number

- Defined in lib/starling/animation/Tween.d.ts:106

The total time the tween will take per repetition (in seconds).

### transition

transition: string

- Defined in lib/starling/animation/Tween.d.ts:96

The transition method used for the animation. @see Transitions

### transitionFunc

transitionFunc: function

- Defined in lib/starling/animation/Tween.d.ts:101

The actual transition used for the animation.

#### Type declaration

- - (number: any): number

  - #### Parameters

    - ##### number: any

    #### Returns number

## Methods

### addEventListener

- addEventListener(type: string, listener: Function): void

- Inherited from EventDispatcher.addEventListener

  - Defined in lib/starling/events/EventDispatcher.d.ts:32

  Registers an event listener at a certain object.

  #### Parameters

  - ##### type: string

  - ##### listener: Function

  #### Returns void

### advanceTime

- advanceTime(time: number): void

- - Defined in lib/starling/animation/Tween.d.ts:78
  inheritdoc

  #### Parameters

  - ##### time: number

  #### Returns void

### animate

- animate(property: string, endValue: number): void

- - Defined in lib/starling/animation/Tween.d.ts:61

  Animates the property of the target to a certain value. You can call this method multiple times on one tween.

  Some property types are handled 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

  - ##### property: string

  - ##### endValue: number

  #### Returns void

### animatesProperty

- animatesProperty(property: string): boolean

- - Defined in lib/starling/animation/Tween.d.ts:85

  Indicates if a property with the given name is being animated by this tween.

  #### Parameters

  - ##### property: string

  #### Returns boolean

### dispatchEvent

- dispatchEvent(event: Event): void

- Inherited from EventDispatcher.dispatchEvent

  - Defined in lib/starling/events/EventDispatcher.d.ts:45

  Dispatches an event to all objects that have registered listeners for its type. If an event with enabled 'bubble' property is dispatched to a display object, it will travel up along the line of parents, until it either hits the root object or someone stops its propagation manually.

  #### Parameters

  - ##### event: Event

  #### Returns void

### dispatchEventWith

- dispatchEventWith(type: string, bubbles?: boolean, data?: any): void

- Inherited from EventDispatcher.dispatchEventWith

  - Defined in lib/starling/events/EventDispatcher.d.ts:50

  Dispatches an event with the given parameters to all objects that have registered listeners for the given type. The method uses an internal pool of event objects to avoid allocations.

  #### Parameters

  - ##### type: string

  - ##### Optional bubbles: boolean

  - ##### Optional data: any

  #### Returns void

### fadeTo

- fadeTo(alpha: number): void

- - Defined in lib/starling/animation/Tween.d.ts:70

  Animates the 'alpha' property of an object to a certain target value.

  #### Parameters

  - ##### alpha: number

  #### Returns void

### getEndValue

- getEndValue(property: string): number

- - Defined in lib/starling/animation/Tween.d.ts:82

  The end value a certain property is animated to. Throws an ArgumentError if the property is not being animated.

  #### Parameters

  - ##### property: string

  #### Returns number

### Protected get_currentTime

- get_currentTime(): number

- - Defined in lib/starling/animation/Tween.d.ts:111

  #### Returns number

### Protected get_delay

- get_delay(): number

- - Defined in lib/starling/animation/Tween.d.ts:119

  #### Returns number

### Protected get_isComplete

- get_isComplete(): boolean

- - Defined in lib/starling/animation/Tween.d.ts:89

  #### Returns boolean

### Protected get_nextTween

- get_nextTween(): Tween

- - Defined in lib/starling/animation/Tween.d.ts:188

  #### Returns Tween

### Protected get_onComplete

- get_onComplete(): Function

- - Defined in lib/starling/animation/Tween.d.ts:162

  #### Returns Function

### Protected get_onCompleteArgs

- get_onCompleteArgs(): Array<any>

- - Defined in lib/starling/animation/Tween.d.ts:182

  #### Returns Array<any>

### Protected get_onRepeat

- get_onRepeat(): Function

- - Defined in lib/starling/animation/Tween.d.ts:157

  #### Returns Function

### Protected get_onRepeatArgs

- get_onRepeatArgs(): Array<any>

- - Defined in lib/starling/animation/Tween.d.ts:177

  #### Returns Array<any>

### Protected get_onStart

- get_onStart(): Function

- - Defined in lib/starling/animation/Tween.d.ts:146

  #### Returns Function

### Protected get_onStartArgs

- get_onStartArgs(): Array<any>

- - Defined in lib/starling/animation/Tween.d.ts:167

  #### Returns Array<any>

### Protected get_onUpdate

- get_onUpdate(): Function

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

  #### Returns Function

### Protected get_onUpdateArgs

- get_onUpdateArgs(): Array<any>

- - Defined in lib/starling/animation/Tween.d.ts:172

  #### Returns Array<any>

### Protected get_progress

- get_progress(): number

- - Defined in lib/starling/animation/Tween.d.ts:115

  #### Returns number

### Protected get_repeatCount

- get_repeatCount(): number

- - Defined in lib/starling/animation/Tween.d.ts:125

  #### Returns number

### Protected get_repeatDelay

- get_repeatDelay(): number

- - Defined in lib/starling/animation/Tween.d.ts:130

  #### Returns number

### Protected get_reverse

- get_reverse(): boolean

- - Defined in lib/starling/animation/Tween.d.ts:136

  #### Returns boolean

### Protected get_roundToInt

- get_roundToInt(): boolean

- - Defined in lib/starling/animation/Tween.d.ts:141

  #### Returns boolean

### Protected get_target

- get_target(): any

- - Defined in lib/starling/animation/Tween.d.ts:93

  #### Returns any

### Protected get_totalTime

- get_totalTime(): number

- - Defined in lib/starling/animation/Tween.d.ts:107

  #### Returns number

### Protected get_transition

- get_transition(): string

- - Defined in lib/starling/animation/Tween.d.ts:97

  #### Returns string

### Protected get_transitionFunc

- get_transitionFunc(): function

- - Defined in lib/starling/animation/Tween.d.ts:102

  #### Returns function

  - - (number: any): number

    - #### Parameters

      - ##### number: any

      #### Returns number

### hasEventListener

- hasEventListener(type: string, listener?: any): boolean

- Inherited from EventDispatcher.hasEventListener

  - Defined in lib/starling/events/EventDispatcher.d.ts:55

  If called with one argument, figures out if there are any listeners registered for the given event type. If called with two arguments, also determines if a specific listener is registered.

  #### Parameters

  - ##### type: string

  - ##### Optional listener: any

  #### Returns boolean

### moveTo

- moveTo(x: number, y: number): void

- - Defined in lib/starling/animation/Tween.d.ts:67

  Animates the 'x' and 'y' properties of an object simultaneously.

  #### Parameters

  - ##### x: number

  - ##### y: number

  #### Returns void

### removeEventListener

- removeEventListener(type: string, listener: Function): void

- Inherited from EventDispatcher.removeEventListener

  - Defined in lib/starling/events/EventDispatcher.d.ts:35

  Removes an event listener from the object.

  #### Parameters

  - ##### type: string

  - ##### listener: Function

  #### Returns void

### removeEventListeners

- removeEventListeners(type?: string): void

- Inherited from EventDispatcher.removeEventListeners

  - Defined in lib/starling/events/EventDispatcher.d.ts:39

  Removes all event listeners with a certain type, or all of them if type is null. Be careful when removing all event listeners: you never know who else was listening.

  #### Parameters

  - ##### Optional type: string

  #### Returns void

### reset

- reset(target: any, time: number, transition?: any): Tween

- - Defined in lib/starling/animation/Tween.d.ts:44

  Resets the tween to its default values. Useful for pooling tweens.

  #### Parameters

  - ##### target: any

  - ##### time: number

  - ##### Optional transition: any

  #### Returns Tween

### rotateTo

- rotateTo(angle: number, type?: string): void

- - Defined in lib/starling/animation/Tween.d.ts:75

  Animates the 'rotation' property of an object to a certain target value, using the smallest possible arc. 'type' may be either 'rad' or 'deg', depending on the unit of measurement.

  #### Parameters

  - ##### angle: number

  - ##### Optional type: string

  #### Returns void

### scaleTo

- scaleTo(factor: number): void

- - Defined in lib/starling/animation/Tween.d.ts:64

  Animates the 'scaleX' and 'scaleY' properties of an object simultaneously.

  #### Parameters

  - ##### factor: number

  #### Returns void

### Protected set_delay

- set_delay(value: number): number

- - Defined in lib/starling/animation/Tween.d.ts:120

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_nextTween

- set_nextTween(value: Tween): Tween

- - Defined in lib/starling/animation/Tween.d.ts:189

  #### Parameters

  - ##### value: Tween

  #### Returns Tween

### Protected set_onComplete

- set_onComplete(value: Function): Function

- - Defined in lib/starling/animation/Tween.d.ts:163

  #### Parameters

  - ##### value: Function

  #### Returns Function

### Protected set_onCompleteArgs

- set_onCompleteArgs(value: Array<any>): Array<any>

- - Defined in lib/starling/animation/Tween.d.ts:183

  #### Parameters

  - ##### value: Array<any>

  #### Returns Array<any>

### Protected set_onRepeat

- set_onRepeat(value: Function): Function

- - Defined in lib/starling/animation/Tween.d.ts:158

  #### Parameters

  - ##### value: Function

  #### Returns Function

### Protected set_onRepeatArgs

- set_onRepeatArgs(value: Array<any>): Array<any>

- - Defined in lib/starling/animation/Tween.d.ts:178

  #### Parameters

  - ##### value: Array<any>

  #### Returns Array<any>

### Protected set_onStart

- set_onStart(value: Function): Function

- - Defined in lib/starling/animation/Tween.d.ts:147

  #### Parameters

  - ##### value: Function

  #### Returns Function

### Protected set_onStartArgs

- set_onStartArgs(value: Array<any>): Array<any>

- - Defined in lib/starling/animation/Tween.d.ts:168

  #### Parameters

  - ##### value: Array<any>

  #### Returns Array<any>

### Protected set_onUpdate

- set_onUpdate(value: Function): Function

- - Defined in lib/starling/animation/Tween.d.ts:152

  #### Parameters

  - ##### value: Function

  #### Returns Function

### Protected set_onUpdateArgs

- set_onUpdateArgs(value: Array<any>): Array<any>

- - Defined in lib/starling/animation/Tween.d.ts:173

  #### Parameters

  - ##### value: Array<any>

  #### Returns Array<any>

### Protected set_repeatCount

- set_repeatCount(value: number): number

- - Defined in lib/starling/animation/Tween.d.ts:126

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_repeatDelay

- set_repeatDelay(value: number): number

- - Defined in lib/starling/animation/Tween.d.ts:131

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_reverse

- set_reverse(value: boolean): boolean

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

  #### Parameters

  - ##### value: boolean

  #### Returns boolean

### Protected set_roundToInt

- set_roundToInt(value: boolean): boolean

- - Defined in lib/starling/animation/Tween.d.ts:142

  #### Parameters

  - ##### value: boolean

  #### Returns boolean

### Protected set_transition

- set_transition(value: string): string

- - Defined in lib/starling/animation/Tween.d.ts:98

  #### Parameters

  - ##### value: string

  #### Returns string

### Protected set_transitionFunc

- set_transitionFunc(value: function): function

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

  #### Parameters

  - ##### value: function

    - - (number: any): number

      - #### Parameters

        - ##### number: any

        #### Returns number

  #### Returns function

  - - (number: any): number

    - #### Parameters

      - ##### number: any

      #### Returns number

Generated using TypeDoc