3 Replies Latest reply on Mar 3, 2014 8:56 PM by Saurav

    Random Animation for 4 Buttons

    magic_mushy Level 1

      Hello lovely people. I seek help. I appologise but I have no competency with Javascript.


      I have 4 buttons wich are 4 different symbols. Each button has a simple 1second animation. I have a mouseover and a mouseout script attached to an invisable rectangle over each button/symbol.









      When the mouse enters a button it plays the animation forward. When the mouse leaves the button the animation plays in reverse.


      What I want is the page to load and prior to a user placing the mouse cusor in one of the buttons. A button to be chosen at random, the button animation to play. Once the animation is complete I want it to play in reverse. Then choose another button at random and repeat infintely until a user places the mouseover a button. When the user places a mouse cursor over a button I want the button to check if it's at the end of the buttons animation. If the button is at the end of the animation I want the buttom animation state to stop. If the button is not at the end of the animation I want it to play to the end of the animation. I also want to check the animation state of all the other buttons. If any of the animations are in the process of playing or at the end of their animation I want them reversed.


      I currently have a script attached to the stage.


      var randomNum = Math.floor((Math.random()*4)+1);

      if (randomNum == 1){



      else if (randomNum == 2){



      else if (randomNum == 3){



      else {




      When the page loads it selects a button at random and plays the animation.


      You can view the sample page here. http://www.fnwireless.net/Test%204%20Buttons.html


      A big thankyou to anyone who posts a reply. If you need any further clarrification for my ramblings please let me know.