GreenSock,AS3中的onUpdate函数,导致问题

时间:2013-03-15 18:56:11

标签: actionscript-3 flash animation tween greensock

想象一下使用多个圆圈的圆周边界的水波纹效果。我正在使用onUpdate函数实际上停止了程序的其余部分(即第二个补间)。试图延迟补间多个圆也不起作用??这会导致它们在下一个补间发生之前没有完全补间。该方法需要重复:

(对不起大量的代码)

var micCircleOne:Sprite = new Sprite();
var micCircleTwo:Sprite = new Sprite();
var micCirclesOneResize:Object = {radius:75};
var micCirclesTwoResize:Object = {radius:75};

function circles():void {
        micCircleOne.graphics.lineStyle(2, 0x000000, 1, false, "normal", null, null, 3);
        micCircleOne.graphics.drawCircle(0, 0, micCirclesOneResize.radius);
        micCircleOne.x = xScreenPos + (displayRes/2);
        micCircleOne.y = yScreenPos + (displayRes/2);

        addChild(micCircleOne);
// the onUpdate below causes issues with the delay of the next tween
        TweenMax.to(micCirclesOneResize, 2, {radius:400, ease:SlowMo.ease.config(1,0), onUpdate:circlesOneExpandUpdate, onUpdateParams:[micCirclesOneResize], onComplete:circlesExpandAnimate});

        micCircleTwo.graphics.lineStyle(2, 0xbbbbbb, 1, false, "normal", null, null, 3);
        micCircleTwo.graphics.drawCircle(0, 0, micCirclesTwoResize.radius);
        micCircleTwo.x = xScreenPos + (displayRes/2);
        micCircleTwo.y = yScreenPos + (displayRes/2);

        addChild(micCircleTwo);
// the delay of this tween is affected
        TweenMax.to(micCirclesTwoResize, 2, {radius:400, ease:SlowMo.ease.config(1,0), delay:1, onUpdate:circlesTwoExpandUpdate, onUpdateParams:[micCirclesTwoResize]});

}

function circlesOneExpandUpdate(micCirclesOneResize:Object):void {
        micCircleOne.graphics.clear();
        micCircleOne.graphics.lineStyle(2, 0x000000, 1, false, "normal", null, null, 3);
        micCircleOne.graphics.drawCircle(0, 0, micCirclesOneResize.radius);
}

function circlesTwoExpandUpdate(micCirclesTwoResize:Object):void {
        micCircleOne.graphics.clear();
        micCircleOne.graphics.lineStyle(2, 0xbbbbbb, 1, false, "normal", null, null, 3);
        micCircleOne.graphics.drawCircle(0, 0, micCirclesTwoResize.radius);
}

function circlesExpandAnimate():void {
        micCirclesOneResize = {radius:75};
        micCirclesTwoResize = {radius:75};

        TweenMax.to(micCirclesOneResize, 2, {radius:400, ease:SlowMo.ease.config(1,0), onUpdate:circlesOneExpandUpdate, onUpdateParams:[micCirclesOneResize], onComplete:circlesExpandAnimate});
        TweenMax.to(micCirclesTwoResize, 2, {radius:400, ease:SlowMo.ease.config(1,0), delay:1, onUpdate:circlesTwoExpandUpdate, onUpdateParams:[micCirclesTwoResize]});
}

更新:在micCircleOne内将micCircleTwo更改为circlesTwoExpandUpdate();解决了问题。 -facepalm-

但是,我遇到了另一个带有一些额外代码的问题。模糊发生在circles();内,但似乎onUpdate导致每次重绘整个displayObject的每一个模糊,导致它滞后很多。

TweenMax.set(micCircleOne, {alpha:1, blurFilter:{blurX:0, blurY:0}});

TweenMax.to(micCircleOne, 1, {ease:SlowMo.ease.config(1, 0), alpha:0, blurFilter:{blurX:20, blurY:20}, delay:1});

模糊和alpha在circlesExpandAnimate();中重置,然后使用完全相同的代码再次运行:

TweenMax.set(micCircleOne, {alpha:1, blurFilter:{blurX:0, blurY:0}});

TweenMax.to(micCircleOne, 1, {ease:SlowMo.ease.config(1, 0), alpha:0, blurFilter:{blurX:20, blurY:20}, delay:1});

0 个答案:

没有答案