Restarting TweenLite animation
The scrubber we created in this chapter controls our animations really well, but not accurately. It ignores delays, as we are manually controlling all the animations. If we had more animations running at the same time, it would be impossible to manage them in the same way. In the next chapter we will solve that problem as we introduce timelines (through the TimelineLite). For now let's return to our animation and restart it.
Video Transcript
00:00We're just about to wrap up this chapter not a long session
00:03We're gonna talk a little bit of more about how to restart our animation and beyond that also to understand
00:08The different functions that exist that tell us more information about where is our animation at currently?
00:14We saw the progress and total progress, but there's a couple more functions
00:18Nothing complicated and once we're done with that we're gonna be ready to move on into our chapter 2
00:24Which is going to be about timeline animations wrap up the first chapter in our advanced animation training
00:31Before we do that. I wanted to talk about a couple more things. So
00:36Let's jump right in there. I'm not gonna go through every single one of these methods
00:39But what I'm gonna do is I'm just gonna paste them down next to our our on anim update and you could basically
00:45Play around with them and see how they work. We worked with the progress function and the total
00:52Progress functions to find out basically how far are we? I don't even know if we use the total progress as yeah
01:00Well, we didn't need to write but anyways, let's let's talk about them
01:04So progress we didn't really need to look at the total progress because it's a it's a matter of
01:10basically
01:12From 0 to 1 right? We had there the value between 0 or 1 for our progress
01:17So you have the function progress gives you where you are currently in a percentage wave between 0 and 1 total progress would be 1
01:25duration on the other on the other is
01:28basically how many seconds have passed versus how many seconds are in total and
01:32Time is how many seconds and total time is how many seconds as well. He might ask yourself and me
01:38What is the difference between duration and time and the different is quite big?
01:42I would say for now work with the time and not the duration until we move into working with tween max animations
01:48Because once we move into animations using tween max also loops
01:53For example, if we have a yo-yo effect that has three yo-yos going on that would take into consideration
01:59Into that duration so the duration would be if our animation was five seconds and we had a yo-yo effect
02:05It would be that amount of time. So literally the duration and total duration
02:11Give us a value that is a lot more accurate if our animation is more
02:16Integrate if we're using those advanced features in tween max
02:20So without further ado what I'm going to do be to wrap up this course
02:23I want to revisit this console area and I want to have this toggle play really work
02:28Oh, so when our element is just not existent anymore
02:32so in our case what I'm going to do is I'm going to wrap up my if condition with the if this item exists because
02:38If we have at least one item
02:41And then we're going to do this loop if not
02:43We could literally skip this whole loop and instead of going through this loop
02:46I'm going to hard code and force my animation to start over again and to do that
02:51I'm just going to approach my element and I'm going to approach the two objects that I've created earlier the tween pan and tween width and
02:59I'm just literally just going to tell them tween pan. I want you to restart
03:04tween with I
03:07Want you to restart as well, and that's it. Once I've configured that
03:11That's really all I had to do because whenever it doesn't find the object it will restart it
03:17So we covered in this lesson seven different functions of tween
03:21Light and it's relatable to tween max as well and also by the way the timeline effects
03:26Which are going to be our main topic of the next chapter
03:29But if I save this and just go to show you that it actually really works is if we click on refresh here
03:34Have our animation complete and when our animation is complete
03:37We'll try to pause it again
03:39Which will actually play it over from the beginning because it was already paused and that's a really great feature because I could pause it
03:47At any point I want here
03:48I could go in my timeline wherever I want to and I could decide okay
03:51I'm here and I want to start playing it now
03:54By the way applies the same way if I go ahead and I move my timeline
03:58I could at any point start playing it again that will all still work because it cross relates to each other
04:05So that's it. We're done with chapter one
04:07I hope you enjoyed it and chapter two is going to jump us right into that world of timelines
04:12So hope to see you there
