Sorry. The code I posted was wrong for you. Had to switch over from C++ thinking to AS thinking. Here is the code you want:
Code:
map.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
map.addEventListener(MouseEvent.ROLL_OUT, manageMouseOut, false, 0, true);
var lineX:linex = new linex();
var lineY:liney = new liney();
function track(e:Event):void
{
lineX.x = mou***;
lineX.y = mouseY;
lineY.x = mou***;
lineY.y = mouseY;
}
function manageMouseOver(event:MouseEvent):void
{
Mouse.hide();
addChild(lineX);
addChild(lineY);
stage.addEventListener(MouseEvent.MOUSE_MOVE, track);
}
function manageMouseOut(event:MouseEvent):void
{
Mouse.show();
removeChild(lineX);
removeChild(lineY);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, track);
}
(mou*** = m o u s e X)
We pulled the lineX and lineY variables out of the functions.
We added a removeEventListener to the manageMouseOut function.
We also added Mouse.show() to show the mouse again, and two removeChild() for lineX and lineY.
This will remove the objects from the stage, but keep their variables alive so that we can simply add them back to the stage when needed.
Bookmarks