Skip to main content
AnaG1998
Participant
August 3, 2016
Answered

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

  • August 3, 2016
  • 1 reply
  • 6290 views

Having an issue with creating a website in Animate CC with ActionScript3.

Any help would be appreciated.

Basically I am trying to get buttons "home" "about" "services" "contact" to work when clicked.

import flash.events.MouseEvent;

stop();

header_mc.home_btn.addEventListener(MouseEvent.CLICK, gohome);

function gohome (event:MouseEvent):void{

  gotoAndStop(1);

}

header_mc.about_btn.addEventListener(MouseEvent.CLICK, goabout);

function goabout (event:MouseEvent):void{

  gotoAndStop(2);

}

header_mc.services_btn.addEventListener(MouseEvent.CLICK, goservices);

function goservices (event:MouseEvent):void{

  gotoAndStop(3);

}

header_mc.contact_btn.addEventListener(MouseEvent.CLICK, gocontact);

function gocontact (event:MouseEvent):void{

  gotoAndStop(4);

}

Ran test after permitting debugging and got

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

  at WORKINGwebsite_fla::MainTimeline/frame1()[WORKINGwebsite_fla.MainTimeline::frame1:3]

This topic has been closed for replies.
Correct answer Ned Murphy

Frame 1 line 3. 

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).

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
August 3, 2016

Frame 1 line 3. 

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).