00:00Now, another item I want to talk about when we're talking about variables is that we have
00:05to define them.
00:06If we try to work with a variable, such as let's say e, and try to put a value into it,
00:11we never define that variable.
00:14And because we never defined it, if we try to run that application, it's going to give
00:17us an error telling us access to an undefined property e, which basically means that we
00:22did not define this variable.
00:25Flash does not understand what that is, it didn't store room and memory for that variable.
00:33Let's look a little bit deeper into the way we build our variables.
00:37So we said we have to state the word var, and then put a space, and then define our variable.
00:44We could have if we wanted to end it in this place, and just create our variable e.
00:49Now in ActionScript 2, that's completely legitimate, but in ActionScript 3, it's preferable not
00:55to do that.
00:56Because it would waste Flash's energy trying to figure out what that variable is, and at
01:02the same hand, it would make our development much harder, because then it would be hard
01:06for us to know if there's a number, or a string, or a different type of value in our variable.
01:13And if we don't know what type of variable we have in there, the compiler as we compile
01:17will not be able to give us accurate errors.
01:20So if I publish our file right now, we'll see that I'm not getting any errors right
01:24now, because I'm not in a strict mode.
01:26But in different modes, we're going to get not errors necessarily, but alerts telling
01:34us that our variable wasn't defined properly.
01:36But in this case, we're not getting any alert.
01:39And that's a problem, because if I go into my variable e, and I put into the value 3,
01:44and then the next item I put inside of it by mistake a string, such as my name, and
01:49I run the application, there will be no error.
01:53Well if I would tell Flash that I want only numbers to be inside of this variable, and
01:59I run the application again, Flash will be smart enough to let me know that I've made
02:03a mistake that I've put a different type of value than I've wanted to into the variable
02:07e.
02:08So if I run the application again, it's going to prompt me, and tell me implicit correction
02:13of a value of type string to an unrelated type number.
02:17OK, so it's very important for us to state what type of variable we're working with.
02:24Let's look at another few options with working with defining variables.
02:28Now we could define a variable, such as e as a number.
02:32And if we wanted to, we could have typed comma space, and added another variable, even
02:38of a different type, such as s as a string.
02:41And that's completely legitimate, and when we're done, we could end up with a semicolor.
02:47Now with that said, it's not really recommended to work this way.
02:50One, because it's not very readable, and we want to make our code as legible as we can.
02:56And two, it makes it, it's a very, very minute problem, but it makes Flash work a little
03:00bit harder by us not giving Flash one command per line.
03:05And basically, we're asking Flash to do two things in one line, and preferably it's
03:09better off always to tell Flash to do only one thing at a time.
03:13We always end our commands, and when we tell something to Flash, we always end that
03:18command with a semicolon, kind of letting Flash know that this is the end of the line.
03:25Now, if you don't put a semicolon, Flash is smart enough to silently figure things out.
03:32But it's a standard, and a lot of languages request you to add a semicolon, so
03:37try to make sure that you always add a semicolon and an end of a line.
03:40So we've seen how we could add multiple variables in one line using one var
03:46definition, and we said we don't really recommend it.
03:50So for example, another way to illustrate why we do need the semicolon is,
03:56for example, we could say, we could type our variables this way as well.
04:01We don't have to define a new var, and this is legitimate.
04:04This is all considered one line for Flash.
04:07Flash is going to deal with this at one time.