# OOP problem

**URL:** https://forum.kirupa.com/t/oop-problem/261434
**Category:** flash
**Created:** [May 27, 2008, 4:21pm UTC](https://forum.kirupa.com/t/oop-problem/261434 "2008-05-27T16:21:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![magnusvs](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@magnusvs](https://forum.kirupa.com/u/magnusvs)
#### Post date: [May 27, 2008, 4:21pm UTC](https://forum.kirupa.com/t/oop-problem/261434/1 "2008-05-27T16:21:56Z")

</div>

Hi!

I’m trying to make a photo gallery with AS3, but I get an error message when creating and importing classes.

The site structure is like this  
main.fla (the file I want to import a class to)  
classes (folder where the .as files are located)

In the “classes” folder, I have a file named Album.as which contains the Album class.  
The code for the Album.as is like this:

> 

// package needs to match directory structure between your fla and the class  
package classes {  
// imports go inside the package, outside the class  
import flash.display.Sprite;  
// class name needs to match filename (case sensitive)  
class Album extends Sprite{  
// constructor method matches class name, this gets run automatically  
public function Album(){  
// super() calls the constructor of the superclass…  
// so this makes sure we’ve set up everything that a  
// Sprite normally gets  
super();  
trace(‘new Album created’);  
}  
}  
}  
Then, in the main.fla, I have this code (frame 1 in the main timeline):

> 

// make the custom class available  
import classes.Album;

// make a variable to hold the album object  
var albumInstance:Album;

// put a new album inside  
albumInstance = new Album();

// put the album on stage  
addChild(albumInstance);  
When I run the file, I get two errors saying:  
“1046: Type was not found or was not a compile-time constant: Album.” for  
“var albumInstance:Album;”

and

“1180: Call to a possibly undefined method Album.” for  
“albumInstance = new Album();”

So it looks like it can’t find the class I’m referring to (is that correct?). Does anybody know how I can solve this problem? People are using OOP all the time and I guess this is really basic stuff, but I have never used OOP in Flash before:)

---

<div class="post-metadata">

### Author: ![magnusvs](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@magnusvs](https://forum.kirupa.com/u/magnusvs)
#### Post date: [May 27, 2008, 4:50pm UTC](https://forum.kirupa.com/t/oop-problem/261434/2 "2008-05-27T16:50:09Z")

</div>

Solved! I just had to make the class public! 🙂  
If I make more classes, e.g. “Image” as one class, should I then put it inside the same package, or use a new package and another file? (that’s what I’m used to in [vb.net](http://vb.net))
