1 Reply Latest reply on Feb 5, 2014 5:36 AM by resdesign

    Random Rotation on click

    npackey

      I have a banner I have been working on with three spinners like a slot machine.  Currently I have everything hand animated to rotate the spinners to spin to one of 4 options each.  What I would like is to have a button that triggers the spinners to rotate to a random ( 1 of 4 ) points over the course of 1/2 second 500ns. 

       

      Is there a code snippit that will make an object rotate to one of 4 chosen variables?

        • 1. Re: Random Rotation on click
          resdesign Adobe Community Professional & MVP

          Hello; here is an example of a spinner I made. This is probably different from what you are doing but it will give you an idea of what you can do.

           

          spinner.png

          var spinner1 = sym.$('spinner1');

          spinner1.click(function(){

          // randomize the degree of spin.

                    var myVar1 = Math.floor((Math.random()*180)+10);

                    //alert(myVar1);

                    sym.getSymbol('spinner1').play();

                    spinner1.css({

                              '-webkit-transform': 'rotate(' + myVar1 + 'deg)',

                              '-moz-transform': 'rotate(' + myVar1 + 'deg)',

                              '-ms-transform': 'rotate(' + myVar1 + 'deg)',

                              '-o-transform': 'rotate(' + myVar1 + 'deg)',

                              'transform': 'rotate(' + myVar1 + 'deg)',

             });

             spinner1.css('-moz-transition','all 500ms cubic-bezier(0.420, 0.000, 1.000, 1.000)');

          });

          1 person found this helpful