Skip navigation
Currently Being Moderated

ActionScript on two buttons works, ActionScript on one button doesn't.

Apr 18, 2012 9:09 AM

Tags: #help #flash #button #buttons #as2 #actionscript #game #2.0

For some reason, the ActionScript I have on two buttons in my game. When the program starts, it goes to the first page, which has two buttons leading to other scenes. Those two buttons work. One of them is a directions button that leads to the directions page. I have another button on my directions page that I want to go back to the title page, the scene with the two buttons. (By the way, I'm using ActionScript 2)

 

The code I used for the first two buttons:

 

DirectionsButton.onRelease=function(){

    gotoAndPlay("Directions",1);

}

 

PlayButton.onRelease=function(){

    gotoAndPlay("Game",1);

}

 

---------------------------------------------------------------------- ----------------------

 

The code I used for the Back button on the Directions scene:

 

BackButton.onRelease=function(){

    gotoAndPlay("Title",1);

}

 

---------------------------------------------------------------------- -----------------------

 

For some reason, it's in the exact same format and the exact same way as the other two buttons, but it WILL NOT work. The cursor turns into the hand instead of the arrow, but nothing happens when I click on it. The codes are in the background of each scene, and each of them are buttons. Two of them work, but the other doesn't!

 

It's really annoying, so please help me. Thank you in advance!

 
Replies
  • Currently Being Moderated
    Apr 18, 2012 9:19 AM   in reply to Losan33

    As long as the code for the lone button is in the same frame as the button, there shouldn't be a problem with the code you show.  You should put a trace() in the lone button's function to see if it is working at all.  If it is not, then you might need to check instance names or that the code is in the frame and not on the button.  If it does trace, then check that you have a scene named Directions, and maybe a stop() command somewhere in it such that you aren't speeding right thru it without stopping.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 1:11 PM   in reply to Losan33

    Not that it's any consolation, but using scenes is not a recommended practice - so if you are only doing it for your coursework, you should plan on forgetting about using them in the future.  Thy can be troublesome without reason as you are finding out.  Just as a matter of further trial, instead off using just  gotoAndPlay("Directions",1);   try using    _root.gotoAndPlay("Directions",1);

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 20, 2012 11:55 AM   in reply to Losan33

    Are you kidding!? - If you wanted to go to title then just CHANGE THAT CODE so Title is in it instead of directions! It's not that hard, don't be so mean about it. Ned is trying to help, you don't have be mean to him due to your ignorance.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 21, 2012 5:52 AM   in reply to Losan33

    I wouldn't call it mean, just ignorant and childish.  I offered an example that you should apply to all of them.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points