
Код:
var step = 5;
var wayObj = {
left:{dx: step},
right:{dx:-step},
down:{dy: step},
up:{dy: -step},
down20px:{dy: 20},
downRight20px:{dy: step, dx:-20}
}
function goToWay(way:String) {
var ob = wayObj[way];
if( ob.dx ) mc1._x += ob.dx;
if( ob.dy ) mc1._y += ob.dy;
};
function btnOnRelease() {
if( this.dir == undefined ) this.dir = (this._name.split("_"))[0];
gotoWay(this.dir);
};
right_btn.onRelease = left_btn.onRelease = up_btn.onRelease = btnOnRelease;
down_btn.onRelease = down20px_btn.onRelease = downRight20px_btn.onRelease = btnOnRelease;
