Jason,
If you are trying to add a static item like a logo or text on top of the map then you need to use the map static layer. If you need your object to move with the map when it is panned then you will have to use a true Map XY.
private function applyMask( mousePt:Point ):void {
if (_currentRegion == NONE) {
return;
}
if (!_mask) {
const w:Number = map.width / Math.abs(map.scaleX);
const h:Number = map.height / Math.abs(map.scaleY);
const x:Number = mousePt.x;
const y:Number = mousePt.y;
const xy:Number = x + y;
_mask = new Shape();
var g:Graphics = _mask.graphics;
g.clear();
g.beginFill(0x000000);
// Render the mask based on the clicked region and the current mouse position
switch (_currentRegion) {
case LEFT:
g.drawRect(x, 0, w - x, h);
break;
case TOP:
g.drawRect(0, y, w, h - y);
break;
case RIGHT:
g.drawRect(0, 0, x, h);
break;
case BOTTOM:
g.drawRect(0, 0, w, y);
break;
case TOP_LEFT:
g.moveTo(w, h);
if (xy <= h) {
g.lineTo(0, h);
g.lineTo(0, xy);
} else {
g.lineTo(xy - h, h);
}
if (xy <= w) {
g.lineTo(xy, 0);
g.lineTo(w, 0);
} else {
g.lineTo(w, xy - w);
}
g.lineTo(w, h);
break;
case BOTTOM_RIGHT:
g.moveTo(0, 0);
if (xy <= w) {
g.lineTo(xy, 0);
} else {
g.lineTo(w, 0);
g.lineTo(w, xy - w);
}
if (xy <= h) {
g.lineTo(0, xy);
} else {
g.lineTo(xy - h, h);
g.lineTo(0, h);
}
g.lineTo(0, 0);
break;
case TOP_RIGHT:
g.moveTo(0, h);
if (x < y) {
g.lineTo(0, y - x);
} else {
g.lineTo(0, 0);
g.lineTo(x - y, 0);
}
if (w - x < h - y) {
g.lineTo(w, y + w - x);
g.lineTo(w, h);
} else {
g.lineTo(x + h - y, h);
}
g.lineTo(0, h);
break;
case BOTTOM_LEFT:
g.moveTo(w, 0);
if (w - x < h - y) {
g.lineTo(w, y + w - x);
} else {
g.lineTo(w, h);
g.lineTo(x + h - y, h);
}
if (x < y) {
g.lineTo(0, y - x);
g.lineTo(0, 0);
} else {
g.lineTo(x - y, 0);
}
g.lineTo(w, 0);
break;
}
g.endFill();
// Add the mask to the display list
map.addChild(_mask);
// Apply the mask to the target layer
layer.mask = _mask;
}
}