Código ActionScript :
package com.esedeerre
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import com.senocular.utils.KeyObject;
public class Ship extends MovieClip
{
private var stageRef:Stage;
private var key:KeyObject;
private var velocidad :uint = 4;
private var parada :Boolean = true;
public function Ship(stageRef:Stage)
{
stop();
this.stageRef = stageRef;
key = new KeyObject(stageRef);
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
}
private function Release (e:Event):void
{
if (key.keyReleased(Keyboard.LEFT))
{
(currentLabel != "link_down")
gotoAndStop("parado_down");
}
else if (key.keyReleased(Keyboard.RIGHT))
{
(currentLabel != "link_right")
gotoAndStop("parado_right");
}
if (key.keyReleased(Keyboard.UP))
{
(currentLabel != "link_up")
gotoAndStop("parado_up");
}
else if (key.keyReleased(Keyboard.DOWN))
{
(currentLabel != "link_down")
gotoAndStop("parado_down");
}
}
private function loop(e:Event) : void
{
if (key.isDown(Keyboard.LEFT))
{
x -= velocidad;
(currentLabel != "link_left")
gotoAndPlay("link_left");
stop();
}
else if(key.isDown(Keyboard.RIGHT))
{
x += velocidad;
(currentLabel != "link_right")
gotoAndPlay("link_right");
stop();
}
if (key.isDown(Keyboard.UP))
{
y -= velocidad;
(currentLabel != "link_up")
gotoAndPlay("link_up");
stop();
}
else if (key.isDown(Keyboard.DOWN))
{
y += velocidad;
(currentLabel != "link_down")
gotoAndPlay("link_down");
stop();
}
}
}
} 