Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

TweenMax.getTweensOf()

TweenMax.getTweensOf( target:Object, onlyActive:Boolean ) :

[static] Returns an array containing all the tweens of a particular target (or group of targets) that have not been released for garbage collection yet which typically happens within a few seconds after the tween completes.

Parameters

target: Object

The target whose tweens should be returned, or an array of such targets

onlyActive: Boolean

(default = false) — If true, only tweens that are currently active will be returned (a tween is considered “active” if the virtual playhead is actively moving across the tween and it is not paused, nor are any of its ancestor timelines paused).

Details

Returns an array containing all the tweens of a particular target (or group of targets) that have not been released for garbage collection yet which typically happens within a few seconds after the tween completes. For example,TweenMax.getTweensOf(myObject) returns an array of all tweens of myObject, even tweens that haven't begun yet.TweenMax.getTweensOf([myObject1, myObject2]); will return a condensed array of the tweens of myObject1 plus all the tweens of myObject2 combined into one array with duplicates removed.

Since the method only finds tweens that haven't been released for garbage collection, if you create a tween and then let it finish and then a while later try to find it with getTweensOf(), it may not be found because it was released by the engine for garbage collection. Remember, one of the best parts of GSAP is that it saves you from the headache of managing gc. Otherwise, you'd need to manually dispose each tween you create, making things much more cumbersome.

TweenMax.to(myObject1, 1, {x:100});
TweenMax.to(myObject2, 1, {x:100});
TweenMax.to([myObject1, myObject2], 1, {opacity:0});

var a1 = TweenMax.getTweensOf(myObject1); //finds 2 tweens
var a2 = TweenMax.getTweensOf([myObject1, myObject2]); //finds 3 tweens
Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×