AS3 Flex 中滚动列表的补间效果

Tweening effect for scrolling list in AS3 Flex

我有一个名为 tileListCanvas 的 canvas,当鼠标在 tileListCanvas 上上下移动时,我会垂直滚动它。一切正常,但我想为滚动行为添加补间效果,以便滚动逐渐减慢并在用户停止移动鼠标时停止。滚动行为由

实现
target = tileListCanvas.verticalScrollPosition -= (10 - yDiff) 

用于向上滚动和

target = tileListCanvas.verticalScrollPosition += (10 + yDiff) 

用于向下滚动。

如果有人能告诉我如何做到这一点,那将让我开心!

[Bindable]private var previousX:Number = 0;
[Bindable]private var previousY:Number = 0;
[Bindable]private var currentX:Number = 0;
[Bindable]private var currentY:Number = 0;
[Bindable]private var xDir:String;
[Bindable]private var yDir:String;
[Bindable]private var xDiff:Number = 0;
[Bindable]private var yDiff:Number = 0;

[Bindable]private var lastX:Number = 0;
[Bindable]private var lastY:Number = 0;
[Bindable]private var speed:Number;
[Bindable]private var target:Number = 0;

private function initMouseDirectionChecker():void
{
    tileList.addEventListener(MouseEvent.MOUSE_MOVE, checkDirection);
}

private function beginScrolling(mouseEvent:MouseEvent):void
{
    tileListCanvas.verticalScrollPosition -= 5;
}

 public function checkDirection(e:MouseEvent):void
{
    getHorizontalDirection();
    getVerticalDirection();

    dir1.text = "x: " + xDir
    dir2.text = "y: " + yDir;
}

//Horizontal
private function getHorizontalDirection():void
{
    previousX = currentX; //Checks the last position
    currentX = stage.mouseX; //Gets the current position

    if (previousX > currentX) //Compares both positions to determine the direction
    {
        xDir = "left";
    }
    else if (previousX < currentX)
    {
        xDir = "right";
    }
    else
    {
        xDir = "none";
    }
}

//Vertical
private function getVerticalDirection():void
{
    previousY = currentY; //Checks the last position
    currentY = stage.mouseY; //Gets the current position

    if (previousY > currentY) //Compares both positions to determine the direction
    {
        yDir = "up";
        target = tileListCanvas.verticalScrollPosition -= (10 - yDiff);                    
    }
    else if (previousY < currentY)
    {
        yDir = "down";
        target = tileListCanvas.verticalScrollPosition += (10 + yDiff);
    }
    else
    {
        yDir = "none";
    }
}

感谢 swift 回复,非常感谢!

我听从了你的建议并从 greensock.com 下载了 GASP,在那里我能够将 greensock swc 导入我的项目并访问 TweenLite。我使用下面的代码实现了我想要的滚动效果。

TweenLite.to(tileListCanvas, 2, {verticalScrollPosition:currentY +10, ease:Back.easeOut});

希望这可以帮助其他人。