Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
darngooddesign

Resuming a paused tween [SOLVED]

Recommended Posts

I'm looping a MC

TweenMax.allTo([counterMC6.numbers4], 1, {y:-600, repeat:140, delay:1.5, ease:Linear.easeNone} );

 

I have another button that pauses it.

TweenMax.allTo([counterMC6.numbers4], 0, {paused:true, overwrite:true} );

 

How would I resume the repeating animation? Do I have to nest it in another Tween and pause/resume that Tween? I don't want to loose the number of times it has already repeated.

Link to comment
Share on other sites

Never mind, I just figured it out:

 

TweenMax.pauseAll();

TweenMax.resumeAll();

 

Do exactly what I want.

Link to comment
Share on other sites

Actually, I'd recommend doing it this way:

 

var group:TimelineLite = new TimelineLite();
group.appendMultiple( TweenMax.allTo([counterMC6.numbers4], 1, {y:-600, repeat:140, delay:1.5, ease:Linear.easeNone}) );

//then to pause the whole group...
group.stop();

//and to start playing...
group.play()

 

You could even reverse() or add labels, whatever. Tons of possibilities. http://blog.greensock.com/v11beta/

Link to comment
Share on other sites

Another question then...

 

The numbers4 MC contains numbers stacked on top of each other and the tween moves them up in front of a box:

 

0

1

2

3

4

5

etc

 

When the animation runs its fine, but when paused I would like the mc to snap to increments of 60 so the numbers are centered.

 

Is this going to be hugely complex?

Link to comment
Share on other sites

Are you saying that when you stop() the tweens you want to at the same time force all the MovieClips to have a "y" coordinate that is a multiple of 60? So they'd just suddenly jump there?

Link to comment
Share on other sites

yes. but a relative y position. They would snap to the closest increment of 60.

Link to comment
Share on other sites

It'd be easy to make 'em jump there and stay, but if you want to be able to play() your tween from that new spot and maintain all the existing tweens and their repeat counts, etc., it's definitely more challenging. You'd need to do the math to figure out the time at which they'd hit the next 60 coordinate, and have your timeline skip to that time (group.currentTime = whatever). But it looks like you don't even have them going at the same pace - if they're all stacked on top of each other yet they're tweening to exactly the same y coordinate, that means the ones that are further away will travel faster. That also means that it's extremely challenging to find exact times when they all line up on increments of 60. In fact, it may never happen. Maybe I'm misunderstanding you, though.

 

I'm pressed for time on another project right now, so I don't have time to come up with the algorithm. Sorry.

Link to comment
Share on other sites

I wasn't expecting you to come up with that algorithm however I am having an issue with the code you suggested.

 

var group:TimelineLite = new TimelineLite();

onCounterBtn{
group.appendMultiple([
TweenMax.allTo([counterMC6.numbers2], 50, {y:-600, repeat:1, delay:4, ease:Linear.easeNone}),
TweenMax.allTo([counterMC6.numbers3], 5.1, {y:-600, repeat:20, delay:2, ease:Linear.easeNone})
]);
}

onPauseBtn{
group.stop();
}

onPlayBtn{
group.play()
}

 

The play pause buttons don't work and I'm getting this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock::TimelineLite/insert()
at com.greensock::TimelineLite/insertMultiple()
at com.greensock::TimelineLite/appendMultiple()
at 10518_10_SalesMap_5Tabs_091609_fla::exhibit5_4/onCounterBtn()

 

I understand your deadline, so just post when you have time.

 

Cheers

Larry

 

 

 

PS. Using the TweenMax.pauseAll(); and TweenMax.resumeAll(); the issue I was having was that while it didn't stop the elapsed time. by that I mean:

 

Lets say I paused at 1:00 and resumed at 1:30, when I would press resume the tweens would continue from 1:30. This presents a problem as I'm using a lot of delay's, and I needed to be able to pause the timer so it doesn't matter how long leave it paused, it will resume exactly where I left off. Hope that makes sense.

Link to comment
Share on other sites

You added extra brackets around the TweenMax.allTo() calls. Remember, TweenMax.allTo() returns an Array of tweens. So you were passing arrays within arrays. I also assume your numbers2 and numbers3 were arrays themselves, right? In that case, it should be:

 

onCounterBtn {
   group.appendMultiple( TweenMax.allTo(counterMC6.numbers2, 50, {y:-600, repeat:1, delay:4, ease:Linear.easeNone}) );
   group.appendMultiple( TweenMax.allTo(counterMC6.numbers3, 5.1, {y:-600, repeat:20, delay:2, ease:Linear.easeNone}) );
}

Link to comment
Share on other sites

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@13f4b81 to Array.
at 10518_10_SalesMap_5Tabs_091609_fla::exhibit5_4/onCounterBtn()

 

What kind of thing can do that?

 

Will tweening buttons in the group do it? I think they were casing an issue so I commented them out ad got the above error. The only complex code I have in these tweens are a couple of renderImmediately:false.

 

The number2, numbers3 are static MCs that are being tweened. They were in brackets earlier because I was trying a different angle.

Link to comment
Share on other sites

Oh, okay, then if you're just tweening one mc with each tween, then don't use allTo(), use to(). Like this:

 

onCounterBtn {
   group.append( TweenMax.to(counterMC6.numbers2, 50, {y:-600, repeat:1, delay:4, ease:Linear.easeNone}) );
   group.append( TweenMax.to(counterMC6.numbers3, 5.1, {y:-600, repeat:20, delay:2, ease:Linear.easeNone}) );
}

Link to comment
Share on other sites

TweenLite.to(TweenMax, 0, {globalTimeScale:?});

 

How would I apply something like that within a specific MC? That way i can just set the timescale to 0 which pauses everything, including the elapsed time, and still lets my Tweens in the other tabs function as normal.

Link to comment
Share on other sites

I tried that, but none of my group.tweens start.

 

Please post a sample FLA that demonstrates the issue. You're using AS3, right? And what version of TweenLit/Max/TimelineLite/Max?

Link to comment
Share on other sites

  • 3 weeks later...

I'm using the most recent version of AS3 TimelinMax.

 

The counter pause is in Exhibit 5. Currently, when you click the pause button the red square still Tweens away after five seconds. I tried setting GlobalTimeScale=0, which worked for the play/pause btw, but then none of the Tweens in Exhibit 1, for example, worked. Also, in the tabs layer I was Tweening the tint, but that no longer works. I commented out those Tweens, but what replaces them?

 

http://www.darngooddesign.com/PauseTest.zip

Link to comment
Share on other sites

I'm using the most recent version of AS3 TimelinMax.

 

No you're not - you're using extremely outdated versions of all the classes. In old versions, TweenLite tweens could not be paused. Only in recent weeks has that capability been added. Had you used a TweenMax tween on the red square, pauseAll() would have been effective. But if you update to the latest version (http://blog.greensock.com/v11beta/), it seems to work great even with TweenLite (now that the pause() capability has been added).

 

Does that clear things up for you?

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.
×