I keep getting the TypeError: Error #1010 when trying to create the constructor code for a small game in AS3. The code that appears to be causing the issue is:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip {
var screen1:StartScreen;
var screen2:InstructionsScreen;
var screen3:SelectScreen;
var screen4:Game1Screen;
var screen5:Game2Screen;
var screen6:Game3Screen;
var screen7:FailScreen;
var screen8:CompleteScreen;
public function Main(){
screen1 = new StartScreen();
screen2 = new InstructionsScreen();
screen3 = new SelectScreen();
screen4 = new Game1Screen();
screen5 = new Game2Screen();
screen6 = new Game3Screen();
screen7 = new FailScreen();
screen8 = new CompleteScreen();
screen1.startBtn.addEventListener(MouseEvent.CLICK,gotoSelect);
screen1.instBtn.addEventListener(MouseEvent.CLICK,gotoInst);
screen2.startBtn.addEventListener(MouseEvent.CLICK,gotoSelect2);
screen3.game1Btn.addEventListener(MouseEvent.CLICK,gotoGame1);
screen3.game2Btn.addEventListener(MouseEvent.CLICK,gotoGame2);
screen3.game3Btn.addEventListener(MouseEvent.CLICK,gotoGame3);
screen4.failBtn.addEventListener(MouseEvent.CLICK,gotoFail1);
screen4.winBtn.addEventListener(MouseEvent.CLICK,gotoWin1);
screen5.failBtn.addEventListener(MouseEvent.CLICK,gotoFail2);
screen5.winBtn.addEventListener(MouseEvent.CLICK,gotoWin2);
screen6.failBtn.addEventListener(MouseEvent.CLICK,gotoFail3);
screen6.winBtn.addEventListener(MouseEvent.CLICK,gotoWin3);
addChild(screen1);
}
private function gotoSelect(evt:MouseEvent):void{
removeChild(screen1);
addChild(screen3);
}
private function gotoInst(evt:MouseEvent):void{
removeChild(screen1);
addChild(screen2);
}
private function gotoSelect2(evt:MouseEvent):void{
removeChild(screen2);
addChild(screen3);
}
private function gotoGame1(evt:MouseEvent):void{
removeChild(screen3);
addChild(screen4);
}
private function gotoGame2(evt:MouseEvent):void{
removeChild(screen3);
addChild(screen5);
}
private function gotoGame3(evt:MouseEvent):void{
removeChild(screen3);
addChild(screen6);
}
private function gotoFail1(evt:MouseEvent):void{
removeChild(screen4);
addChild(screen7);
}
private function gotoWin1(evt:MouseEvent):void{
removeChild(screen4);
addChild(screen8);
}
private function gotoFail2(evt:MouseEvent):void{
removeChild(screen5);
addChild(screen7);
}
private function gotoWin2(evt:MouseEvent):void{
removeChild(screen5);
addChild(screen8);
}
private function gotoFail3(evt:MouseEvent):void{
removeChild(screen6);
addChild(screen7);
}
private function gotoWin3(evt:MouseEvent):void{
removeChild(screen6);
addChild(screen8);
}
}
}
And the error message that appears when I try and run this is:
TypeError: Error #1010: A term is undefined and has no properties.
at Main()
Mainclass so we can determine what's causing the error. The code above doesn't seem to be the offending one - Matti Lyrascreen1toscreen6don't have the named buttons defined, or theStartScreenetc classes don't exist or are accessible. - Matti Lyra