02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Clearing timelines

You can clear out all the animations and all the elements you've added into a timeline by calling the TimelineLite.clear() method. In this lesson, we will explore the TimelineLite.clear method.

Video Transcript

00:00Alright, so we're definitely getting closer to the end of the chapter, and I wanted to dedicate a little bit of time to learn about features in the timeline as well.
00:08So in this lesson, we're going to look at how do you clear an animation and start anew.
00:13And that's what we're going to look at right away.
00:15Start learning a few more tricks, a few more methods, a few more things we could do with the timeline.
00:21And the first thing, well, next thing I want to do is I want to add another controller to enable us to clear the whole timeline and start anew.
00:29So to do that, I'm just going to go back into my application, and I'm going to add a new controller.
00:35So I'm going to go all the way up to our controllers, and I'll go ahead and add a clear command.
00:39And we'll just call this clear, and I'm going to call this unclear.
00:48And let's go all the way to the bottom of our application, and I'm just going to go ahead and create that function.
00:57This will be easier for us to see.
01:08Alright, so how does unclear work? It's very simple.
01:10All we have to do is just call the clear command.
01:12And by calling the clear command, I could literally just get rid of everything.
01:16And if I get rid of everything, and if I just click here, refresh, and I'll just add an item, move it around, play it around, click on replay.
01:25And then I'll click on the clear. I'm not going to get rid of the item, but if I click on replay again, then it's not going to actually do anything.
01:34So what's so about the clear command is that not only does it delete everything, it deletes everything.
01:39And we're going to talk about labels really soon, but it also deletes labels by default.
01:45And we'll see what labels are on a little bit later, and then we'll look at the clear again about how could we not clear the labels if we don't want to.
01:53But before we even do that, I wanted to also talk about our current animation.
01:57And in our case, if I'm just going to add everything, it's always a good idea to test a few things.
02:02So I'm going to have all these items come in.
02:05I'll have all these three items. If I click on replay, they're going to replay.
02:08But what if I just want them to start from that position so I could click on the clear.
02:12And now let's see if things are going to work.
02:14If I click on the auto to disable it, and now I'm going to move my items to a specific spot.
02:21Click on the auto again just to trigger that animation. Will the animation work?
02:26And it sure does. So that's all we had to do with our clear.
02:28We didn't have to do anything else because that information that we were sending in with our element with that last P information has passed through.
02:37And then whenever we cycle through it, we're creating that animation. Beautiful.
02:41That's all we really needed to do to make sure that our clear is working.
02:45And it sure is. And we're done talking about clear.
02:47And in the next lecture, we're going to learn about another functionality of the timeline, another method.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!