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

TypeError: Error #1009: Cannot access a property or method of a null object reference.

New Here ,
Jul 27, 2013 Jul 27, 2013

Hi,

I'm a n00b to AS3 and i'm having a hard time with 2 things...

Problem 1:

I've got buttons linking my frames back and forth, and they all seem to work when clicked, however every single button brings up this error (TypeError: Error #1009: Cannot access a property or method of a null object reference.) everytime when the movie is being tested...

and I have no idea what it means, surfing around google it seems like I have the right code for making buttons. So it's a bit frustrating.

My button code is :

back_btn.addEventListener(MouseEvent.CLICK, startScreen);

function startScreen(eventData:MouseEvent):void { gotoAndStop(1);

back_btn.removeEventListener(MouseEvent.CLICK, startScreen); }

Everything has an instance name.

Problem 2:

I have a few buttons on my stage that when clicked reveal text in multiple text fields, I was wondering how, when I click a back button i've coded, Would i make the text clear itself again? Since once the buttons are clicked the text appears on every frame, even when clicking the back button to go back to the start screen of my app and play everything through again.

Any help would be greatly appreciated, thanks for your time.

TOPICS
ActionScript
469
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 ,
Jul 27, 2013 Jul 27, 2013
LATEST

The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

 

- is declared but not instantiated

- doesn't have an instance name (or the instance name is mispelled)

- does not exist in the frame where that code is trying to talk to it

- is animated into place but is not assigned instance names in every keyframe for it

- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

 

If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

If you want to clear textfields you can juast assign an empty string to them, as in... tField.text = "";   So make your back button do that for whatever textfields need to be reset.

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