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

Initializing our application with null

When we first start our application on a mobile device it looks like hell right now. We got to fix that. We will use a trick in programing enabling us to call the refresh using the null attribute . Let's see how do that before moving to the next video were we continue to debug and improve our application.Ops we got a real bug %u2013 let's fix it before moving forewords.

Video Transcript

00:00Let's sort out the issues that we found once we actually tested it out on a real application.
00:05So first of all, we want to make sure that we get our application to run absolutely from the beginning.
00:10So to make sure that it runs the way we want it to run, I'm going to call it on change even without an event.
00:16So to do that, basically what I'm going to do is I'm going to write underneath in line 15, I'm going to call the on change.
00:21But because I don't really have a stage orientation event, if I don't send anything, it's going to generate an error.
00:27So to avoid this error, I'm going to type null, which now basically means nothing.
00:31But in programming, it means it helps us bypass the fact that we need to send a stage orientation event.
00:37It's kind of like a loop around and basically says to the compiler, we know that we're supposed to send a stage orientation event, but we're not going to.
00:45So it's kind of like us saying it explicitly that we're sending nothing.
00:49So once I call that on change, our application should as soon as it runs the first time center the way it should.
00:55Now, we want to fix just one more thing before we test this out. And that was we noticed when we ran our real application that we missed one line in our inches.
01:03And the way we solve that is making sure that we don't start from zero and we are not starting from zero anymore.
01:09But also that we continue to the full extent of the total inches and not only until one before because we made it smaller than.
01:16So I'm going to set it to be smaller or equal to total inches.
01:19And I'm going to do the same inside of our for loop, making sure that it's going to go through all the way to the end.
01:25And again, we're skipping that first step.
01:27So we're starting from one and we're going all the way to the end because now we basically moved out one step.
01:34Now, one thing and one more thing to note is that we later on will probably probably disable this line twenty eight.
01:41And we'll probably put something else there once we put in the smaller steps, which we'll do in the next video.
01:46But before we do that, let's test it out.
01:48I'm just going to save my application and I'm going to click on that command shift return to get my application to publish on my phone.
01:55And this time around, I'm expecting my application to be to show me the inches correctly and align my logo exactly in the center even before I realign my phone for the first time.
02:06So I'm just going to let it to connect.
02:07And now that it's connected, I'm just going to disconnect my phone here for a second.
02:11And if we look at it again, we'll see that now our phone element is also logo is centered.
02:16But we're still seeing a small little problem that we could see that our inches here are it actually is drawing because it's a complete full inch.
02:24So it's exactly four inches.
02:25And because of that, we barely could see that the line, the last line on the bottom here, which indicates four inches because our device screen is exactly four inches.

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!