Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Error 1010//Buttons Aren't Working

New Here ,
Mar 02, 2014 Mar 02, 2014

I know AS2 and am finally converting to AS3 now by following a book. My code is exactly the way it is in the book and everything in my library (the buttons, movieclips) are linked correctly, but I keep getting the same error 1010 that a term is undefined or has no properties. I want to know if I'm being dumb (I hope not), or if the book is outdated. Hopefully someone can help. I put in a picture of what my assets look like, as well as the code below it.

asLinkage.jpg

package  {

          import flash.display.MovieClip;

          import flash.events.MouseEvent;

          public class Main extends MovieClip{

                    var startPage:StartPage;

                    var hillPage:HillPage;

                    var pondPage:PondPage;

                    public function Main() {

                              startPage = new StartPage();

                              hillPage = new HillPage();

                              pondPage = new PondPage();

                              addChild(startPage);

                              startPage.HillButton.addEventListener(MouseEvent.CLICK, onHillButtonClick);

                              startPage.PondButton.addEventListener(MouseEvent.CLICK, onPondButtonClick);

                    }

                    function onHillButtonClick(event:MouseEvent):void{

                              addChild(hillPage);

                              removeChild(startPage);

                    }

                    function onPondButtonClick(event:MouseEvent):void{

                              addChild(pondPage);

                              removeChild(startPage);

                    }

          }

}

TOPICS
ActionScript
673
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 02, 2014 Mar 02, 2014

You should go into your Flash Publish Settings and select the option to Permit Debugging.  That can enhance your error messages to include line numbers for the offending code.

From what I see I suspect you are miscoding the names of the buttons inside the StartPage instance.  The names HillButton and PondButton are the class names based on what your library image shows, they are not the instance names... at least hopefully they are not.

Translate
LEGEND ,
Mar 02, 2014 Mar 02, 2014

You should go into your Flash Publish Settings and select the option to Permit Debugging.  That can enhance your error messages to include line numbers for the offending code.

From what I see I suspect you are miscoding the names of the buttons inside the StartPage instance.  The names HillButton and PondButton are the class names based on what your library image shows, they are not the instance names... at least hopefully they are not.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2014 Mar 02, 2014

I did the Permit Debugging thing and the output error code became:

TypeError: Error #1010: A term is undefined and has no properties.

          at Main()

Which I can only assume means whats wrong is with line 19 (which would be the HillButton event listener line), but the problem isn't really obvious to me just by looking.

Also, when I tried adding instance names, it gave me this compiler error for both buttons.

Symbol 'StageOne'1046: Type was not found or was not a compile-time constant: HillButton.

I'm sure its just something really dumb on my part. I'm probably gonna keep trying out different little things to fix it but I'm not really sure whats wrong. Thanks for the help so far though!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 02, 2014 Mar 02, 2014

I already indicated what the problem is with that line (and the one after it).  HillButton is the name you assigned as the class name... look at your library to see that.  You cannot use a class name as an instance name.  You will need to use maybe something like "hillButton"... so that it does not spell the same as the class name "HillButton", and you target it using the instance name, not the class name.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2014 Mar 02, 2014

OH! You know now that I'm rereading your original post I definitely feel dumb haha. Ive been trying a bit and I've just been kind of frustrated with it so sorry for that. I'll let you know if it worked when I get home, but that sounds like the issue. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2014 Mar 02, 2014
LATEST

Thank you so much! I was about to go insane! Haha. thats gonna be a lot of help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines