just a quick nooby question really. I’m pretty new to as2.
Basically I want each individual pudding to get a random number between 1 and 2 then rotate either clockwise or anti-clockwise depending on the result. However they all seem to be rotating the same way.
Here’s my code:
var random1_2;
function getRandom1_2() {
random1_2 = (Math.floor(Math.random()*2)+1);
}
var puddingXY = [[34.3,69.6],[490.3,69.6],[34.3,433.6],[488.3,433.6]];
for (i=0; i<puddingXY.length; i++) {
var pudding:MovieClip = _root.attachMovie("pudding", "pudding"+i, _root.getNextHighestDepth());
pudding._x = puddingXY*[0];
pudding._y = puddingXY*[1];
//start at random rotation
pudding._rotation = Math.floor(Math.random()*360+1);
getRandom1_2();
pudding.onEnterFrame = function() {
if(random1_2 == 1) {
this._rotation += 3;
} else {
this._rotation -= 3;
}
}
}
I’m sure it’s a simple answer, but like I said I’m pretty new.
Any help greatly appreciated.
Thanks