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

Our First Linkage

So far we focused mainly on building our visual elements and positioning them on the stage. In this video we will learn how we can create a blueprint(linkage) that we can instantiate from code.

Video Transcript

00:00So far we've focused mainly on building one thing.
00:04Let's start taking our experiences that we had so far and taking it a step a bit further.
00:09In this example, we're just going to create a little cute, hopefully, simple animation that kind of mimics
00:15maybe the motion from things that go up downwards.
00:19We could say rainfall.
00:20We're not going to go through actually going through the aesthetics.
00:23And we're going to just look at a little bit of the motion and how could we create that motion
00:27and add some randomness and add some details.
00:30But before we do that, we have one thing that we have to learn, which is creating linkages.
00:35We don't have to, but we want to.
00:37This is the first linkage experience that we're going to create.
00:41All right, so let's jump into Flash.
00:44And what I want to do is I'm just going to create a very, very simple shape.
00:48I'm just going to grab my oval tool and I'm going to create a little oval.
00:54And I'm going to get rid of the background of that oval, of the line.
00:59I'm just going to keep the background beautiful.
01:02And I'm going to modify, convert it into a symbol.
01:04And this time around, I'm going to call it MC Oval.
01:10All right, now at this time around, we actually are going to look into the Advanced feature.
01:15So if we click on to Advanced, we're going to see all these details that we want to modify.
01:21Instead of doing it directly, even though that's exactly what I want to do,
01:25I want to show you what you do in case you didn't do it.
01:28So let's click OK and see how we could return back to that linkage property.
01:33And we could see that our disappeared.
01:39Weird.
01:40I shouldn't do that, right?
01:42Let's zoom out and see what happened.
01:44All right, so let's just delete it from the stage for a second and go to our library.
01:49Yep, our oval tool is there.
01:51That was just a weird little thingy that just happened there.
01:55All right, so we have our item in the library.
01:58We're going to go back into it.
02:00And we're going to control-click or right-click and then go into our properties,
02:06which will give us back the same dialogue that we had when we created our object,
02:10actually, our movie clip.
02:12And again, to notice, we are creating a movie clip and not other types of objects
02:17that we've looked at earlier.
02:19We want to export that code into ActionScript or as it's more known as linkage.
02:25We're going to link our movie clip to be able to be created and accessible in code.
02:31And we're going to see in a second how we actually create them.
02:34Now, because we didn't really learn yet how to create classes,
02:38we're going to actually just put here a name and that will make Flash
02:43automatically create a class for us.
02:46Just as we used objects and arrays which were classes that created our array
02:50or created our object, we need to create a blueprint or a class
02:55that will enable Flash to duplicate and create new instances for our movie clip.
03:00I like calling anything that comes from the library.
03:03I like starting with the letter L to indicate that it's a linkage
03:06and it's not a real class.
03:09I'm just adding L to my MC Oval, making it named LMC Oval.
03:16The base class is a movie clip because our display object is a movie clip
03:20and we are not going to play around with that at this point.
03:23We're going to keep it at the default base class which is flash.display.movieclip.
03:27If we had our own custom class and we created something on our own,
03:30we might have changed our base class or class
03:33but we're going to look into that in a later course
03:35where we go and talk when we'll start talking about classes
03:38and how to work with them.
03:40Perfect, so we're done here and we could click OK
03:43and just a reminder, our name in the library is MC Oval.
03:46That's not the name of our class.
03:48The name of our class is LMC Oval.
03:51If we called it MC Oval, it would be the exact same thing.
03:54The name and a linkage but that would be kind of confusing.
03:57Adding that LMC makes sure that we know that this is a linkage.
04:01It came from the library.
04:02It's harder to get confused later on as we learn different types of classes,
04:06ones that we create ourselves versus ones that are created dynamically
04:11by the flash editor or the flash player or the flash compiler,
04:15whatever is actually creating the class.
04:18I like differentiating it.
04:20That's an important pointer and we'll revisit that later on
04:23when we actually create our own classes as well.
04:25All right, so I'm going to click OK.
04:27At this point, it's going to give us this warning message
04:30if we didn't set, not to show this message,
04:32it's telling us that classes could not be found
04:35and that's true because we never created a class on our own.
04:38So instead of let flash is telling us it will be automatically generated
04:41in the SWF file upon export and that's exactly what we just set.
04:46All right, so we have our movie clip in the library.
04:48We know its linkage is LMC Oval and we have nothing on our stage right now.
04:54So if I run my application, we'll see that there's nothing on the stage.

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!