when tracing the mouseX / mouseY
or localX / localY
coordinates of a display object, why does x
start at 1 while y
starts at 0?
for example, i've drawn a simple 400 x 400 pixel sprite onto the stage with a MouseEvent.MOUSE_MOVE
event listener that calls a handler function to trace the local coordinates of the mouse.
the first, top-left pixel returns {x:1, y:0}
and the last, bottom-right pixel returns {x:400, y:399}
. shouldn't both the x
and y
start and end with the same value? i'm not sure which makes more sense for a the first mouse coordinate (either 0 or 1) but it certainly doesn't make sense that they are different?
[SWF(width = "1000", height = "600", backgroundColor = "0xCCCCCC")]
import flash.display.Sprite;
import flash.events.MouseEvent;
var darkBlueRect:Sprite = createSprite();
darkBlueRect.x = 23;
darkBlueRect.y = 42;
addChild(darkBlueRect);
darkBlueRect.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveEventHandler);
function mouseMoveEventHandler(evt:MouseEvent):void
{
trace(darkBlueRect.mouseX, evt.localX, darkBlueRect.mouseY, evt.localY);
}
function createSprite():Sprite
{
var result:Sprite = new Sprite();
result.graphics.beginFill(0x0000FF, 0.5);
result.graphics.drawRect(0, 0, 400, 400);
result.graphics.endFill();
return result;
}