Strike Force Heroes 2
The explosive sequel to the hit game Strike Force Heroes!
3.93 / 5.00 10,188 ViewsObsolescence
Defeat the enormous mechanical beasts--and become one of them.
4.03 / 5.00 46,370 ViewsHi.
I'm using AS3 OOP.
If i want to organise my .as files in my project folder into many subfolders such as menu items, is there a special procedure I have to follow to let flash know where my seperate .as files are?
Just change the package name at the top of the .as files to reflect their location.
Example: a class in the folder "classes/characters/enemies" would have the package "classes.characters.enemies".
And when you import them you just refer to them like that.
import classes.characters.enemies.wilddog; I'm getting error 1172,
definition of ____ could not be found.
BTW i'm importing this to my document class right?
At 1/17/12 12:50 AM, DavidHan wrote: I'm getting error 1172,
definition of ____ could not be found.
Is the file name the same as the class inside it?
Example: the wilddog class would be in the file wilddog.as
If that's not the problem then maybe you made a typo or something somewhere.
At 1/17/12 12:50 AM, DavidHan wrote: BTW i'm importing this to my document class right?
Yeah, or where ever you are using the class.
--------------
Here's an example showing a possible folder structure:
Image (below as well)
Then inside enemy_fisherman.as
package classes.characters
{
...
public class enemy_fisherman extends enemy
{
and then where ever I want to use this class I will simply import it like this:
import classes.characters.enemy_fisherman;
or
import classes.characters.*;
which import all the classes in that package/folder that are being used.
Very nice explanation, Torrunt.
unless you are using a barbaric IDE, importing will be taken care of for you. You should just put classes that are related into the same folder for your own sanity. When you get a little bit more advanced with using packages you may use internal variables that only classes with the same package can access.
Asteroids || Never trust a gay Canadian?
Thanks Torrunt. I'm using flash IDE btw.
As a test, I tried putting a class file into a folder called MenuButtons, then in the .as file of that class, i put
package MenuButtons {
I did not get an error, so I guess that part is good, but when I tested my project, the classfile didn't run. I tested a trace(); in the constructor, and it didn't run.
Do i need to import in flash IDE?
when do I need to import? do I have to do it everytime or just once?
thnks!
Whoops, turns out the class is one that is dragged onto the stage using flash instead of being created at runtime. Does that make a difference? has flash already imported it now? where do i set the new classpath then?