Creating Packages

Folders and Paths

What are packages? Go to your post office and get a box. Put various things into the box, which you want to send. What do you usually do? You again make smaller boxes to organize your package. Now in our case we use folders, which we give names, for example we have lesson1, lesson2 and so on. Within the folders we have created more folders like as_scripts to know where all the .as scripts are located. However, in real world we do not only create one folder but several depending on the size of the project. To get into an example open the lesson7 folder. We have two flas lesson7a.fla and lesson7b.fla. Can you guess which scripts belong to which fla? Well open lesson7a.fla and the lesson7a folder. You can see two more folders inside, which we called as_scripts and as_scripts_a. This is not very useful because we don't know what really is the difference. Well. take it as an example how you should not name folders. But I am using it here to show how the script in our fla file has to look like.

import lesson7a.as_scripts.*;
import lesson7a.as_scripts_a.*;
var show1:SlideShow1 = new SlideShow1 ("../images/pic_1.jpg");
var setXY:Adjust_xy = new Adjust_xy (m_empty);
trace("bx "+setXY.Fix);
trace("by "+setXY.Fiy);
_root.onEnterFrame = function() {
	setXY.Fix = (Stage.width-_root.m_empty._width)/2;
	setXY.Fiy = (Stage.height-_root.m_empty._height)/2;
	trace("ax "+setXY.Fix);
	trace("ay "+setXY.Fiy);
};

Look at the red lines. We have to separately import every folder. That is also true for our next example in the folder lesson7b. Open the fla file first and then look at the folder. Inside we find another folder as_scripts_b and inside there we find the main script slideShow1 and another folder called "helper". This is more reasonable because now we know inside the helper folder is a subscript, which fullfills a certain task for the basic functions in slideShow1. Again we need to import all folders as the lines in red show.

import lesson7a.as_scripts.*;
import lesson7a.as_scripts_a.*;
var show1:SlideShow1 = new SlideShow1 ("../images/pic_1.jpg");
var setXY:Adjust_xy = new Adjust_xy (m_empty);
trace("bx "+setXY.Fix);
trace("by "+setXY.Fiy);
_root.onEnterFrame = function() {
	setXY.Fix = (Stage.width-_root.m_empty._width)/2;
	setXY.Fiy = (Stage.height-_root.m_empty._height)/2;
	trace("ax "+setXY.Fix);
	trace("ay "+setXY.Fiy);
};

And that brings us to the conclusion of this part of the tutorial.

Next we will look at the superclass.

previous  next