2

我有一个圆形图形,上面有 7 个图像。它需要在下一个/上一个图像上旋转并停止。它应该旋转超过 50 度才能到达下一张/上一张图像,所以我添加了 360。

这部分工作正常。但是当我尝试在旋转过程中添加一些运动模糊类型的效果时,旋转有时会在没有完成的情况下停止。

问题似乎在下面(但我也发布了完整的代码)

// animate the blur
var myTween:Tween = new Tween(spinner, "blur", 
                            Regular.easeOut, 16, 0, 1.3, true);
myTween.addEventListener(TweenEvent.MOTION_CHANGE, applyBlur);

// animate the rotation
var spin:Tween = new Tween(spinner, "rotation", 
                         Regular.easeOut, 0, angle, 1.5, true);
spin.addEventListener(TweenEvent.MOTION_FINISH, hideSpinner);   

/* * * * * * * * * * * * * * * * * * * * / // ref的完整代码 /* * * * * * * * * * * * * * * * * * * /

// import blur classes
import flash.display.Sprite;
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;
import fl.transitions.TweenEvent;
import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;


// set up the blur filter
var blurX:Number = 4;
var blurY:Number = 16;
var blur = new BlurFilter(blurX, blurY, BitmapFilterQuality.HIGH);
var targetAngle = 0;

//var targetAngles:Array = new Array(0,60,110,160,210,270,320);

// Track the last sandwich viewed
// these are the defaults to start with
var currentSandwich:MovieClip = this.sandwich1;
var nextSandwich:MovieClip = this.sandwich1;

// Show / Hide the spiner
up.addEventListener(MouseEvent.CLICK, revealSpinner);
down.addEventListener(MouseEvent.CLICK, revealSpinner);

function revealSpinner(event:MouseEvent):void
{ 
    // deactivate the buttons
    up.removeEventListener(MouseEvent.CLICK, revealSpinner);
    down.removeEventListener(MouseEvent.CLICK, revealSpinner);

    var angle:Number = 0;
    // set the rotation amount depending on what arrow was clicked
    if ( event.currentTarget.name == "up" ){
        angle = spinner.rotation + 360 + 51.42;
    } else {
        angle = spinner.rotation + -360 + -51.42;
    }
    trace(angle);

    // animate the blur
    var myTween:Tween = new Tween(spinner, "blur", Regular.easeOut, 16, 0, 1.3, true);
    myTween.addEventListener(TweenEvent.MOTION_CHANGE, applyBlur);

    // animate the rotation
    var spin:Tween = new Tween(spinner, "rotation", Regular.easeOut, 0, angle, 1.5, true);
    spin.addEventListener(TweenEvent.MOTION_FINISH, hideSpinner);   

}

function hideSpinner(event:TweenEvent):void
{   
    // reactivate the buttons
    up.addEventListener(MouseEvent.CLICK, revealSpinner);
    down.addEventListener(MouseEvent.CLICK, revealSpinner);

    // stop the listeners
    spinner.removeEventListener(TweenEvent.MOTION_FINISH, hideSpinner);
    spinner.removeEventListener(TweenEvent.MOTION_CHANGE, applyBlur);

    spinner.filters = [];
    //spinner.rotation = targetAngle;
}

function applyBlur(event:TweenEvent):void
{
    spinner.filters = [new BlurFilter(spinner.blur, spinner.blur, 1)];
}
4

2 回答 2

1

Greensock补间平台(以前称为 TweenLite/TweenMax)是一个出色的补间库。我从来没有遇到过用它设置复杂补间的问题。

于 2010-02-04T03:52:41.220 回答
0

我没有找到上面停止补间的原因。但这通过使用单独的包http://code.google.com/p/tweener/解决了问题

于 2010-01-04T16:46:49.353 回答