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

Delaying function calls

Although the main purpose of this animation library is animations, there are some very useful functionalities that relate to time hidden inside. In this lecture, we will see how we can use the delayedCall method to trigger functions at any given time.

Video Transcript

00:00We are getting incredibly closer to the end of chapter two, but before that there's a couple more topics that we want to cover so
00:08Let's start with the basic. Well now basic everything is basic, but fun. Nothing is basic. Let's not say even that word
00:14That's such a silly word. Let's not use that word
00:16All right
00:16So the next thing we want to talk about is if you want to call you don't have to only create an it's not only
00:21An animation tool tween light tween on tween maps. It also enables you to
00:27sequence calls of different methods
00:29For one for example if you want to delay a call for a specific function the way you would do that for example in our case
00:35Where we're calling here step one if we didn't want to call step one immediately
00:40But create a small delay of let's say a second before we call it
00:44Then we would be able to call the tween light and delayed call
00:50the
00:51Laid call and we would say how much of a delay again if it's seconds or frames
00:57Less less than you notice here. They use frames is if we want to use frames, but really usually I'll use seconds
01:02I'm going to put here a one-second delay the callback. I want to call is my step one and
01:08The function the property I want to send to it is my MC logo, but I have to send it inside of an array
01:15so it's MC logo and
01:17I'm gonna ignore the use frames because I don't really want to change it and the default is use functions
01:23So there we go. That's all I have to do and that will create that one second delay
01:28Delayed call for my MC tween now notice
01:32It's probably wasn't very noticeable
01:34But our application started with my logo in the center if I had a problem with that position
01:39Then I would probably want to change that now
01:43Specifically specifically by the way one of our problems with our animation right now
01:47Let me just also get rid of that trace because we don't need it anymore
01:50This call that basically reset our position and position that where we wanted it to be
01:57Really didn't need to happen more than once so if we wanted to we could have moved that step and put it kind of
02:03Just right next to our delayed call because we really don't need to call this method more than once
02:09And if we wanted to we could create some sort of animation or you know
02:13Like we wanted to we could have created a slight delay now that we have your short period of time
02:17We could do a delay of dot five
02:20Dot four I wrote so that forward let it be and it'll take us two seconds to get to its starting position
02:25And then it'll start animating so giving it let's say give it a zero dot three
02:30So we'll have a zero that three seconds to stand in its location. Well, let me see. Oh cuz I'm doing this
02:35There's no such thing as this
02:37Beast so let me just put your MC logo because we're outside of that function. So this doesn't exist at this location and
02:44Like so let's run it one more time. We'll see that it our logo plops into its place
02:49It's a nice little clean animation. It holds there for a sec a second and then moves on now, obviously the for our
02:57The the speed issue here is really annoying that ease
03:01So I'm just gonna get rid of that ease for now because I don't feel like I really need it for this specific animation
03:07But if I did want to use some sort of a ease I would probably have to put those eases separately between those elements
03:13So there we go. That's it. That's about well, that's it about the late call another method another function that will help you
03:21Creating your animation. Sometimes you don't want to do a specific animation
03:24You just want to delay a call to a specific function and you use the delayed call method to do that
03:29Instead of creating a new set interval or instead of creating a new time class
03:34Time object. Alright, so that's it for delayed call in the next video in the next lectures in the lecture
03:42We're gonna be talking about killing things
03:43So if it's the killing of the tween itself or the killing of everything related to that object, so we will see that
03:51momentarily

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!