# For loop help - nooby

**URL:** <https://forum.kirupa.com/t/for-loop-help-nooby/316798>\
**Category:** Uncategorized\
**Created:** [December 2, 2010, 5:14pm UTC](https://forum.kirupa.com/t/for-loop-help-nooby/316798 "2010-12-02T17:14:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BadBoyMcCoy](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@BadBoyMcCoy](https://forum.kirupa.com/u/BadBoyMcCoy)\
**Post date:** [December 2, 2010, 5:14pm UTC](https://forum.kirupa.com/t/for-loop-help-nooby/316798/1 "2010-12-02T17:14:21Z")

</div>

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:

```auto
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
