I like to think of packages as folders. When you are stating that the package is importme that means that that specific class is in the folder importme.
so say you have a simple class called CreateBox...
I always create an AS folder for my projects. so my package would be AS. this is what the code would loom like
Code:
package AS
{
import flash.display.Sprite;
public class CreateBox extends Sprite
{
private var mc:Sprite;
public function CreateBox(width:Number, height:Number, color:uint, alpha:Number=1)
{
super();
mc = new Sprite();
mc.graphics.beginFill(color, 1);
mc.graphics.drawRect(0,0,width,height);
mc.graphics.endFill();
mc.alpha = alpha;
addChild(mc);
}
}
}
now how to call that from your main document class. really depends on where your writing your code and how you have the project setup. I use eclipse with the flex sdk so it keeps track of all my folders in my project. And knows my AS folder is a resource for classes. If your using flash you can setup in the export settings where it should look for specific folders. Lee brimelow has a tutorial on this over at GotoandLearn
for the sake of my example though its simple when you want to use that class then you would import AS.CreateBox;
then you can create instances of that class by saying
Code:
box = new CreateBox();
so your full document class would look like this then;
Code:
package
{
import AS.CreateBox;
import flash.display.Sprite;
public class Main extends Sprite
{
private var box:CreateBox;
public function Main()
{
super();
box = new CreateBox(10,15,0x000000,1);
addChild(box);
}
}
}
hope this helps, and clears it up for you.
Bookmarks