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.