package { import flash.display.MovieClip; import flash.text.TextField; import flash.display.Shape; import flash.events.Event; public class Avoider extends MovieClip { public var target:MovieClip = new MovieClip; public var player:MovieClip = new MovieClip; public var score:int = 0; public var mouseDiffX:int = 0; public var mouseDiffY:int = 0; public function Avoider() { addEventListener(Event.ENTER_FRAME, mouseMovement); drawPlayer(); } public function drawPlayer() { player.graphics.beginFill(0x000000); player.graphics.drawCircle(0, 0, 10); player.x = 200; player.y = 200; player.graphics.endFill(); addChild(player); } public function mouseMovement(event:Event):void { mouseDiffY = mouseY - player.y; mouseDiffX = mouseX - player.x; if (mouseDiffY < 0) { if (!player.hitTestObject(walltop)) { player.y += mouseDiffY / 6; } } if (mouseDiffY > 0) { if (!player.hitTestObject(wallbottom)) { player.y += mouseDiffY / 6; } } if (mouseDiffX < 0) { if (!player.hitTestObject(wallleft)) { player.x += mouseDiffX / 6; } } if (mouseDiffX > 0) { if (!player.hitTestObject(wallright)) { player.x += mouseDiffX / 6; } } } } }