Jump to content
Search Community

Tweengroup, one way then another, and repeat.

mrEmpty test
Moderator Tag

Recommended Posts

Hello.

 

I have a question regarding TweenGroup. I have a series of 6 movieclips, I want them to rotate 30 degrees one way, stagger 0.5 seconds between them, then onComplete rotate 30 degrees the other way, same stagger, then repeat.

 

So far it seems I need to call a function on a mouse event to start the first tween series, then call a second function to do the second tween, then call a third function to start the third tween etc etc. Can I simple get TweenGroup to tween one way with stagger, then reverse, with stagger?

 

Regards.

 

E.

Link to comment
Share on other sites

I would STRONGLY recommend that you look into the new TimelineLite and TimelineMax classes in v11. They will replace TweenGroup and they're much more powerful, flexible, and robust. You can even nest timelines within timelines. Check out the insertMultiple() and appendMultiple() because they allow you to align tweens and stagger them pretty easily. And there's also TweenMax.allTo() that can be used in conjunction with either of those methods. It should be pretty easy to get a sequence built with those tools.

 

http://blog.greensock.com/v11beta/

Link to comment
Share on other sites

One more thing, after building my timeline (you can probably guess I sobered up and went back to code) can I simply repeat it endlessly, until I call another tween?

 

EDIT: Ignore me, repeat is the argument I'm looking for I guess. Think the Gin has settled for the evening. :oops:

Link to comment
Share on other sites

Hello.

 

Using this code:

 

swatchWaveTimeline.insertMultiple([new TweenLite(card001, 2, { rotationZ:-25 } ),
											new TweenLite(card002, 2, { rotationZ:-25 } ),
											new TweenLite(card003, 2, { rotationZ:-25 } ),
											new TweenLite(card004, 2, { rotationZ:-25 } ),
											new TweenLite(card005, 2, { rotationZ:-25 } ),
											new TweenLite(card006, 2, { rotationZ:-25 } )],
											0, TweenAlign.START,
											0.2);										

		swatchWaveTimeline.insertMultiple([new TweenLite(card001, 2, { rotationZ:25 } ),
											new TweenLite(card002, 2, { rotationZ:25 } ),
											new TweenLite(card003, 2, { rotationZ:25 } ),
											new TweenLite(card004, 2, { rotationZ:25 } ),
											new TweenLite(card005, 2, { rotationZ:25 } ),
											new TweenLite(card006, 2, { rotationZ:25 } )],
											3, TweenAlign.START,
											0.2);

 

with this timeline var:

 

var swatchWaveTimeline:TimelineMax = new TimelineMax({repeat:-1, repeatDelay:0});

 

works fine, but after the first complete cycle, the movie clips snap back to 0 rotation before going to positive 25, then to neg 25, then snap back to 0 and start again. Do I need to tell TweenMax/Lite to use the current value as the starting value?

 

Thank you.

 

E.

Link to comment
Share on other sites

The first time a tween renders, it determines the starting values and locks them in. That way, if you restart() or rewind to a previous state, it can render correctly. So when your timeline loops back to the beginning, the values will return to where they started. Normally that's what people want. But you can invalidate() a tween (or an entire timeline) and it'll clear out all those values and force them to re-initialize the next time the tween renders.

Link to comment
Share on other sites

No, I think you might be misunderstanding. You don't put invalidate() into a tween or timeline. You call invalidate() on the timeline or tween instance itself in order to clear out all the starting values. So you could use an onComplete in a TimelineLite to call a function that invalidates the timeline and then restarts it (to get the looping effect you're after).

var myTimeline:TimelineLite = new TimelineLite({onComplete:loopTimeline});
myTimeline.insertMultiple(....); //add tweens here
function loopTimeline():void {
   myTimeline.invalidate();
   myTimeline.restart();
}

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