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_ba开发者_Go百科ckground.width * (definedPercentage/100);
return defineWidth;
}
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/
In addition to what dain suggested, you might also want to check out TimelineLight.
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.
精彩评论