malcr001 Posted February 14, 2010 Share Posted February 14, 2010 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 More sharing options...
GreenSock Posted February 14, 2010 Share Posted February 14, 2010 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 More sharing options...
malcr001 Posted February 14, 2010 Author Share Posted February 14, 2010 Do I need some sort of yoyo command in the rewinds functions to specify the amount of time I want it to animate up and down? Link to comment Share on other sites More sharing options...
GreenSock Posted February 14, 2010 Share Posted February 14, 2010 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 More sharing options...
malcr001 Posted February 14, 2010 Author Share Posted February 14, 2010 Is there a way of getting it to repeat a specified number of times? Link to comment Share on other sites More sharing options...
GreenSock Posted February 14, 2010 Share Posted February 14, 2010 Is there a way of getting it to repeat a specified number of times? Sure - that's what the "repeat" value is for. If you want it to repeat twice, you set repeat to 2. var timeline:TimelineLite = new TimelineLite({onComplete:rewinds, repeat:2}); Have you seen the documentation? http://www.greensock.com/as/docs/tween/ Link to comment Share on other sites More sharing options...
malcr001 Posted February 14, 2010 Author Share Posted February 14, 2010 Is there a way to play a sound after each append tween? Link to comment Share on other sites More sharing options...
GreenSock Posted February 15, 2010 Share Posted February 15, 2010 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 More sharing options...
malcr001 Posted February 15, 2010 Author Share Posted February 15, 2010 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? Link to comment Share on other sites More sharing options...
GreenSock Posted February 15, 2010 Share Posted February 15, 2010 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 More sharing options...
malcr001 Posted February 15, 2010 Author Share Posted February 15, 2010 thanks the first option worked for me Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now