Things That Have Names
lets review things that have names in flash so we can then figure out how to separate between them.
Video Transcript
00:02Bingo. Alright, so we don't get it, but not only classes, okay? So there's a few different things that we want to recognize.
00:10Yeah, okay, so Adam and Tani, perfect. So let me just spill out the type of things that we worry about when we're working in object-oriented programming, okay?
00:22So we have a few different things. Let's list them out. Let's start with that. Can you guys just list out the type of things that have names in code that you know about so far?
00:35So we said packages have names. Functions have names. Thanks, Tani.
00:40Linkage names are actually classes, because they're names of classes. Okay, good. That's classes.
00:56Yeah, definitely everything, but we definitely could list it out. So let me just write that down as you're typing it.
01:01So you guys said, you said functions. Well, I said packages, right? Packages.
01:08Tani said functions, and I'll add functions and variables, right? Which is kind of like in the same group.
01:16And then we said classes, right? Methods, yeah, and I'm going to include methods and properties inside of the functions and variables.
01:31Methods and properties, because it's not that they, it's the exact same thing, but they're quite, quite similar. Well, their syntax is exactly the same.
01:40Now, library names, absolutely. Library names. And you know what, Tani, I'm going to add what you said. Library linkages.
01:51Which is, they are classes, but we're going to have some sort of difference between them.
01:57Welcome, Carol. All right, so let me just do a quick summary for Carol, also, and welcome back.
02:10So we were talking about object-oriented programming. We're kind of like stepping through the things that exist.
02:19And we were asking, what type of things have names in object-oriented programming?
02:24So so far, we said that there are packages, there are functions and variables, which are methods and properties.
02:29That's how we call them in object-oriented terminology. We have classes. We said we have library names, which isn't exactly object-oriented, right?
02:38It's part of Flash, so we're not going to ignore it. And then we have library linkages.
02:42Let me just ask a quick question before I add one more thing that we didn't learn about yet, or two more things that we haven't really touched, okay?
02:50So let me ask first, what is actually the difference between a library name and a library linkage? Does anyone know?
02:56Love it. Love it. Excellent. And that's exactly the answer. So if we just look at the library just for a second,
03:24we have here our library elements, and we have here one that's called ball, and the second one that's called ball2.
03:31But they don't have a class. They do have a class, but we don't have access to it.
03:36This name is just a name for the stage, just a name for the library, so we could recognize it between the visual elements in the library.
03:43So this is our library name. But when we right-click into it and we go into the properties of it, then we find that linkage when we export to ActionScript.
03:52And only then they ask us, okay, so what class do we want to give it? That is going to be our linkage.
03:57Now, let me ask you a question. So why did Flash make our lives more complicated, right?
04:02Why couldn't they just have it automatically, whatever you have in the library, whatever it's called, that would be its class as well?
04:08Does anyone have a, even though we didn't learn about it, just have a guess.
04:12Why did they make that separation? Is it to make our lives more complicated, or do you think there's some sort of extra bonus there hidden that we're going to be learning about in a couple of minutes?
04:21It's not a very fair question, so don't worry about it if you can just throw answers out, because we really didn't learn about it.
04:39Well, it doesn't have anything to do with naming conventions, even though they do have different naming conventions.
04:50But the reason is, imagine that you have the most simple scenario, Orin is a designer, has no clue in programming, he doesn't even want to know programming, right?
05:00And he built this really complicated, really, really cool Illustrator art, he threw it into Flash, he even did a little bit of animation into it, and now he wants to put some interactiveness into it.
05:11Now, he doesn't really want to write all that code.
05:14So he turns to Carol, and Carol is a programmer and a designer as well, so she knows his Illustrator files, but she already created some of these classes, right?
05:24Why would she need to now go through all these classes, rename them, and try to figure out all these stuff?
05:29She already has a class that could do everything that Orin wants, she already did it before.
05:33Now, if she had to go and rename all of Orin's stuff, it might break some of Orin's design.
05:40So Carol doesn't have to rework on all the stuff that she worked already before.
05:48All she has to do is just link into these elements whatever she wants to have interactivity.
05:54It doesn't have to be connected to the visual name, the name that the designers are using.
05:59That's one reason.
06:01The second reason is, what if we have 20 different visual elements, but they all have the same functionality, right?
06:07Let's say we have 20 different types of cats, or in our scenario, 20 different types of balls.
06:14But they're all balls, they are all going to hop on the stage.
06:18The blue ball, the green ball, the yellow ball, the red ball, they're all going to hop on the stage.
06:23Now, why should I have a class for a yellow ball, a class for a blue, I probably shouldn't say blue ball,
06:28but a class for all these different colors of balls?
06:31I shouldn't, right?
06:33And because I shouldn't have that, there's a strict separation between them.
06:36So I could say, okay, now this is a class that will work on all these type of balls, all right?
06:41And that's really the importance of, especially when you're designers,
06:44and a lot of you guys have a lot of experience with design.
06:47You don't want to step away from that.
06:49That's the beauty of that flash, and that's the beauty of what you're doing.
06:52Don't run away from your skills as designers.
06:54Now that you're building all these stuff, just start thinking about them as clusters.
06:58Could we start reusing these elements?
07:00Could we start reusing our code?
07:02And that's where object-oriented program becomes really, really fun.
07:05Okay, so that's the reason why we have both a linkage name and a library name,
07:11or a library name and a class name for our library element.
07:15Now I'm going to throw two more things that we haven't really talked about yet.
07:18We kind of briefly talked about it, but not really, all right?
07:21So one of them is going to be constants.
07:25I don't know if I spelled that right.
07:28Probably I didn't, but it doesn't really matter.
07:31All right, so constants.
07:32What are constants?
07:33Until now we worked with variables.
07:35Variables are things that change over time.
07:37But there are some things that do not change.
07:40Like, does pi ever change?
07:42No, math.pi.
07:44Pi never changes.
07:45So here we go.
07:46We have pi, which is a constant.
07:47It's not a variable.
07:48I don't want anyone to change that, because that would mess a lot of things up, right?
07:52Pi is pi.
07:53It will always be pi.
07:54It will never change.
07:55And there's a lot of other things like that,
07:57such as, let's say, the highest number that an integer could get,
08:00which is the max value.
08:02That max value will never change.
08:04It's not a variable, right?
08:06If it was a variable, someone could come in and change it.
08:08But we don't want anyone to change it.
08:10And that's where constants come in.
08:12Now we're going to look at how do we create our own constants.
08:15But we're going to have to have a way to differentiate between a constant,
08:18which looks almost like a variable, and saying that's not a constant.
08:21So we have that.
08:22And the last item and the last different type of thing that has names
08:26that we care about differentiating,
08:28and that's really just for our own good,
08:30is between private and public things, mainly variables.
08:36Okay?
08:37So we can do public and private variables.
08:39Now, is a public and private variable the same thing?
08:42Yeah, they're both variables.
08:44But the real difference between them is that some we want the world to know about,
08:47some we don't.
08:48Now, as we're working with Flash,
08:50which is a more primitive editing tool,
08:53and it's not like Eclipse, and it's not like Flex,
08:56and it's like all these really great ones that a lot of people are working with them,
08:59and I don't think you guys should yet,
09:01but you obviously are recommended to if you feel like doing,
09:03because it does cut down a lot of the thinking.
09:05It makes things a lot faster,
09:07but I don't think faster is better, especially now when you're new to programming.
09:11You really want to get the ins and out of it,
09:13because when you do, then you can find tools that make things faster.
09:16I personally always work with the more primitive tools.
09:19So I just like automatic filling of class names, that's great,
09:23because I don't really want to need to remember every single class name.
09:26But there are some things like building my own functions,
09:28I like doing it myself, because it makes it easier
09:31for you to keep your head around what is around,
09:34and kind of know exactly when you created something on your own.
09:37So that covers all the different types of names and stuff
09:40that we're actually going to cover now in the next half hour or so.
