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

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

New Here ,
Dec 08, 2012 Dec 08, 2012

I have created a simple Flash program with two buttons. When a button is clicked, it should switch to a new page, but I've been receiving this error:

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

          at Main()

I know this error is common and I've been looking everywhere for a solution but I can't find one. It looks like there is a problem with the buttons but I feel like I've tried everything and it still won't work Here is my code:

package

{

          import flash.display.MovieClip;

          import flash.events.MouseEvent;

 

          public class Main extends MovieClip

          {

 

          var startPage:StartPage;

          var yellow:Yellow;

          var green:Green;

 

          public function Main()

          {

                    startPage = new StartPage();

                    yellow = new Yellow();

                    green = new Green();

                    addChild(startPage);

 

                    //add event listeners

                    startPage.yellowButton.addEventListener(MouseEvent.CLICK,onYellowButtonClick);

                    startPage.greenButton.addEventListener(MouseEvent.CLICK,onGreenButtonClick);

          }

          //event handlers

          function onYellowButtonClick(event:MouseEvent):void

          {

                    addChild(yellow);

                    removeChild(startPage);

          }

          function onGreenButtonClick(event:MouseEvent):void

          {

                    addChild(green);

                    removeChild(startPage);

          }

          }

}

TOPICS
ActionScript
3.7K
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

Community Expert , Dec 08, 2012 Dec 08, 2012

that's supposed to be yellowButton, not YellowButton. case counts in actionscript

do the same for greenButton and you should be good to go.

p.s. please mark helpful/correct responses.

Translate
Community Expert ,
Dec 08, 2012 Dec 08, 2012

line 21 contains the non-existant object.  if that info doesn't help you solve the problem, indicate which is line 21.

most likely startPage doesn't have one or both of those buttons defined when your code executes.

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 ,
Dec 08, 2012 Dec 08, 2012

Line 21:

startPage.yellowButton.addEventListener(MouseEvent.CLICK,onYellowButtonClick);

Here is the properties dialog for YellowButton:

Untitled-1.jpg

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
Community Expert ,
Dec 08, 2012 Dec 08, 2012

that's irrelevant to this discussion, so far.

attach a screenshot of of your StartPage movieclip with the button (you think) is yellowButton selected and showing the properties panel.

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 ,
Dec 08, 2012 Dec 08, 2012

Here is the StartPage movieclip - YellowButton is color A:

StartPage.jpg

StartPage properties:

StartPage_Properties.jpg

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
Community Expert ,
Dec 08, 2012 Dec 08, 2012

in the ide, click on color A (to select it), then take a screenshot showing the properties panel (not the symbol properties panel).

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 ,
Dec 08, 2012 Dec 08, 2012

I apologize I am new to Flash but is this what you mean?

Properties.jpg

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
Community Expert ,
Dec 08, 2012 Dec 08, 2012

that's the correct panel but the screen shot shows the properties panel with the stage selected. 

click the button you think is yellowButton in your StartPage movieclip (color A) and then take a screenshot showing that properties panel.

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 ,
Dec 08, 2012 Dec 08, 2012

Okay so I opened the YellowButton properties panel and noticed the name was blank, so I changed the name to YellowButton:

Properties.jpg

Now though I'm getting these compiler errors:

1046: Type was not found or was not a compile-time constant: YellowButton.

1046: Type was not found or was not a compile-time constant: GreenButton.

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
Community Expert ,
Dec 08, 2012 Dec 08, 2012

that's supposed to be yellowButton, not YellowButton. case counts in actionscript

do the same for greenButton and you should be good to go.

p.s. please mark helpful/correct responses.

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 ,
Dec 08, 2012 Dec 08, 2012

Thank you so much!

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
Community Expert ,
Dec 08, 2012 Dec 08, 2012
LATEST

you're welcome.

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