user1231561
user1231561

Reputation: 3359

Tweenlite - a sequence chain of TweenLite.to not triggering

Its pretty simple what im trying to achieve. I have a MC on Stage, which im trying to tween to different X coordinates.

I've set up four TweenLite.to sequences, however for some weird reason only one is being triggered - what am I doing wrong?

TweenLite.to(slider.mc_slider,1,{x:_returnXPos(95), ease:menuEasing});
TweenLite.to(slider.mc_slider,1,{delay: 1, x:_returnXPos(35), ease:menuEasing});
TweenLite.to(slider.mc_slider,1,{delay: 2, x:_returnXPos(50), ease:menuEasing});

//Function which returns x coordinate of Sliderbar - related to defined percentage
function _returnXPos(definedPercentage:Number):Number {
    var defineWidth:Number = slider.mc_background.width * (definedPercentage/100);
    return defineWidth;
}

Upvotes: 0

Views: 2747

Answers (3)

Richard Parnaby-King
Richard Parnaby-King

Reputation: 14862

Looking at the code (not at a machine I can test this on) only the last tween is running. If you want them running in sequence you need to specify a call-back function. Unfortunately you cannot use anonymous functions.

TweenLite.to(slider.mc_slider,1,{x:_returnXPos(95),ease:menuEasing,onComplete:nextTween,onCompleteParams:[35]});

function nextTween(newPos:int)
{
    TweenLite.to(slider.mc_slider,1,{x:_returnXPos(newPos),ease:menuEasing,onComplete:finalTween,onCompleteParams:[50]});
}

function finalTween(newPos:int)
{
    TweenLite.to(slider.mc_slider,1,{x:_returnXPos(newPos),ease:menuEasing,onComplete:finalTween,onCompleteParams:[50]});
}

Not the best answer as you are repeating code THREE times. When I get to a pc I can test this on I'll refactor the code into a single function.

Upvotes: 0

Oliver Salzburg
Oliver Salzburg

Reputation: 22099

In addition to what dain suggested, you might also want to check out TimelineLight.

Upvotes: 1

dain
dain

Reputation: 6689

The problem might be that you have to make sure that you're using the OverwriteManager with the right settings, otherwise it might just overwrite your tweens, regardless of the delays, see: http://www.greensock.com/overwritemanager/

Upvotes: 4

Related Questions