0

_global.choiceMadeが1に等しい場合、次のコードを使用してムービークリップをトゥイーンしています...

onClipEvent (load) {
    import mx.transitions.Tween;
    import mx.transitions.easing.*; 
}

onClipEvent (enterFrame) {
if (_global.choiceMade == 1) {
    var myTweenX:Tween = new Tween(this, "_x", mx.transitions.easing.Back.easeOut, this._x, -349, 0.5, True);
}
}

これは、メインタイムラインの各フレームに含まれています。最初は正常に実行されますが、次のフレームでは実行が非常に遅くなります(0.5ではなく約12秒かかり、非常に途切れます)。最初のフレームに戻ってもう一度実行すると、今度は非常に遅くなります。

なぜこれを実行しているのか理解できません。CPUが実行されている間、CPUが約6〜15%のままであるため、要求が厳しすぎることはありません。

私のコードの残りを表示するように更新されました:

メインのタイムラインには、それぞれにムービークリップを含むフレームがあります。これらの各ムービークリップのタイムラインには、次のものが含まれています。

//tint an object with a color just like Effect panel
//r, g, b between 0 and 255; amount between 0 and 100
Color.prototype.setTint = function(r, g, b, amount) {
var percent = 100-amount;
var trans = new Object();
trans.ra = trans.ga=trans.ba=percent;
var ratio = amount/100;
trans.rb = r*ratio;
trans.gb = g*ratio;
trans.bb = b*ratio;
this.setTransform(trans);
};//Robert Penner June 2001 - http://www.robertpenner.com
 MovieClip.prototype.scaleXY = function(to){
 this.onEnterFrame = function(){
 this._alpha = to-(to-this._alpha)/1.2;
 if(this._alpha > to-1 && this._alpha < to+1){
 this._alpha = to;
 delete this.onEnterFrame
 }
 }
 }
scoreUpdated = 0;
Answer = 1;
_global.choiceMade = 0;
Buttons = new Array(this.buttonHolder.True, this.buttonHolder.False);
Answers = new Array(this.Correct, this.Wrong);
for (i=0; i<Answers.length; i++) {
Answers[i]._alpha = 0;

}
for (b=0; b<Buttons.length; b++) {
Buttons[b].thisValue = b;

}

このムービークリップには、次のコードを含む2つのムービークリップボタン(TrueとFalse)があります。

onClipEvent (enterFrame) {
this.onRollOver = function() {
    this.gotoAndStop("over");
};
this.onRollOut = function() {
    this.gotoAndStop("up");
};
this.onPress = function() {
    this.gotoAndStop("down");
};
this.onReleaseOutside = function() {
    this.gotoAndStop("up");
};
this.onRelease = function() {
    this.gotoAndStop("down");
    whichChoice = this;
    _global.choiceMade = 1;
    counter = 0;
};
if (_global.choiceMade == 1) {
    this.enabled = false;
this._parent.scoreNow = _global.score;
this._parent.scoreOutOf = (this._parent._parent._currentframe)- 1 + ( _global.choiceMade);
if (thisValue == this._parent._parent.Answer && whichChoice == this) {
    myColor = new Color(this);
    myColor.setTint(0,204,0,13);
    this._parent._parent.Answers[0]._alpha = 100;
    this._parent._parent.Answers[0].scaleXY(100);
    this.tick.swapDepths(1000);
    if (counter == 0) {
    _global.score++;
    counter++;
    }
} 
else if (thisValue == this._parent._parent.Answer) {
    myColor = new Color(this);
    myColor.setTint(0,204,0,13);
    this.tick.swapDepths(1000);
}
else if (whichChoice == this) {
    this._parent._parent.Answers[1]._alpha = 100;
    this._parent._parent.Answers[1].scaleXY(100);
    myColor = new Color(this);
    myColor.setTint(255,0,0,13);
    this.cross.swapDepths(1000);
}
else {
    myColor = new Color(this);
    myColor.setTint(255,0,0,13);
    myColor.setTint(255,0,0,13);
    this.cross.swapDepths(1000);
}
}
}

上部のスクリプトはムービークリップ上にあり、これらのボタンはbuttonHolderと呼ばれるものに含まれています。このボタンは、ボタンの内容を実行し、画面全体でボタンをトゥイーンして、回答が選択されると次のボタンを表示します。

4

2 に答える 2

1

私が見る限り、choiceMade == 1 である限り、新しい効果が作成されます! これは問題ありません。15 fps で 1 秒で 15 のトゥイーンが実行されるため:(

choiceMade = 0 または 1 以外の値を設定してみてください

onClipEvent (enterFrame) 
{
    if (_global.choiceMade == 1) 
    {
        _global.choiceMade = -1;
        var myTweenX:Tween = new Tween(this, "_x", mx.transitions.easing.Back.easeOut, this._x, -349, 0.5, True);
    }
}
于 2011-05-16T08:48:10.603 に答える
0

コードの残りの部分を見ないと、何が起こっているのかを正確に理解するのは困難です。しかし、choiceMade を変更することはないようで、継続的にトゥイーンを再作成します。

onClipEvent (enterFrame) {
if (_global.choiceMade == 1) {
    var myTweenX:Tween = new Tween(this, "_x", mx.transitions.easing.Back.easeOut,      this._x, -349, 0.5, True);
_global.choiceMade = 0;
}
}
于 2011-05-16T08:49:50.770 に答える