# Simple Loop Help

**URL:** <https://forum.kirupa.com/t/simple-loop-help/332459>\
**Category:** flash\
**Created:** [June 16, 2014, 2:22am UTC](https://forum.kirupa.com/t/simple-loop-help/332459 "2014-06-16T02:22:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TAves](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@TAves](https://forum.kirupa.com/u/TAves)\
**Post date:** [June 16, 2014, 2:22am UTC](https://forum.kirupa.com/t/simple-loop-help/332459/1 "2014-06-16T02:22:58Z")

</div>

```auto

this.addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event):void{
    
    //check x and y position of each piece and 
    //see if they are within the correct range.
        
    for (var i = 0; i < puzzleArray.length; i++){
        
        trace("looping");
        var tolerance = 20;
            
        if ((puzzleArray*.x < (436.95 + i*125 + tolerance)) && 
            (puzzleArray*.x > (436.95 + i*125 - tolerance))){
                puzzleArray*.x = 436.95 + i*125;
                trace("x position");
        }
            
        if ((puzzleArray*.y < 116.8 + i*83.25 + tolerance) &&
            (puzzleArray*.y > 116.5 + i*83.25 - tolerance)){
                puzzleArray*.y = 116.5 + i*83.25;
        }
        
    }

}

```

So basically I have an array (puzzleArray) with the puzzle pieces within it. Each piece is draggable, and when it comes into range (as specified by tolerance) I want the x and y position to be set to a certain value.

The actual loop is executing, but the if conditionals within the loop aren’t (‘x position’ isn’t being traced). The compiler throws no errors. …I’m stuck. 🙂
