Skip to main content
Known Participant
September 4, 2014
Question

Actionscript 3 Class Not Running More Than Once After Using The GoToAndStop function

  • September 4, 2014
  • 1 reply
  • 406 views

I'm having a strange issue, and I am sure it's due to my lack of knowledge about how classes fully work in Adobe AIR (Flash CC). I've created a login button that is connected to a function, and based on a set of conditions it will take you to a different frame with the GoToAndStop function. I've created a logout button that is suppose to take you "back" to the login frame (that has the login button) if you click the logout button using the GoToAndStop function. Up to this point, everything works until I try to click the Login button again, it does not do anything. It's like it does not even try to execute my class file anymore.

Does the class file only run at startup and never runs again, and if so, how can I create a section of code that is constantly monitoring what the user is doing no matter what frame you are on and no matter if I use the GoToAndStop function or not?

Thanks

This topic has been closed for replies.

1 reply

Known Participant
September 4, 2014

Hi there, try using gotoAndPlay to get to the frame, and the first line you have in the actionscript of that frame would be stop().

Here is another guess, without seeing your code, is that you are using a Boolean variable for the login button that is initially set to true...then when you go to other frame (logout frame), that login button Boolean variable has not been reset back to true to allow you to use the login button once again.

Justin

rs14smithAuthor
Known Participant
September 4, 2014

If your second guess is correct, how would I reset a button?

Known Participant
September 5, 2014

Based on your qyestion, I think I was wrong with my second guess.

When I want to create a button, what I do is draw a bitmap that looks like a button and then use a mouse event listener that looks for any part of the stage that is clicked.  You would use the same code for touch as well.  As3 will return the x.y. coordinate of the area that was clicked or touched.  When the xy coordinate is known, if it corrseponds to the area where the button is, I code the appropriate response.  Hence, I only use one event listener for all my buttons, as long as thet involve simple clicks or taps of the screen.

Good luck, Justin