3 Replies Latest reply on May 31, 2008 12:42 PM by clbeech

    Fustrating problem with self-made 5-state button

      Hey guys, just wondering if you could help me, i don't have much knowledge with actionscript and i created my own 5 state button using a movie clip and a little bit of actionscript by following a tutorial online. ( http://www.sanctifiedstudios.com/advanced-five-state-buttons/)

      Basically, when rolled over, the button slides out, and when rolled off, the button slides back in. The problem is, while the button is rolling back in, if you flick your mouse onto the button again quickly, instead of restarting the roll-out animation, the button just flickers quickly between the in position and the out position.

      You can see it for yourself here: www.everlightmusic.com < hover your mouse over the buttons on the right, move your mouse off, and then while its rolling back in, quickly move your mouse back onto it.

      The actionscript for the buttons is this:


      this.onRollOver = function(){
      this.onRollOut = function(){
      this.onPress = function(){
      this.onRelease = function(){
      this.onReleaseOutside = function(){
      this.onRelease = function(){

      And here is a screenshot of the movie clip timeline:


      Any help with this would be greatly appreciated :)
        • 1. Re: Fustrating problem with self-made 5-state button
          clbeech Level 3
          yeah this is typical when using a timeline based button action. two things you could do:

          1) control the state change by using a variable to indicate when the motion is complete (or not) like 'isOpen' - you'd need to do this for each button in combination with a condition in the handler that 'reads' the var and determines the course of action - of course the next problem is that if you 'rollout' while the motion is happening and the handler fires previous to the setting of the var to it's 'new' state it won't close because the condition would only be fired once - the only way around that would be to include a loop that runs until the condition is satisfied.

          2) much better than the above method (which would get messy fast) is to simply use the 'tween' class to create you motions, you can then 'open' or 'close' from what ever the current position of the clip is at the moment the handler is fired. you've got your code on the timeline of the 'button' MC (good job) so you could change it to something like this:
          • 2. Re: Fustrating problem with self-made 5-state button
            EverLightMusic Level 1
            Thanks so much! The second option fixed it right up, Just a little bit of tweaking with the variables and its done. looks sleeker too!

            Thanks for the quick solution!
            • 3. Re: Fustrating problem with self-made 5-state button
              clbeech Level 3
              you're welcome - no problem :)