Toggling the direction of the animation
Toggling the direction of animation playback between going forwards or backwards is possible in TweenLite. TweenLite comes built in with the capability to animate backwards using the reverse command, or forwards using the play command. In this lesson, we will create a toggle button that will change the current direction of our animation.
Video Transcript
00:00We just saw her how to use the pause and how was a toggle kind of button
00:04There's one more toggle which is called reverse that works in a similar way
00:08And what I want to do next is I'm gonna because I already split my animations between my X and my Y
00:12I'm gonna align them back to the same duration. But what I'm gonna do is I'm gonna change the on complete
00:19Parameters. Well, I'm gonna get rid of the on reverse complete
00:23Well, and that can get rid of it completely, but I'm gonna create here an on
00:27On
00:29Sam on on on on on reverse reverse
00:36Direction on reverse direction that is gonna be for our on complete that is gonna be also for our on reverse complete
00:43So I'm gonna call the same method and I'm only doing that for our second animation. So I'm gonna create that quickly private function on
00:52Click. Oh
00:54Sorry, what am I doing?
00:55On reverse direction and we're on reverse direction. We're gonna get the tween itself and we could go to that tween and
01:06We could reverse it. So first of all, we want to see what is the reverse?
01:11So one is we could call just reverse that reverse will automatically just switch it wherever direction it was in
01:18It's just gonna reverse the direction that it was in
01:21Notice how that doesn't work because reverse always goes in one direction
01:25But because we want to also we said we have a reverse or we have play
01:29What we want to do is we want to go to this instead of reverse and we're gonna call reversed
01:34We're just gonna ask it. What is its current direction?
01:37We're just gonna trace it out for a second just like we did with our
01:41Current animation remember and we see here. It's false now that we know that it's reversed. We want to toggle it
01:46So again, we're gonna do the exact same thing and we're just gonna put it inside of our reverse the command to do
01:52The exact opposite of what it's at the exact same thing as we did with our pause if we run it one more time
01:58We'll see that now it's working honky-dory perfectly and once it's reversed once it's not and we've created this
02:05toggle ness basically making these two functions
02:10These two methods just not needed because this one does the job of both of them just because we use the reversed method
02:17now I want to talk briefly about the things that we're not gonna be talking about before we move on to the
02:22Next topic now, I'm gonna quickly just show you a couple stuff
02:25We're not gonna talk about and you could follow up on them on your own. They're really easy
02:29So one is in our tween light. There's also a property called default override
02:34We're not gonna talk about it because basically you saw what overrides is
02:38We spent a lot of time on it
02:39The default override enables you to set a default for all your animations if you want to set it in a different type of override
02:46as your default
02:47Now beyond that and I'm just gonna create here quickly. Oh, you know, let me just go to this
02:52tween that we have here and I'm talking about a few properties that a few methods that we're not gonna be talking about one is the
02:59delay method and
03:00The delay method or return to the amount of delay this animation has or you could actually set a delay to it
03:07So for example, if we wanted to we could say hey, let's add a one-second delay into this tween
03:15Notice how it stops and then goes stops and then goes very funky stuff
03:19So I'm not gonna go over all the different
03:22Properties, but these are the exact same properties that you worked with that we added them such as duration
03:27Well duration itself was the property of the amount of time
03:30We could literally or get the amount of time or change the amount of time same goes for our
03:36Event callback we could add or change our event itself by calling the tween
03:42Event callback and then just add the string the callback name itself
03:46For example the complete or the reverse and then we could change the callback and send different parameters to it on the fly
03:53So we're not going to talk about this ring. I'm gonna leave this open because you need to fill them up
03:58You're welcome to play around with them and look them up
04:01So those are the methods that we're not going to look into not because they're hard
04:05But just because we don't want to waste your time
04:07So we're just going to talk about them really quickly now
04:09So you're aware of them look into them and in the following video
04:12We're going to continue looking at a couple of more things that we could do with Queen Light
