Skip to main content
Participant
May 12, 2010
Question

Button in a content Movie Clip

  • May 12, 2010
  • 1 reply
  • 598 views

Hi,

I need help on a button going to a frame "reservationpage".  I set a button  on  frame 3 in "treatmentspage" that should call on "reservationpage" in  frame 8.

I  have been using this code:

myreserve_btn.addEventListener(MouseEvent.CLICK,  onReservClick);

function onReservClick(evt:MouseEvent):void {
     gotoAndStop("reservation page");
   
     myreserve_btn.removeEventListener(MouseEvent.CLICK, onReservClick);
}

but keep  getting:

TypeError:  Error #1009: Cannot access a property or method of a null object  reference.
    at  SpaLuvicebestmassageoptionintown_fla::MainTimeline/frame3()
    at  flash.display::Sprite/constructChildren()
    at  flash.display::Sprite()
    at flash.display::MovieClip()
    at  SpaLuvicebestmassageoptionintown_fla::innnerbody_25()
    at  flash.display::Sprite/constructChildren()
    at  flash.display::Sprite()
    at flash.display::MovieClip()
    at  flash.display::MovieClip/gotoAndStop()
    at  SpaLuvicebestmassageoptionintown_fla::MainTimeline/bodymassagebtn_clicked()

can I get  help on this please?

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
May 12, 2010

Check that you have assigned the instance name "myreserve_btn" to the button in all keyframes that it exists in.  IF that is not all the code you have in frame 3, then you should go into your Publish Settings and select the option to Permit Debugging.  That will make it so that your error message includes the line number of the offending code/object.

shademupAuthor
Participant
May 12, 2010

Hi Ned,

Thank for the quick response. The button does have an instance name of "myreserve_btn" and it only seats on page layer in frame 3. and I changed publish settings and got this output message:

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

    at SpaLuvicebestmassageoptionintown_fla::MainTimeline/frame3()[SpaLuvicebestmassageoptionintown_fla.MainTimeline::frame3:1]

    at flash.display::Sprite/constructChildren()

    at flash.display::Sprite()

    at flash.display::MovieClip()

    at SpaLuvicebestmassageoptionintown_fla::innnerbody_25()

    at flash.display::Sprite/constructChildren()

    at flash.display::Sprite()

    at flash.display::MovieClip()

    at flash.display::MovieClip/gotoAndStop()

    at SpaLuvicebestmassageoptionintown_fla::MainTimeline/bodymassagebtn_clicked()[SpaLuvicebestmassageoptionintown_fla.MainTimeline::frame1:12]

Is there a way around this?

thanx in advance

Ned Murphy
Legend
May 12, 2010

The error is indicating that line 1 is the offending line,, so if that line is...

myreserve_btn.addEventListener(MouseEvent.CLICK,  onReservClick);

Then the error is telling you the myreserve_btn doesn't exist as far as the code is concerned.  That code and that button (by that instance name) need to be in the same frame of the same timeline for the error to be avoided.  Instance names are assigned to an object after you place it on the stage, in the Properties panel, where it says <Instance Name>.