Jump to content
Search Community

Tween Pausing

archonic test
Moderator Tag

Recommended Posts

I'm making a XML banner rotator and recently introduced TimelineLite. I started using it since the flash.utils.timer doesn't have a pause() method (which is totally ridiculous). I ended up ridding of the timer completely since there's an onComplete param for the timeline. Here's what I'm trying to do:

 

http://dev.archonic.com/mint/HomepageBa ... index.html

 

Pretty self-explanatory. When the mouse hovers above the container, the timer (which is now just a TweenMax tween) pauses. Mouse off and it resumes. Then when the tween is done, the same thing happens with the next banner. As you can see it's not quite doing that.

 

Every time a slide is loaded, a function is called to update the colours of the navigation items (called updateNavColours):

function updateNavColours():void {
		//Idle colours
		for(var i:uint = 0; i				if(i != current) {							
				TweenMax.to(navItems[i].navNum_bg, 0, {tint:navBG_IDLE, scaleX:1, scaleY:1, overwrite:true})
				TweenMax.to(navItems[i].num, 0, {tint:navTXT_IDLE});
				TweenMax.killTweensOf(navItems[i].navShine_mc, false);
			}
		} 

		//Selected colour
		TweenMax.to(navItems[current].navNum_bg, 0.2, {scaleX:1, scaleY:1, tint:navBG_SELECTED});
		TweenMax.to(navItems[current].num, 0.2, {tint:navTXT_SELECTED});
		navTimeline.insert( TweenMax.from(navItems[current].navShine_mc, slideData[current][2], {width:0, ease:Linear.easeNone}) );
		navTimeline.resume();
	}

 

I've tried using navTimeline.killTweensOf, navTimeline.append, adding a label at the end of the tween and using gotoAndStop and gotoAndPlay, removing the tween from the timeline, etc.

 

It was working when the timeline was less involved (used only for pausing on mouse over) and the flash timer called the next slide. I'd could always go back but this seems like a more elegant solution. And I'd like to understand timline lite a little better :)

 

Any ideas?

 

PS - I watched the timeline basics video, very helpful! Is that timeline advanced video you talked of available?

Link to comment
Share on other sites

It's tough to troubleshoot with this limited information - there is probably something else going on in your code. It looks like one problem is that you're inserting your tweens into the timeline all at the very beginning and then resuming which means that after the first one plays, you won't see the others. The playhead starts at zero, then you add the first tween and start going...let's say it takes 2 seconds for that tween to finish. Then when you insert() another 2-second tween at the beginning of the timeline and resume(), the playhead is ALREADY at the 2-second point, so it'll start playing again at the END of the tween you just inserted. See what I mean?

 

Do you mind me asking why you're using a TimelineLite/Max anyway? Usually it's great for controlling a bunch of tweens as a whole, but you're only putting one tween in there at any given time and don't appear to need to reverse() or anything, so why not just do a simple TweenLite or TweenMax instead? You can use an onComplete in those too (as I'm sure you knew).

Link to comment
Share on other sites

I was using timeline lite exclusively for the pause method; something the flash utils timer doesn't have. When your mouse goes over the container, the timer (and tween) will pause, and will resume on mouse roll out.

 

It seems I tried to extends timeline lite's use to something it's not ideal for. I'll go back to what worked :). Thanks!

Link to comment
Share on other sites

You can use a simple tween or TweenLite.delayedCall() for stuff like that...

 

var timer:TweenLite = TweenLite.delayedCall(20, myFunction);
...then later...
timer.pause();
...and then...
timer.resume();

 

That'll even allow you to pass parameters to the function too. And its timing will be perfectly synced with all other tweens that are being managed by the GreenSock platform. But if you prefer using a Timer, that's okay too.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...