Jump to content
Search Community

yoyo

malcr001 test
Moderator Tag

Recommended Posts

HI I have an animation that takes place one after the other how do I use yoyo after the last animation has completed?

 

var timeline:TimelineLite = new TimelineLite({onComplete:rewinds});

 

//Tweening movieclip file from one movieclips x, y position to another

timeline.append(new TweenMax (file, 2, {dynamicProps:{x:getNode1XPosition, y:getNode1YPosition}}));

timeline.append(new TweenMax (file, 2, {dynamicProps:{x:getNode2XPosition, y:getNode2YPosition}}));

timeline.append(new TweenMax (file, 2, {dynamicProps:{x:getNode3XPosition, y:getNode3YPosition}}));

timeline.append(new TweenMax (file, 2, {dynamicProps:{x:getNode4XPosition, y:getNode4YPosition}}));

Link to comment
Share on other sites

You define yoyo in the constructor's vars object, like this:

 

var timeline:TimelineLite = new TimelineLite({onComplete:rewinds, yoyo:true});

 

But be careful because dynamicProps makes the properties completely dynamic on every frame, so it's not like a normal tween that you can just play backwards.

Link to comment
Share on other sites

When yoyo is true, it will just go back and forth - you don't set the amount of time for yoyo. For example, if you have 3 tweens that are 1 second each in your timeline and they're sequenced (play back-to-back), your entire timeline would be 3 seconds. When it yoyos and goes back towards the beginning, it will take 3 seconds as well. Please watch the video at http://www.greensock.com/timeline-basics/ if you haven't already - I think it might clear things up for you.

Link to comment
Share on other sites

Sure, you can use an onComplete for each tween that calls a function that plays a sound. Or addCallback() at the various spots where you want it played. Keep in mind that if you want to append a callback, it's as simple as myTimeline.addCallback(myFunction, myTimeline.duration);

Link to comment
Share on other sites

Hi im trying to use youre example to apply what is shown on the first post that shows the code but cant get it to work could you make an example using my first post?

 

 

var timeline:TimelineLite = new TimelineLite({onComplete:rewinds});
timeline.append(new TweenMax (file, 2, {dynamicProps:{x:getNode1XPosition, y:getNode1YPosition}, onComplete:playSound}));
timeline.append(new TweenMax (file, 2, {dynamicProps:{x:getNode2XPosition, y:getNode2YPosition}, onComplete:playSound}));
...
function playSound():void {
   //your code here to play the sound.
}

 

-Or-

 

var timeline:TimelineLite = new TimelineLite({onComplete:rewinds});
timeline.append(new TweenMax (file, 2, {dynamicProps:{x:getNode1XPosition, y:getNode1YPosition}}));
timeline.addCallback(playSound, timeline.duration);
timeline.append(new TweenMax (file, 2, {dynamicProps:{x:getNode2XPosition, y:getNode2YPosition}}));
timeline.addCallback(playSound, timeline.duration);
...
function playSound():void {
   //your code here to play the sound.
}

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