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.

Guest
Jan 25, 2013 Jan 25, 2013

error:

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

          at Untitled_fla::MainTimeline/frame1()[Untitled_fla.MainTimeline::frame1:4]

code:

asdf.addEventListener(MouseEvent.CLICK, onClick);

asdfasdf.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void

{

          text1.text = e.target.text

}

asdf is in frame 1

asdfasdf is in frame 2

text1 is in frame 1

how do i get the code to work without causing the error?

TOPICS
ActionScript
871
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 , Jan 25, 2013 Jan 25, 2013

if asdfasdf doesn't exist until frame 2, you can't use code referencing it in frame 1.

either move the code or move the object or you'll need to use code to check if frame 2 has played and then execute the code referencing asdfasdf

p.s. an object can exist in frame 1 and not be visible until frame 2 is played

Translate
Community Expert ,
Jan 25, 2013 Jan 25, 2013

one (or more) of the line 4 objects referenced doesn't exist when that code executes.

which is line 4, which frame has that code and are there any referenced objects in more than 1 keyframe?

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
Guest
Jan 25, 2013 Jan 25, 2013

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

          at Untitled_fla::MainTimeline/frame1()[Untitled_fla.MainTimeline::frame1 :2]

the error was actually this one the one in top is another error before

asdfasdf is not in keyframe 1 it's in keyframe 2

is there a way I can make asdfasdf readable for onClick function?

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 ,
Jan 25, 2013 Jan 25, 2013

if asdfasdf doesn't exist until frame 2, you can't use code referencing it in frame 1.

either move the code or move the object or you'll need to use code to check if frame 2 has played and then execute the code referencing asdfasdf

p.s. an object can exist in frame 1 and not be visible until frame 2 is played

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
Guest
Jan 25, 2013 Jan 25, 2013

Thank you

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 ,
Jan 25, 2013 Jan 25, 2013
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