var v = 20;
function goDir(dir) {
switch (dir) {
case "left" :
ball.onEnterFrame = function() {
this._x -= v;
if (this._x<0) {
this._x = Stage.width;
}
};
break;
case "right" :
ball.onEnterFrame = function() {
this._x += v;
if (this._x>Stage.width) {
this._x = 0;
}
};
break;
case "up" :
ball.onEnterFrame = function() {
this._y -= v;
if (this._y<0) {
this._y = Stage.height;
}
};
break;
case "down" :
ball.onEnterFrame = function() {
this._y += v;
if (this._y>Stage.height) {
this._y = 0;
}
};
break;
case "stop" :
delete ball.onEnterFrame;
break;
}
}
dt1.htmlText = "<a href=''asfunction:goDir,up''>Up</a>";
dt2.htmlText = "<a href=''asfunction:goDir,down''>Down</a>";
dt3.htmlText = "<a href=''asfunction:goDir,left''>Left</a>";
dt4.htmlText = "<a href=''asfunction:goDir,right''>Right</a>";
dt5.htmlText = "<a href=''asfunction:goDir,stop''>Stop</a>";
源文件下载: