I've been searching around for some answers to this issue, but nothing seems to work when I try to find a solution.
What I'm trying to achieve is to make a spinner in Javascript & Adobe Edge that randomly spins on a number, and does not repeat that number again until all numbers have been spinned.
I know this should be fairly easy to do for a decent coder, but I'm not that experienced yet.
This is what I have so far, but it is unfinished and buggy:
var myArray = ['360', '330', '300', '270', '240', '210', '180', '150', '120', '90', '60', '30'];
var Spinner1 = sym.$('Spinner1');
Spinner1.click(function(){
// randomize the degree of spin.
var mySpin = myArray[Math.floor(Math.random() * myArray.length)];
sym.getSymbol('Spinner1').play();
Spinner1.css({
'-webkit-transform': 'rotate(' + mySpin + 'deg)',
'-moz-transform': 'rotate(' + mySpin + 'deg)',
'-ms-transform': 'rotate(' + mySpin + 'deg)',
'-o-transform': 'rotate(' + mySpin + 'deg)',
'transform': 'rotate(' + mySpin + 'deg)',
});
Spinner1.css('-webkit-transition','all 500ms cubic-bezier(0.420, 0.000, 1.000, 1.000)');
if (mySpin > 300 && mySpin < 360) {
alert("Winner is number 1!");
}
});
Hope someone could help me out. Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…