evan
07-07-2009, 04:06 AM
I have pretty much gotten the hang of coding in a document class but I would like to start breaking up my code into classes that are called up in the document class:
lets say my document class is named "shootemup", it will be named shootemup.as to go along with shootemup.fla -which has shootemup in the document class field in the properties.
step 1:
here is my code :
package{
//imports here
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*
import flash.display.*
public class shootemup extends MovieClip{
//begin vars here if any
//begin constructor:
public function shootemup()
{
trace("the constructor is running");
}//end constructor
//private functions go here
}//end class
}//end package
step 2:
But if I want to create a new class like this:
package importme{
//imports here
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*
import flash.display.*
public class importme {
//begin vars here if any
//begin constructor:
public function importme()
{
trace("class importme is running too");
}//end constructor
//private functions go here
}//end class
}//end package
step 3:
import class and get it to run:(this is the part I am not sure about)
I go back into my document class and add the lines in bold(I think)
package{
//imports here
import importme
/*importme is not in a folder otherwise it would be importme.importme or com.importme*/
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*
import flash.display.*
public class shootemup extends MovieClip{
//begin vars here if any
//not sure: var importme: new Imortme
//begin constructor:
public function shootemup()
{
trace("the constructor is running");
//start importme function
importme();
//or is it
//addchild(importme)
}//end constructor
//private functions go here
}//end class
}//end package
-I am new at this so any help is appreciated.:confused:
lets say my document class is named "shootemup", it will be named shootemup.as to go along with shootemup.fla -which has shootemup in the document class field in the properties.
step 1:
here is my code :
package{
//imports here
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*
import flash.display.*
public class shootemup extends MovieClip{
//begin vars here if any
//begin constructor:
public function shootemup()
{
trace("the constructor is running");
}//end constructor
//private functions go here
}//end class
}//end package
step 2:
But if I want to create a new class like this:
package importme{
//imports here
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*
import flash.display.*
public class importme {
//begin vars here if any
//begin constructor:
public function importme()
{
trace("class importme is running too");
}//end constructor
//private functions go here
}//end class
}//end package
step 3:
import class and get it to run:(this is the part I am not sure about)
I go back into my document class and add the lines in bold(I think)
package{
//imports here
import importme
/*importme is not in a folder otherwise it would be importme.importme or com.importme*/
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*
import flash.display.*
public class shootemup extends MovieClip{
//begin vars here if any
//not sure: var importme: new Imortme
//begin constructor:
public function shootemup()
{
trace("the constructor is running");
//start importme function
importme();
//or is it
//addchild(importme)
}//end constructor
//private functions go here
}//end class
}//end package
-I am new at this so any help is appreciated.:confused: