infinite for loop problem
Code:
package
{
import flash.geom.*;
import flash.display.*;
import flash.events.*;
public class Main extends MovieClip
{
var sp:Sprite = new Sprite();
public function Main()
{ addChild(sp);
drawPoints(20,20);
}
public function drawPoints(sx=0,sy=0)
{
var ptArr = [0,0,10,0,10,10,10,20,60,20,60,10,60,0,70,0];
sp.graphics.lineStyle(1,0x00ff00);
sp.graphics.moveTo(sx,sy);
for(var i=2;i<ptArr.length;i+2) <--PROBLEM PORTION
{
sp.graphics.lineTo(ptArr[i]+sx,ptArr[i+1]+sy);
trace(i);
}
}
}
}
When I run the code, it seems to run eternally and freeze, however in the for loop, if I replace i+2 with i++ and put in another i++ inside, the problem doesn't occur.....any idea what's going on?