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

Runtime Error

Like anything that is live - there are bound to be errors - let's see how we deal with them and figure out how to solve them.

Video Transcript

00:00So, our loader info contained that as well, but the loader info contained all of the information
00:06inside of Flash, okay? Everyone's with me still. So, basically, when something loaded,
00:11all the information was inside of the loader info. It's not extremely intuitive, so I'm
00:16really, really happy to any that you came up with it, because that's not an easy thing
00:19to come up on your own. But the loader info would actually contain all this information.
00:27Like, remember, the loader info contained a lot of information. So, actually, if we wanted
00:32to follow the content itself, and that's what we want to do, we want to follow the content
00:37itself, not the movie clip that's holding the content, which is the loader. We actually
00:43want to follow the content. If we want to follow the content, then we want to go to the loader
00:47info. And in that loader info, now we can start asking all the questions we want, such as adding
00:54an event listener, and now we could ask for an event complete. Well, when we try to ask this,
00:59and actually, this is really, really good, because the hints in CS5.5 look really wicked. So,
01:04add event listener, if we did it directly, doesn't even have your complete, right? So,
01:08it is very accurate. Well, if we go to our image one, and then we go to dot our, actually,
01:14our loader info, then we add an add event listener. We'll see that now we're getting
01:20all these stuff that are relevant to loading. So, we see here that, finally, we're getting
01:24stuff as such as complete, initialize, open, unload, error, progress, all right? And progress
01:32is an important one that we're going to be working on in a minute, okay? So, now we have
01:37a complete. So, we could actually add an event complete, which will then add us in the flash
01:41dot events, that event, and we're going to add a listener, so it's going to be on complete.
01:48All right? So, on complete, we're going to call that function. So, we're going to create
01:51a private function. It's going to be on complete. It's going to be an event type,
01:56because that's the type of event that was sent. It's not going to return anything.
02:02And we can already now just trace out that event and just see that when our image will complete
02:06loading, it's going to call that event. So, first, let's fix whatever error we have here.
02:10Cannot access a property or method of a null object reference error 109. Now, this is a great
02:17place to sort out. First of all, this error is really useless, right? Because we don't really
02:20know where the error is happening. Let's sort that out. So, if I go into my FLA, I'm going to
02:25go into my file, publish settings, and I'm going to go into my flash tab. Now, this looks a little
02:32bit different if you're working on a different version of flash, but if you just go into your
02:35Swift and just search for permit debugging and click on okay in your Swift tab, it might be up
02:40here if you're in the earlier version of flash, and just click okay. As soon as we do that,
02:45now when we're going to get the errors, it's going to actually tell us where in our code
02:49we made a mistake. So, we can see that it's in line 16. So, now I could go to line 16, and I'll
02:54see, oh, okay, we have here an image. We have here, sorry, not an image, we have here an issue.
02:59So, first of all, cannot access a private or method of a null object reference.
03:05Oh, not loader info. My, my bad. You see that? And that's where, that's where, you know, like,
03:11your answers was really good, but actually, yeah, definitely. And we'll create a quick just
03:17sample of that, but I actually made a mistake. So, let me just take a step back. The loader info
03:22actually is not actually in existence yet. That's why we're getting this error. So, if I go into my
03:27trace, image one, and I just dot loader info, and I trace this out, we're going to see that
03:43we have our loader info. But if I try to go to maybe add event listener, let's see what happens.
03:48And this time you do these deep, oh, sorry, that was wrong. I put it, didn't put it here a dot.
03:53And because I didn't put a dot, I got the loader info of my movie clip instead of the image one
03:57that I wanted. And I will see that, boom, it's bringing back null. So, I made a mistake. So,
04:03but even though I made a mistake, it's a great, it's a great mistake to make. Now,

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!