Sorry, I should have explained that first. Ok here goes. I have a row of thumbnail images which use the ENTER_FRAME event to move to the left or to the right depending on mouseX. I wanted to stop this movement when the beginning/end is reached using tweens:
var myTimeline:TimelineMax = new TimelineMax();
myTimeline.append(new TweenMax(thumbnailBar, 0.2, {x:0, ease:Quad.easeOut, paused:true, overwrite:0}));
myTimeline.addLabel("smoothLeftScroll", 0);
myTimeline.append(new TweenMax(thumbnailBar, 0.2, {x:(thumbnailArea.x - thumbnailBar.width + thumbnailArea.width), ease:Quad.easeOut, paused:true, overwrite:0}));
myTimeline.addLabel("smoothRightScroll", 0.2);
function thumbGallery(e:Event):void
{
/*
some code here
*/
if (thumbnailBar.x > 5.7 * prevDiff && prevDiff < 0) // beginning reached. prevDiff < 0 means thumbnailBar moves to the left.
{
myTimeline.gotoAndStop("smoothLeftScroll");
myTimeline.tweenTo("smoothRightScroll");
}
else if (thumbnailArea.x - thumbnailBar.width + thumbnailArea.width - thumbnailBar.x > -5.7 * prevDiff && prevDiff > 0) // end reached
{
myTimeline.gotoAndPlay("smoothRightScroll");
}
else
{
thumbnailBar.x -= prevDiff;
}
var a:Array = myTimeline.getActive();
for (var i:Number = 0; i < a.length; i++) {
trace(a[i].target + " is tweening");
}
}
I'm guessing this does not run properly because "myTimeline" is called multiple times. "TweenMax(thumbnailBar, 0.2, {x:0, ease:Quad.easeOut, paused:true, overwrite:0})" doesn't seem to help either. So my idea was to use "getActive()" and call "myTimeline" only when there are no tweens running already.