你提供的链接不起作用,但我想我有个提示
velocity=0;
maxVelocity=3;
accel=0.1;
break=0.98;
function onEnterFrame(){
if (mouseOverRightSensor){
velocity +=accel;
}else if (mouseOverLeftSensor){
velocity -=accel;
}
// make sure you constrain the velocity
if (Math.abs(velocity)>maxVelocity) {
//get the sign of the velocity and multiply it with maxVelocity
velocity=Math.abs(velocity)/velocity * maxVelocity
}
//Add the velocity to the movieclip's position
movieclip.x+=velocity;
//shrink down the velocity, this is done each frame no matter if the mouse is over the sensor;
velocity*=break;
}
基本上,即使鼠标不在传感器上,你也需要移动movieclip,这是用速度变量来实现的。
您可能需要调整这些值并添加更多代码,这只是一些概念代码。
希望对你有帮助:)