发布网友 发布时间:2024-10-24 17:12
共3个回答
热心网友 时间:2024-11-20 04:13
在你基础上改的,没有改变你的主体结构。
添加了两个变量:tempY用来保存鼠标触碰到MC时候的speedY的值;hit是一个真假值。
var speedY = -1;
var tempY:Number = 0;
var hit:Boolean=false;
this.MC.onEnterFrame = function() {
if (this.hitTest(_xmouse, _ymouse, true)) {
//判断hit是否为真,如果不为真,那么把speedY的值赋给tempY,然后改变hit的值为真;
if(!hit){
tempY = speedY;
hit=!hit;
}
speedY = 0;
} else {
//判断hit是否为假,如果不为假,那么把tempY的值赋给speedY,然后改变hit的值为假;
if(hit){
speedY=tempY;
hit=!hit;
}
}
if (this._y <= 20 || this._y >= 295) {
speedY *= -1;
}
this._y += speedY;
updateAfterEvent();
};
热心网友 时间:2024-11-20 04:13
top = 20;
bottom = 295;
speedY = -1;
MC.onEnterFrame = mcMove;
MC.onRollOver = function() {
this.onEnterFrame = null;
};
MC.onRollOut = function() {
this.onEnterFrame = mcMove;
};
function mcMove() {
if (this._y<=top || this._y>=bottom) {
speedY *= -1;
}
this._y += speedY;
updateAfterEvent();
}
热心网友 时间:2024-11-20 04:14
var speedY = -1;
MC.onRollOver = function(){
delete this.onEnterFrame;
}
MC.onRollOut = function(){
this.onEnterFrame = this.onEnterFrame2;
}
MC.onEnterFrame2 = function() {
if (this._y<=20 || this._y>=295) {
speedY *= -1;
}
this._y += speedY;
updateAfterEvent();
};追问不对呀,默认不走呀