AS3 OOP packaging help

I am currently trying to make a fighting game with AS3, including my own custom physics engine. It has been coming along pretty well, until I ran into one extremely large bug. When I try to create a new HumanFighter object in my script, it fails, telling me that the package ‘’ does not represent the location of the file. However, I only have two directories I’m working in, and I’ve tried to package it both ways. I have a root directory ‘Flash Games’ and a subdirectory ‘classes’. I’m trying to create the HumanFighter from a class in the classes file, and the HumanFighter class is also inside the classes folder. I might have been able to figure it out by now, except I can create a new ActivePointEngine object from the ActivePointEngine class in the same ‘classes’ folder. Hopefully, I haven’t made you as confused as I am!

Okay so here’s the deal.

Say you have a class called “Explosion.as”.

Your project folder is /fightinggame/

So, for the sake of argument, say you put “Explosion.as” inside /fightinggame/com/gfx/

Then your class file should look like;


package com.gfx { //representing the relative path from your project root
  public class Explosion extends Sprite { // representing the filename, but without the .as
  }
}

[quote=sekasi;2350654]Okay so here’s the deal.

Say you have a class called “Explosion.as”.

Your project folder is /fightinggame/

So, for the sake of argument, say you put “Explosion.as” inside /fightinggame/com/gfx/

Then your class file should look like;

ActionScript Code:
[LEFT]package com.[COLOR=#000080]gfx[/COLOR] [COLOR=#000000]{[/COLOR] [COLOR=#808080]*//representing the relative path from your project root*[/COLOR]

[COLOR=#0000FF]public[/COLOR] [COLOR=#000000]class[/COLOR] Explosion [COLOR=#0000FF]extends[/COLOR] Sprite [COLOR=#000000]{[/COLOR] [COLOR=#808080]// representing the filename, but without the .as[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]

[/quote]
Thanks for the effort, but that doesn’t really apply. I can successfully create an object of a class in the same file *without *adding the file’s name to the package statement. It works for one class, just not for another.

Okay, I found the problem. It wasn’t in the AS files, it was in the linkage of my HumanFighter symbol. Thanks for responding so quickly!