Actionscript AS2:don';在运动完成之前,不要执行卷展栏

Actionscript AS2:don';在运动完成之前,不要执行卷展栏,actionscript,actionscript-2,Actionscript,Actionscript 2,我有一个应用了一些tweens的mc,但是如果你在它们完成之前推出它们,它们就会崩溃。我不想在tweens运行时禁用该按钮,因为如果在tweens运行时滚动,会让用户感到困惑,因为什么都没有发生,并且会卡在该帧中 我要做的是在tween(或之后)期间确认卷展,但在tween完成之前不要运行。但是,我似乎无法从卷展栏功能访问卷展栏功能中tween的onmotionfinished 有什么想法吗 如果我的翻滚有帮助: buttons[i].onRollOver = function() {

我有一个应用了一些tweens的mc,但是如果你在它们完成之前推出它们,它们就会崩溃。我不想在tweens运行时禁用该按钮,因为如果在tweens运行时滚动,会让用户感到困惑,因为什么都没有发生,并且会卡在该帧中

我要做的是在tween(或之后)期间确认卷展,但在tween完成之前不要运行。但是,我似乎无法从卷展栏功能访问卷展栏功能中tween的onmotionfinished

有什么想法吗

如果我的翻滚有帮助:

    buttons[i].onRollOver = function() {
    var oppX:Number = Stage.width-this._x;
    var oppY:Number = Stage.height-this._y;
    if (oppX-209.8<=20) {
        var difference:Number = Math.abs(20-(oppX-209.8));
        oppX += difference;
    } else if (oppX+209.8>=780) {
        var difference:Number = Math.abs(780-(oppX+209.8));
        oppX -= difference;
    }
    if (oppY-172.1<=20) {
        var difference:Number = Math.abs(20-(oppY-172.1));
        oppY += difference;
    } else if (oppY+172.1>=580) {
        var difference:Number = Math.abs(580-(oppY+172.1));
        oppY -= difference;
    }
    var TweenX:Tween = new Tween(circle, "_x", mx.transitions.easing.Strong.easeOut, circle._x, oppX, 1, true);
    var TweenY:Tween = new Tween(circle, "_y", mx.transitions.easing.Strong.easeOut, circle._y, oppY, 1, true);
    circle.gotoAndPlay("out");
    myColor = new Color(this);
    myColor.setTint(153,255,0,30);
    for (MovieClip in buttons) {
        delete buttons[MovieClip].onEnterFrame;
        if (buttons[MovieClip] != this) {
            buttons[MovieClip].enabled = false;
            myColor = new Color(buttons[MovieClip]);
            myColor.setTint(255,255,255,80);
            myColor = new Color(buttons[MovieClip]._line);
            myColor.setTint(255,255,255,80);
        }
    }

};

意识到造成大多数问题的并不是青少年,而是因为我停了下来,才去玩的;调用与该电影剪辑上的标记相同的帧,导致它们卡住

确实有一些tween的问题(如果tween被称为mid tween,则卷展栏跳回到滚动位置),但我决定将tween推到一个数组中,使其全局可访问,并在MotionFinished上清除数组,然后在卷展栏检查中查看数组是否包含任何内容,如果是,则首先清除旧tween

最终产品:

    buttons[i].onRollOver = function() {
    circle.active = this;
    var oppX:Number = Stage.width-this._x;
    var oppY:Number = Stage.height-this._y;
    if (oppX-209.8<=20) {
        var difference:Number = Math.abs(20-(oppX-209.8));
        oppX += difference;
    } else if (oppX+209.8>=780) {
        var difference:Number = Math.abs(780-(oppX+209.8));
        oppX -= difference;
    }
    if (oppY-172.1<=20) {
        var difference:Number = Math.abs(20-(oppY-172.1));
        oppY += difference;
    } else if (oppY+172.1>=580) {
        var difference:Number = Math.abs(580-(oppY+172.1));
        oppY -= difference;
    }
    var TweenX:Tween = new Tween(circle, "_x", mx.transitions.easing.Strong.easeOut, circle._x, oppX, 1, true);
    var TweenY:Tween = new Tween(circle, "_y", mx.transitions.easing.Strong.easeOut, circle._y, oppY, 1, true);
    TweenY.onMotionFinished = function () {
        tweens.length = 0;
    }
    tweens.push(TweenX,TweenY);
    circle.gotoAndPlay("out");
    myColor = new Color(this);
    myColor.setTint(153,255,0,30);
    for (MovieClip in buttons) {
        delete buttons[MovieClip].onEnterFrame;
        if (buttons[MovieClip] != this) {
            buttons[MovieClip].enabled = false;
            myColor = new Color(buttons[MovieClip]);
            myColor.setTint(255,255,255,80);
            myColor = new Color(buttons[MovieClip]._line);
            myColor.setTint(255,255,255,80);
        }
    }
};
buttons[i].onRollOut = function() {
    if (tweens.length != 0) {
        tweens[0].stop();
        tweens[1].stop();
        delete tweens[0];
        delete tweens[1];
        tweens.length = 0;
    }
    circle.gotoAndPlay("in");
    var TweenX:Tween = new Tween(circle, "_x", mx.transitions.easing.Strong.easeOut, circle._x, 400, 0.5, true);
    var TweenY:Tween = new Tween(circle, "_y", mx.transitions.easing.Strong.easeOut, circle._y, 300, 0.5, true);
    TweenY.onMotionFinished = function() {
        circle._x = 400;
        circle._y = 300;
        for (MovieClip in buttons) {
            buttons[MovieClip].enabled = true;
        }
    };
    for (MovieClip in buttons) {
        buttons[MovieClip].onEnterFrame = function() {
            moveButtons(this);
            controlButtons(this);
        };
        myColor = new Color(buttons[MovieClip]);
        myColor.setTint(255,255,255,0);
    }
};
按钮[i].onRollOver=function(){
circle.active=这个;
var oppX:Number=Stage.width this.\u x;
变量oppY:Number=舞台高度此值。\u y;
如果(oppX-209.8=780){
var差异:数值=数学绝对值(780-(oppX+209.8));
oppX-=差异;
}
如果(oppY-172.1=580){
var差异:数值=数学绝对值(580-(oppY+172.1));
oppY-=差异;
}
var TweenX:Tween=新Tween(圆圈“x”,mx.transitions.easing.Strong.easeOut,圆圈.x,oppX,1,true);
变量TweenY:Tween=新Tween(圆“_y”,mx.transitions.easing.Strong.easeOut,圆._y,oppY,1,true);
TweenY.onMotionFinished=函数(){
tweens.length=0;
}
推(TweenX,TweenY);
圈圈,围着玩(“出局”);
myColor=新颜色(此);
霉色菌(153255,0,30);
用于(MovieClip in按钮){
删除按钮[MovieClip].OneInterFrame;
如果(按钮[MovieClip]!=此){
按钮[MovieClip].enabled=false;
myColor=新颜色(按钮[MovieClip]);
霉色菌(255255,80);
myColor=新颜色(按钮[MovieClip]。\u行);
霉色菌(255255,80);
}
}
};
按钮[i].onRollOut=function(){
如果(tweens.length!=0){
tweens[0]。停止();
tweens[1]。停止();
删除tweens[0];
删除tweens[1];
tweens.length=0;
}
圆圈。围棋和游戏(“in”);
变量TweenX:Tween=新Tween(圆圈“x”,mx.transitions.easing.Strong.easeOut,圆圈.x,400,0.5,真);
变量TweenY:Tween=新Tween(圆“_y”,mx.transitions.easing.Strong.easeOut,圆._y,300,0.5,真);
TweenY.onMotionFinished=函数(){
圆圈。x=400;
圆。_y=300;
用于(MovieClip in按钮){
按钮[MovieClip].enabled=true;
}
};
用于(MovieClip in按钮){
按钮[MovieClip].onEnterFrame=function(){
移动按钮(本);
控制按钮(本);
};
myColor=新颜色(按钮[MovieClip]);
霉色菌(255255,0);
}
};

\u currentframe
\u totalframes
是你的好朋友。恐怕这是一个动作脚本。单框。您是使用enterFrame手动在对象之间切换还是使用切换库?如果它是一个tweening库,那么它应该有一个用于完成动画的事件处理程序/回调。如果你正在制作单帧动画,你可以检查你的对象的当前位置是否是最终位置。嗯…只要读“onmotionfinished”。这是否意味着您要使用flash附带的tween类(mx.motion.tween)?如果是这样,您将有一个用于翻转零件的函数,但它还不会被赋值。在onMotionComplete处理程序中,您将使用tween类指定滚动函数(例如myTweenedObj.onRollOver=myRollOverFunction;)是的,问题是在运动结束之前不允许注意滚动,因此如果它们在tween完成之前滚动,它们将被卡住。我需要有一个不断推出的功能,可以告诉运动何时完成,然后运行。因此,如果它们在卷展过程中卷展,则只需等待卷展完成,但卷展函数中的卷展似乎无法从卷展中确定范围。
    buttons[i].onRollOver = function() {
    circle.active = this;
    var oppX:Number = Stage.width-this._x;
    var oppY:Number = Stage.height-this._y;
    if (oppX-209.8<=20) {
        var difference:Number = Math.abs(20-(oppX-209.8));
        oppX += difference;
    } else if (oppX+209.8>=780) {
        var difference:Number = Math.abs(780-(oppX+209.8));
        oppX -= difference;
    }
    if (oppY-172.1<=20) {
        var difference:Number = Math.abs(20-(oppY-172.1));
        oppY += difference;
    } else if (oppY+172.1>=580) {
        var difference:Number = Math.abs(580-(oppY+172.1));
        oppY -= difference;
    }
    var TweenX:Tween = new Tween(circle, "_x", mx.transitions.easing.Strong.easeOut, circle._x, oppX, 1, true);
    var TweenY:Tween = new Tween(circle, "_y", mx.transitions.easing.Strong.easeOut, circle._y, oppY, 1, true);
    TweenY.onMotionFinished = function () {
        tweens.length = 0;
    }
    tweens.push(TweenX,TweenY);
    circle.gotoAndPlay("out");
    myColor = new Color(this);
    myColor.setTint(153,255,0,30);
    for (MovieClip in buttons) {
        delete buttons[MovieClip].onEnterFrame;
        if (buttons[MovieClip] != this) {
            buttons[MovieClip].enabled = false;
            myColor = new Color(buttons[MovieClip]);
            myColor.setTint(255,255,255,80);
            myColor = new Color(buttons[MovieClip]._line);
            myColor.setTint(255,255,255,80);
        }
    }
};
buttons[i].onRollOut = function() {
    if (tweens.length != 0) {
        tweens[0].stop();
        tweens[1].stop();
        delete tweens[0];
        delete tweens[1];
        tweens.length = 0;
    }
    circle.gotoAndPlay("in");
    var TweenX:Tween = new Tween(circle, "_x", mx.transitions.easing.Strong.easeOut, circle._x, 400, 0.5, true);
    var TweenY:Tween = new Tween(circle, "_y", mx.transitions.easing.Strong.easeOut, circle._y, 300, 0.5, true);
    TweenY.onMotionFinished = function() {
        circle._x = 400;
        circle._y = 300;
        for (MovieClip in buttons) {
            buttons[MovieClip].enabled = true;
        }
    };
    for (MovieClip in buttons) {
        buttons[MovieClip].onEnterFrame = function() {
            moveButtons(this);
            controlButtons(this);
        };
        myColor = new Color(buttons[MovieClip]);
        myColor.setTint(255,255,255,0);
    }
};