actionscript-3tweentweener

ActionScript - Remove Tweener Tweens onComplete?


for occasional tweens, such as those triggered/added by a button, is it a best-practice to remove the tween – Tweener.removeTweens(myObject); – or does Tweener automatically do this when the tween finishes?

i understand tweens automatically overwrite themselves, so perhaps it's not useful (not encouraged) to remove occasional tweens, but what about infrequent tweens?

if Tweener doesn't automatically remove tweens when its finished with them, wouldn't the objects that Tweener is referencing not be able to be garbage collected if removed?


Solution

  • Indeed,

    private static function updateTweens ():Boolean {
        ...
        if (!updateTweenByIndex(i)) removeTweenByIndex(i);
    }
    

    updateTweenByIndex returns false when the tween is over. The TweenListObj referencing the tweener's target is thus deleted (spliced) and the target may be garbaged.