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

Linkages

Linkage name conventions.

Video Transcript

00:00Now, library names, they don't really have big standards, right?
00:04So, the standard that I like imposing on them is just adding an MC before, usually.
00:09In all of our samples, we didn't do that so far, because I didn't want to make things more complicated.
00:13But what I like doing is just, or MC, or just the type of element,
00:17because really, when we have library elements, unless it's visual stuff that don't have code involved with it,
00:21but it really doesn't matter the standard, just as long as you're consistent.
00:27I personally like just saying that this is a movie clip, so I'm just going to call it MC.
00:31So, I'm going to call it MCBall, and I like calling this element MCBall2.
00:39Now, what did that give me? Not much.
00:42All it did is that if I add here another element, and let's say I'm going to add another something,
00:47let's say a different color, but this time around, it's not going to be a movie clip.
00:51We're going to add this, and it's going to be a graph instead.
00:54So, I'm going to modify, convert to symbol. I'm going to pick graphic.
00:58And what is a graphic? It's just something that has no code access, right?
01:01It's just a visual element. We cannot export it into ActionScript. It's not quotable.
01:07So, what I like doing is just starting with G.
01:09I know it's a graphic, and then I could give it whatever name where I said it again.
01:12So, we created a graphic, and I just wanted to reiterate that, that our graphic now,
01:17I just gave it a G for it to stand as a graphic.
01:21Now, was that important for it to be with a G? No.
01:23So, you find your own standard. That's fine.
01:26As long as you have one. Don't add things into the library,
01:29because then at some point you're just going to have hundreds of things in your library.
01:32It's going to get really, really messy and really hard to manage it.
01:35Or if you're more organized with folders, then organize things into folders.
01:40The names of the movie clips themselves aren't as important,
01:43although it makes life a little bit easier if your name is kind of similar to the name of the class.
01:50So, it really depends on the scenario, how you're working with it.
01:53Now, I just want to connect the dot to one more thing.
01:56So, we talked about library linkages.
01:58We created a library name, and we could see that that's my MC ball.
02:03Now, let's say we didn't call that.
02:05Let's say we didn't care about that convention,
02:07because really, the amount of import, the importance of it is less important,
02:12because this never gets into code.
02:14So, the importance of it is really just about be organized.
02:17That's really all we're saying here.
02:20So, this has to stay as gball, so we're going to leave it as gball.
02:24All right, so we established we're just going to call this ball,
02:28but let's call this ball instead of all upper case,
02:31at least give it a name that's similar to a class.
02:34So, I'm going to call it ball, which is all lowercase,
02:38because it's not really a class.
02:40So, I'll just call it ball, and this one I'm going to call ball2.
02:43And again, this standard is less important.
02:46The standard that is important is the standard that you have
02:49for things that are code related.
02:51And now, we're talking about linkages.
02:53So, let's say I want to give a linkage to this ball,
02:55and I'm going to even say I want to drop it into the stage,
02:58and we're going to do it right now.
03:00So, I'm going to just delete this,
03:02and we're going to give it a linkage,
03:04because we're going to drop it onto the stage.
03:06Right now, it's on the stage,
03:07but we're going to delete everything from the stage,
03:09double click on eraser,
03:11and we're going to go down to our ball, properties,
03:14and we're going to give it a linkage.
03:15So, we're going to say export to action script,
03:17and I'm going to give you my convention.
03:19My convention is not popular.
03:21I think I'm the only person that uses this convention.
03:23Most of the people I know don't even use a convention here,
03:26but I have a trick, a convention trick,
03:29makes my life really easy.
03:31Some people, like, I'll show you a convention that a friend of mine
03:33I store that uses.
03:34He likes calling everything, just giving it a package name,
03:37which is library dot, and then the name of the element.
03:41I have a very similar one, but instead of that,
03:43what I do is I just call it L in lower case,
03:46and then the name of the class.
03:48Now, this class doesn't really exist, right,
03:50because we have no code connected to it.
03:52We haven't really worked or showed how to put a real class into it,
03:55which we're going to do today.
03:57So, right now, we don't have a real class that we could touch,
04:01that we could edit and change and tinker around with yet, right?
04:04But we have a class name.
04:06Now, what I like doing is calling it L in lower case.
04:09What does that give me?
04:10That makes it easy for me to see that it's a linkage.
04:13So, it's L stands for linkage for me.
04:15And then the name of the class.
04:17Now, I only do that if the class itself has no actual class.
04:22So, whenever I see the L in lower case, then the name in upper case,
04:26then I know, okay, this is a linkage.
04:28There's no real class here.
04:29Now, why is that important?
04:31I'm just going to click okay here.
04:32A lot of times, when I'm coding it,
04:35I'm just going to add a child new L ball.
04:42And look how simple this was.
04:43So, first of all, I'm just adding the element to the stage,
04:45and I'm just creating a new L ball.
04:48Now, by doing that, automatically,
04:50I'm going to be able to throw this element onto the stage so far.
04:53So, good.
04:54But this was easy.
04:55But what if my code was really, really complicated?
04:57Suddenly, I see this class L ball, or it had a different name.
05:01Maybe it was just called ball.
05:03I don't know, especially not in Flash,
05:05I don't know if this is a visual element.
05:07I don't know if it has a real class or not.
05:10Then I start looking for the class, and I can't find it.
05:13And then, suddenly, I'm searching for 10 minutes
05:15because I'm working with a more primitive tool.
05:17And, you know, some of the Flex guys or the people
05:19that are working with more advanced tools will say,
05:20oh, well, you can just click on that button,
05:22and it's going to show you the class if it exists or not.
05:25We don't want to do that yet because we want to get used to the environment
05:27and be really, really comfortable in it
05:29before we start finding tricks and sticks
05:31on how to cut corners and get things faster.
05:34So our problem is that we have to have a way to recognize
05:38just by looking at it, even without searching,
05:40which is much better than searching.
05:42Just by looking at this, I know that this is a library linkage class
05:45that has no actual reference.
05:47There's no actual class connected to it.
05:50So we have already crossed our packages, functions,
05:53variables, classes, library names, library linkages.
05:57Now let's talk about constants, private and public variables,
06:00and then we're going to start building our own class,
06:02which is quite exciting.
06:04All right, so let me just ask quickly again.
06:06So far, everything okay?
06:08Are you guys following what the idea of linkage is?
06:12Perfect.

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!