What are packages?
What is a package? Packages are use to help organize our code into buckets lets take a quick tour of how to work with packages. Through this video you will learn the basics of working with packages and its a great place to start before we build an actionscript 3.0 class.
Video Transcript
00:00Up until now we've been working with our main structure which was a very standard one
00:05We've been working for hours with it
00:07Which we basically had our FLA and all of our code we placed inside of our dot as file
00:12Which we know is a class
00:13But we don't really really get in we didn't really get into the details of what actually that means
00:17I want to break that right now and start understanding and
00:20One the first step that we want to start with and if I just toggle into my flash
00:24And I'm already inside of that main and what I wanted to do is first break down this first line that we've been
00:30Just customize already at this point to use and what best basically is saying is saying to flash to import
00:36From the directory flash and inside of it. It's actually called a package and flash and you can see that's why
00:42It's named a package and we basically our main is sitting inside of an empty package or in other words
00:50It's sitting in the same directory as our FLA and that's not a hundred percent true on rate
00:55I'm gonna get back to that but but that basically what it means it means that there's no
00:59It's not sitting somewhere now
01:01What is the importance of something sitting somewhere there might be and there definitely will be scenarios when you're working with other
01:07developers that they call their classes where they call their files the same names as you're calling your own files and
01:13As you're using open source code or as you're downloading applications, and you're collaborating with other people
01:19you want to make sure that you could separate your code from other developers and
01:23Write that if you just create separate classes, and we're going to look into that and very very very shortly
01:29It's not enough sometimes and just just to state it you kind of need to understand what packages are because everything inside of flash
01:36Almost everything is inside of some sort of a package
01:39So if we wanted to use the movie clip class
01:41We first had to know where that movie clip was located at and it was located in the flash
01:47Display dot movie clip and from our perspective
01:50It's just as if we were saying it's inside of the directory flash and in that directory. It's in the directory display and
01:57In that directory we would find our movie clip class
02:01Right, and then we start using it
02:03So what I want to do before we're going to keep that the way it is
02:06But what I want to do is I want to make our main sit in a different place as well
02:09I don't want it to sit anymore in our main folder
02:13Now to do that all I really have to do is toggle back into my finder and in my finder
02:18What I'm going to do is I'm going to show you a few small pieces before we even let's start from just doing it directly
02:23In my source folder. I'm just going to right-click and create a new folder and
02:28That new folder. I'm going to call it
02:30COM it's just a standard where you just take your domain name and
02:35You start from the other way around so just come that
02:39everything
02:41FLA all lowercase from my perspective now if you wanted to have camel case
02:46That's totally fine as well, but just make sure that your first
02:50Character is lowercase just to make it easier to recognize between what a package is and what a file is because when you're working
02:56Inside of flash don't look very similar
02:59Because you don't have those folder structures perfect
03:02So I have my come folder have my everything I fill a folder now
03:06I want to just close down our main that is because I'm going to grab it from that folder
03:10And I'm just going to toss it right into our new directory
03:14So I want to put it into here, and I want to take our main all the way down into our everything
03:20I fill a now. I just want to reopen it again, so I'm just going to drag it into flash
03:27and
03:28As I drag it into flash now one thing our application is not going to compile anymore because if we run our application main
03:34It's going to run, but it's not going to find our class
03:37So it's just going to put there whatever it wants and the way I know that even if you do here a little trace
03:41And you run your application you're going to see that there's just no it's not happening now
03:50We want to do two things first of all in our main fla. We want to go into our properties again
03:55And instead our class is not going to be called main anymore
03:58We're actually going to give it the full path of how to get to it
04:01And the full path was our com folder and dot followed by everything
04:08fla
04:09Dot then the name of our class which is main now. We don't put the dot as we don't need to I'm just going to
04:14Tape enter and then just click on my edit class definition to see that the link
04:19Happened and we can see that our link did happen
04:22We still have one more thing to change because we have to actually
04:26Manually tell flash inside of our as file that we want
04:30That our package is not in our root anymore because right now this definition says that our packages in the base where our fla
04:38Is located like we said before so all I have to do is just to put their space and just say to flash
04:43No, you're actually inside of the calm
04:45Everything fla because I'm working in cs5
04:48I'm getting these really great hands and if you're working in flex you would be getting or flash builder
04:53You would be getting those hints as well
04:55So I'm just going to double click on it
04:56But if not you just would type calm dot everything fla all in lower case to match the way you built your folder structure
05:05That's all we have to do if we run our application one more time
05:08We're going to see that we're going to get that star in our output and our our applications are connected one to each other
