Skip to main content
Participating Frequently
December 5, 2010
Question

Buttons to Navigate forward and Back but gets Stuck in Back.

  • December 5, 2010
  • 1 reply
  • 1303 views

Hey guys, I am making a project for my college class and it has to do with creating an interactive environment in flash CS4.  Similar to 99 rooms if anyone has gone and seen that famous piece of work.

Anyways I am using action script 3.0 and I created multiple layers using just one scene.  I created a layer with lables on them to mark where I want my buttons to point to and go to.  I have the stop (); on the first frame.  And I made my buttons mostly interactive with movie symbols and tweens.


My first scene I have 2 doors, the user can pick which door to go to and it takes them into a different path.

I made the buttons that are clicked to go forward, and then I tried to make an invisible button on the button edge of the scene to go backwards.  However, the PROBLEM is when I click my button to go backwards I am stuck on the first page and can't move forward.

My AS code is this

function gotoOne(evt:Event):void{
    gotoAndStop("one")
}
backbutton1.addEventListener("click",gotoOne);

function gotoFour(evt:Event):void{
    gotoAndStop("four")
}
buttonforward1.addEventListener("click",gotoFour);

Basically to sum it up the first code is of course for the button to go backwards.  And the forward buttons skips a scene to go forward.  I have another code for the 2nd door to go back as well.

function gotoOne1(evt:Event):void{
    gotoAndStop("one")
}
backbutton2.addEventListener("click",gotoOne1);

I made it say gotoOne1 because I have 2 rooms going back to the same home page room.  So it prevents stuff from going out of whack.

Now here are my error messages.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at finalprojectPractice1_fla::MainTimeline/frame1()
    at flash.display::MovieClip/gotoAndStop()
    at finalprojectPractice1_fla::MainTimeline/gotoOne()

So I am not sure what to do, even my Professor took an hour to try to help me and she couldnt figure it out.  And it would make my project 100 percent better if I can go backward and forward in my environment with my buttons.  Hope you guys can help

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 5, 2010

click file/publish settings/flash and tick "permit debugging".  retest.

copy and paste the the entire error message and highlight the line of code referenced in the error messag.e

Participating Frequently
December 5, 2010

Ok I did what you asked me to do and copy and paste the error code.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at finalprojectPractice1_Scene1_fla::MainTimeline/frame1()[finalprojectPractice1_Scene1_fla.MainTimeline::frame1:9]
    at flash.display::MovieClip/gotoAndStop()
    at finalprojectPractice1_Scene1_fla::MainTimeline/gotoOne()[finalprojectPractice1_Scene1_fla.MainTimeline::frame10:2]

kglad
Community Expert
Community Expert
December 5, 2010

copy and paste the the entire error message and highlight the line of code referenced in the error message

what's line 9 of your code?