package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class FallowRoad extends Sprite
{
private var ball:Ball = new Ball ;
private var array:Array = new Array ;
private var num:Number = new Number ;
public function FallowRoad()
{
addChild(ball);
//ball.y = 100;
this.graphics.lineStyle(1,0x00ff00);
stage.addEventListener(MouseEvent.MOUSE_DOWN,_onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP,_onMouseUp);
}
public function _onMouseDown(event:MouseEvent):void
{
array.push(mouseX,mouseY);
this.graphics.moveTo(mouseX,mouseY);
stage.addEventListener(MouseEvent.MOUSE_MOVE,_onMouseMove);
}
public function _onMouseMove(event:MouseEvent):void
{
array.push(event.stageX,event.stageY);
this.graphics.lineTo(event.stageX,event.stageY);
}
public function _onMouseUp(event:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE,_onMouseMove);
addEventListener(Event.ENTER_FRAME,_onEnterFrame);
}
public function _onEnterFrame(event:Event):void
{
ball.x = array[num++];
ball.y = array[num++];
if (num >= array.length)
{
removeEventListener(Event.ENTER_FRAME,_onEnterFrame);
}
}
}
}
/*
var arr:Array = [630,240,566,240,566,106];
var num:int = 0;
for (var i:int=0; i<3; i++)
{
var b:int = arr[num++];
var c:int = arr[num++];
trace("b======="+b);
trace("c======="+c);
}
*/