2

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()
5
  • 1
    can you provide the full Main class so we can determine what's causing the error. The code above doesn't seem to be the offending one Commented Nov 17, 2012 at 17:22
  • Certainly, it's quite lengthy though. Commented Nov 17, 2012 at 17:23
  • 3
    Right, well I don't see anything wrong with the code itself. I'm guessing that the on of the movieclips screen1 to screen6 don't have the named buttons defined, or the StartScreen etc classes don't exist or are accessible. Commented Nov 17, 2012 at 17:29
  • That was the issue, I hadn't finished adding the buttons! Thank you very much. Is there a way to rate you positively on here? Commented Nov 17, 2012 at 17:41
  • @Tummus I added the comment as an answer to your question. You can upvote and/or accept (using the tick mark below the up/down vote buttons) the answer. Commented Nov 18, 2012 at 10:33

1 Answer 1

2

I don't see anything wrong with the code itself. I'm guessing that one of the movieclips screen1 to screen6 don't have the named buttons defined, or the StartScreen etc classes don't exist or are accessible.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.