Código ActionScript :
onClipEvent (load) {
vx = 100;
vy = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_y -= vy;
while(_root.escenario.hitTest(_x,_y-_height/2,true)){
_y++;
}
}
if (Key.isDown(Key.DOWN)) {
_y += vy;
while(_root.escenario.hitTest(_x,_y+_height/2,true)){
_y--;
}
}
if (Key.isDown(Key.LEFT)) {
_root.escenario._x+=vx;
if(this._xscale>0){
_xscale=-_xscale;
}
if(_root.escenario._x>= 0) {
_root.escenario._x-=vx;
}
while(_root.escenario.hitTest(_x-_width/2,_y,true)){
_x++;
}
}
if (Key.isDown(Key.RIGHT)) {
_root.escenario._x-=vx;
if(this._xscale<0){
_xscale=-_xscale;
}
if(_root.escenario._x+_root.escenario._width <= 1024) {
_root.escenario._x+=vx;
}
while(_root.escenario.hitTest(_x+_width/2,_y,true)){
_x--;
}
}
}.
