My code is working but I have 1 small problem and one bit of code that I want to make better.
1. The problem: The symbol that is the custom cursor is under a box. So, I would like to swap the movieclips or some how move the cursor's movie clip to the top.
2. When I click and drag something I would like the loaded custom cursor icon to change to a different custom cursor (a movie clip in my library), then when I release go back to the original custom cursor.
Regards,
Glen Charles Rowell
Code:
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;
stage.addEventListener(Event.ENTER_FRAME, moveMouse);
function moveMouse(Event) {
Mouse.hide();
cursor.x = mouseX;
cursor.y = mouseY;
}
var board:Sprite = new Sprite();
stage.addChild(board);
//swapChildren( board, cursor );
board.addChild(dragThis);
trace(stage.getChildAt(0).name); // sprite2
trace(stage.getChildAt(1).name); // sprite1
board.graphics.lineStyle(1,0);
board.graphics.beginFill(0xCCCCCC,0.7);
board.graphics.drawRect(0,0,200,300);
board.graphics.endFill();
board.x = 100;
board.y = 10;
dragThis.x = 50;
dragThis.y = 50;
dragThis.addEventListener(MouseEvent.MOUSE_DOWN, startMove);
function startMove(evt:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, pointMove);
}
function pointMove(e:MouseEvent):void {
dragThis.x = goodX(board.mouseX);
dragThis.y = goodY(board.mouseY);
e.updateAfterEvent();
}
stage.addEventListener(MouseEvent.MOUSE_UP, stopMove);
function stopMove(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, pointMove);
}
function goodX(inX:Number):Number {
if (inX < 0) {
return 0;
}
if (inX > 200) {
return 200;
}
return inX;
}
function goodY(inY:Number):Number {
if (inY < 0) {
return 0;
}
if (inY > 300) {
return 300;
}
return inY;
}
Bookmarks