There is interesting problem that is not shows in flash target.
I’m drowning a path with MouseMove, and get an array of a Points. Then I make my circle follow point by point.
And the problem is: when my circle reaches last point - application crashes. As I told previously there is no such problem when targeting flash.
The is code:
public function onFrame(e:Event)
{
if (canMove == true)
{
if (i < posis.length)
{
colliz = Math.sqrt(Math.pow((circle.x - pointToFollow.x), 2) + Math.pow((circle.y - pointToFollow.y), 2));
if (colliz <= 30)
{
i++;
followPut();
return;
}
}
circle.x += speedX;
circle.y += speedY;
}
}
public function onMouseCircleDown(e:MouseEvent)
{
canMove = false;
posis.splice(0, posis.length);
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
public function onMouseMove(e:MouseEvent)
{
putLayer.addChild(new Particle(e.stageX, e.stageY));
posis.push(new Point(e.stageX, e.stageY));
}
public function onMouseUp(e:MouseEvent)
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
followPut();
canMove = true;
}
public function followPut()
{
pointToFollow = posis[i];
speedX = pointToFollow.x - circle.x;
speedY = pointToFollow.y - circle.y;
modul = Math.sqrt(Math.pow(speedX,2) + Math.pow(speedY,2));
speedX = (speedX/modul) * 3;
speedY = (speedY/modul) * 3;
}