Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm running Firefox 3.6.14 and I couldn't replicate your error. But I created a small class, so you can test it for yourself. Does it work as you want? To use it, create a new project, using this class as Main. You should have an object that you can move with WASD and an aim, that you move with the mouse. You can move on any direction, and the mouse at the same time. Please post your results.</p> <pre><code>package { import flash.display.Sprite; import flash.events.Event; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.ui.Keyboard; public class Main extends Sprite { private var keys:Array = new Array(); private var hero:Sprite = new Sprite(); private var aim:Sprite = new Sprite(); public function Main():void { stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp); stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); stage.addEventListener(Event.ENTER_FRAME, update); // create the objects for testing hero.graphics.beginFill(0xff0000); hero.graphics.drawRect(0, 0, 50, 50); hero.graphics.endFill(); hero.x = stage.stageWidth / 2; hero.y = stage.stageHeight / 2; stage.addChild(hero); aim.graphics.lineStyle(1, 0); aim.graphics.drawCircle(0, 0, 10); aim.graphics.moveTo(0, -10); aim.graphics.lineTo(0, 10); aim.graphics.moveTo(-10, 0); aim.graphics.lineTo(10, 0); aim.x = hero.x + hero.width / 2; aim.y = hero.y + hero.height / 2; stage.addChild(aim); } private function update(e:Event):void { if (keys[65]) hero.x -= 5; if (keys[68]) hero.x += 5; if (keys[87]) hero.y -= 5; if (keys[83]) hero.y += 5; } private function onMouseMove(e:MouseEvent):void { aim.x = e.stageX; aim.y = e.stageY; } private function onKeyDown(e:KeyboardEvent):void { keys[e.keyCode] = true; } private function onKeyUp(e:KeyboardEvent):void { keys[e.keyCode] = false; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload