Classes: referencing of a movieclip not being recognised
I have a main .fla file that has a movieclip with an instance name level. Within this there is another movieclip called hero.
I have a main class with the following function:
Quote:
public function beginLevel() {
var cHero:Hero = new Hero;
createFunction1();
}
I then have a Hero class with the following code:
Quote:
public class Hero extends MovieClip {
private var hero:Object;
public function createHero() {
hero = new Object();
hero.mc = level.hero;
hero.startx = hero.mc.x;
hero.starty = hero.mc.y;
}
}
In the main flash file, the hero movieclip is nested inside the level movieclip.
The line hero.mc = level.hero; is used to make it easier for me to manipulate the hero's attributes later on. However when I compile this, I get the error message: Access of undefined property level.
I'm not really sure how to get this class file to recognise the movieclips in the main flash file.
Any help would be greatly appreciated.