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

Pausing and playing timelines

In this lesson, we will integrate a pause and play toggle functionality for our timeline editor.

Video Transcript

00:00In the last lesson, we were introduced to labels of timelines.
00:05We're far from over with that topic, but before we continue with it, I really want to be able to talk about pauses in general.
00:12And we're going to start with just the regular pause play controllers that we've met throughout the tween max, tween light.
00:18So it's going to be a short lesson, and in the next lesson, we're going to move down into actually creating a real pause in the timeline
00:24that will automatically pause when we reach a certain point in the timeline.
00:28But first of all, let's create a pause play controller for our timeline, deeper into the world of labels, which is our main topic of this chapter.
00:36I want to add two more controls, a toggle of pause play and a controller that enables us to pause everything.
00:44So let's start with the toggle of the play pause, because we're going to need that as we dig deeper into labels.
00:50And really, that's where we're going to cross over into tween max, where a lot of the really cool features of labels exist there.
00:57All right, so the first step is I want to create that toggle play pause.
01:01I'm going to go ahead and just add here, maybe before even the replay, I'm going to add here, oopsie.
01:07I'm going to copy that and just add here play pause.
01:13And I'll just call this on, or, you know, let's call this pause.
01:17Let's call this pause, and I'm going to call this on, and we'll just switch it on toggle play.
01:22And I'm going to go ahead and just create that on toggle play.
01:30And let's just put that somewhere above on replay right before that function on toggle play.
01:42And it's simple because we've met it before.
01:44I'm just going to go to the pause.
01:47Oh, we even have it right here.
01:51So I'm just literally taking the pause, but what I want to do is I just want to switch it no matter what.
01:55And I'm just going to go ahead and just call the pause inside of the pause and switch the value that comes back.
02:04All right, so that way we're switching our pause position.
02:07Now, again, because we're getting the jQuery object that has actually the button itself,
02:12I could go ahead and switch the copy itself based on the current pause condition after we switched it.
02:18So I could literally just ask if we are paused, then right here play.
02:22If we are playing, then right here pause.
02:24All right, so this should have now a button that we should automatically change its.
02:32If I just click your refresh, we should have a pause button.
02:35Makes sense. I'm going to add a few items.
02:37One, two, three.
02:42And if I go ahead and just play around with it for a bit, move it around, play with it,
02:48and I go ahead and I replay it and I click on the pause, I could pause the state,
02:53play it any point that I want that I could just replay and play it whenever I want to.
02:58Beautiful.
02:59Now, the next step that I want to do in the next video, it's also add a pause state,
03:04which means that it will just automatically pause at a specific point.
03:07And what I'm going to do is I want to go to the specific label that I'm in and say,
03:11I'm going to pause right here as well.
03:13So we're going to look into that immediately.

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!