Copy link to clipboard
Copied
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?
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now