第一帧代码:
var i:Number = 0;
var posAry:Array=new Array();
this.graphics.moveTo(ball.x,ball.y);
function hxhs(e)
{
this.graphics.lineStyle(10,0xff0000,0.5);
posAry.push([ball.x,ball.y]);
this.graphics.lineTo(posAry[posAry.length-1][0],posAry[posAry.length-1][1]);
}
this.addEventListener(Event.ENTER_FRAME,hxhs);
停止的关键帧代码:
stop();
var index:int=0;
var temp:int=0;
trace(posAry.toString());
this.removeEventListener(Event.ENTER_FRAME,hxhs);
//this.graphics.clear();
//this.graphics.moveTo(posAry[0][0],posAry[0][1]);
this.addEventListener(Event.ENTER_FRAME,ClearLineEvent);
function ClearLineEvent(e:Event):void
{
temp++;
if(temp%2!=0)
{
return;
}
this.graphics.clear();
this.graphics.moveTo(posAry[index][0],posAry[index][1]);
for(var i:int=index;i<posAry.length;i++)
{
this.graphics.lineStyle(10,0xff0000,0.5);
this.graphics.lineTo(posAry[i][0],posAry[i][1]);
}
index++;
trace(index);
if(index==posAry.length)
{
this.removeEventListener(Event.ENTER_FRAME,ClearLineEvent);
}
}