# AS3 OOP packaging help

**URL:** https://forum.kirupa.com/t/as3-oop-packaging-help/264675
**Category:** flash
**Created:** [June 28, 2008, 1:14pm UTC](https://forum.kirupa.com/t/as3-oop-packaging-help/264675 "2008-06-28T13:14:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sage\_of\_Fire](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Sage\_of\_Fire](https://forum.kirupa.com/u/Sage_of_Fire)
#### Post date: [June 28, 2008, 1:14pm UTC](https://forum.kirupa.com/t/as3-oop-packaging-help/264675/1 "2008-06-28T13:14:49Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)
#### Post date: [June 28, 2008, 1:19pm UTC](https://forum.kirupa.com/t/as3-oop-packaging-help/264675/2 "2008-06-28T13:19:00Z")

</div>

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;

```auto

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

```

---

<div class="post-metadata">

### Author: ![Sage\_of\_Fire](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Sage\_of\_Fire](https://forum.kirupa.com/u/Sage_of_Fire)
#### Post date: [June 28, 2008, 1:23pm UTC](https://forum.kirupa.com/t/as3-oop-packaging-help/264675/3 "2008-06-28T13:23:08Z")

</div>

[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.

---

<div class="post-metadata">

### Author: ![Sage\_of\_Fire](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Sage\_of\_Fire](https://forum.kirupa.com/u/Sage_of_Fire)
#### Post date: [June 28, 2008, 1:41pm UTC](https://forum.kirupa.com/t/as3-oop-packaging-help/264675/4 "2008-06-28T13:41:10Z")

</div>

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!
