Código ActionScript :
package com.setup { import flash.display.MovieClip; import flash.events.Event; import flash.events.KeyboardEvent; import flash.ui.Keyboard; public class canasto_mc extends MovieClip { private var der:Boolean = false; private var izq:Boolean = false; private var vel:int = 10; private var limite_x_der:int = 600; private var limite_x_izq:int = 50; public function canasto_mc() { addEventListener(Event.ENTER_FRAME,motor); } public function controles() { stage.addEventListener(KeyboardEvent.KEY_DOWN,key_down); stage.addEventListener(KeyboardEvent.KEY_UP,key_up); } public function key_down(e:KeyboardEvent):void { switch (e.keyCode) { case 68: der = true; break; case 65: izq = true; break; } } public function key_up(e:KeyboardEvent):void { switch (e.keyCode) { case 68: der = false; break; case 65: izq = false; break; } } public function motor(e:Event):void { if (der) { if (x <= limite_x_der) { x += vel; rotation += (5 - rotation) / 3; } } else if (izq) { if (x >= limite_x_izq) { x -= vel; rotation += (-5 - rotation)/3; } } else { rotation += (0 - rotation) / 3; } controles() } } }