Skip to main content
Participant
March 5, 2013
Answered

as3 Problem

  • March 5, 2013
  • 1 reply
  • 336 views

I was wondering how you can edit a Movie Clip, in one frame when the action script controlling it is on another frame. (Both in the same layer though.)

The context is I am making a maze game and each frame is a room on the maze, there is a locked door in one room and a key in another. When you find the key and click it the door will be unlocked and you will be able to progress further within the maze.

The exact error is "TypeError: Error #1009: Cannot access a property or method of a null object reference."

My code is.... ("gKey" is in the current frame while "A25" and "gLock" are in another frame)

  1. gKey.addEventListener(MouseEvent.CLICK, GreenUnlock);

Function GreenUnlock(m:MouseEvent)

{

    A25.addEventListener(MouseEvent.CLICK, hop25);

    gLock.visible = false

}

function hop25(m:MouseEvent)

{

    gotoAndStop(13);

}

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

The short answer is most likely that you cannot try to execute code for an object that does not exist in the frame where the code executes.  You will need to either move the object to where the code is or move the code to where the object is.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
March 5, 2013

The short answer is most likely that you cannot try to execute code for an object that does not exist in the frame where the code executes.  You will need to either move the object to where the code is or move the code to where the object is.