Я думаю, что на самом деле легче увидеть в коде, чем объяснить. Не то, чтобы вы не читали об использовании точек мыши, но для обзора приведенный ниже код должен дать вам довольно хорошее начало использования точек, учитывая то, что у вас есть выше. Пожалуйста, смотрите комментарии для деталей.
// It helps to keep all the imports at hte top of your file, for easy code reading.
import flash.events.MouseEvent;
import flash.geom.Point;
// It helps to keep all class-level variables at the top of the file.
// Make an array rather than many individual variables. That way you can use a for-loop to access the items.
// (The brackets "[]" are equivalent to new Array().)
var localPosArray:Array = [];
var globalPosArray:Array = [];
var ellipseArr:Array = [];
// can use these as temporary variables:
var localPoint:Point;
var globalPoint:Point;
// stores currently active ellipse index:
var curEllipseIdx:int;
// stores currently active point index:
var curPtIdx:int;
// store click count:
// (You could use an array instead, but probably not necessary.)
var countTotal:int = 0;
// Probably not needed:
// var posOne:Number;
//var posTwo:Number;
//var posThree:Number;
//var posFour:Number;
//var posFive:Number;
stage.addEventListener(MouseEvent.MOUSE_DOWN, startDoodle);
stage.addEventListener(MouseEvent.MOUSE_MOVE, sizeDoodle);
stage.addEventListener(MouseEvent.MOUSE_UP, stopDoodle);
function startDoodle(ev:MouseEvent):void
{
// count clicks (mouse downs):
countTotal++;
// to find the coordinates on the local object -- this is usually different from the global coordinates.
curPtIdx = localPosArray.length;
localPosArray[curPtIdx] = new Point(ev.localX, ev.localY);
// alternately, to overwrite a current point:
// curPtIdx = 0;
// localPosArray[curPtIdx] = new Point(ev.localX, ev.localY); // the old value will be garbage collected, if there are no other references.
// to convert from local to global coordinates:
// curPtIdx = 0;
// globalPoint = localToGlobal(localPosArray[curPtIdx]);
// alternately, to find the coordinates on the global object (the stage):
curPtIdx = globalPosArray.length;
globalPosArray[globalPosArray.length] = new Point(ev.stageX, ev.stageY);
// alternately, to overwrite a current point:
// curPtIdx = 0;
// globalPosArray[curPtIdx] = new Point(ev.stageX, ev.stageY); // the old value will be garbage collected, if there are no other references.
// to convert from local to global coordinates:
// curPtIdx = 0;
// localPoint = globalToLocal(globalPosArray[curPtIdx]);
//You do not need to stop listening for mouse *down*, since that can never happen when the mouse is down.
// stage.addEventListener(MouseEvent.MOUSE_DOWN, makeTarget);
}
function stopDoodle(e:MouseEvent):void
{
//You do not need to stop listening for mouse *up*, since that can never happen when the mouse is up.
//stage.removeEventListener(MouseEvent.MOUSE_UP, makeTarget);
}
function makeTarget(e:MouseEvent):void
{
curPtIdx = 0;
curEllipseIdx = ellipseArr.length;
ellipseArr[curEllipseIdx] = new Ellipse(localPosArray[curPtIdx].x, localPosArray[curPtIdx].x, 0x00ff00);
addChild(ellipseArr[curEllipseIdx]);
// These lines are probably not necessary:
//ellipse.x = mouseX;
//ellipse.y = mouseY;
// What is this for?
//posOne == ellipse.x && ellipse.y
}
function sizeDoodle(ev:MouseEvent):void
{
if (ellipseArr && ellipseArr[curEllipseIdx])
{
// size the ellipse by the distance from the initial point:
// however you might do that.
}
}