package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.ui.Mouse; public class Main extends Sprite { private var circleMouse:Sprite = new Sprite(); private var squareMouse:Sprite = new Sprite(); private var currentMouse:Sprite = new Sprite();
private var useSquareField:Sprite = new Sprite(); private var useCircleField:Sprite = new Sprite();
public function Main() { useSquareField.graphics.beginFill(0xFFFFFF, 1); useSquareField.graphics.drawRect(0, 0, 100, 100); useSquareField.graphics.endFill(); useSquareField.name = "square"; useSquareField.x = 200;
useCircleField.graphics.beginFill(0xFFFFFF, 1); useCircleField.graphics.drawRect(0, 0, 100, 100); useCircleField.name = "circle"; useCircleField.graphics.endFill(); addChild(useCircleField); addChild(useSquareField);
useCircleField.addEventListener(MouseEvent.ROLL_OVER, useCircle); useSquareField.addEventListener(MouseEvent.ROLL_OVER, useSquare); useCircleField.addEventListener(MouseEvent.ROLL_OUT, showMouse); useSquareField.addEventListener(MouseEvent.ROLL_OUT, showMouse);
circleMouse.graphics.beginFill(0x00ff00, 1); circleMouse.graphics.drawCircle(0, 0, 5); circleMouse.graphics.endFill(); currentMouse = new Sprite();
squareMouse.graphics.beginFill(0xff0000, 1); squareMouse.graphics.drawRect(0, 0, 10, 10); squareMouse.graphics.endFill(); this.stage.addEventListener(MouseEvent.MOUSE_MOVE, moveNewMouse); }
private function moveNewMouse(mouseEvent:MouseEvent):void
{ currentMouse.x = mouseEvent.stageX + 5; currentMouse.y = mouseEvent.stageY + 5; mouseEvent.updateAfterEvent(); }
private function useSquare(mouseEvent:MouseEvent):void { Mouse.hide(); addChild(squareMouse); currentMouse = squareMouse; }
private function useCircle(mouseEvent:MouseEvent):void { Mouse.hide(); addChild(circleMouse); currentMouse = circleMouse; }
private function showMouse(mouseEvent:MouseEvent):void { if((mouseEvent.target as Sprite) == useSquareField) { removeChild(squareMouse); } else { removeChild(circleMouse); } currentMouse = new Sprite(); Mouse.show(); } } }
|