AS2提高速度和速度放松

时间:2010-03-12 12:58:01

标签: flash actionscript actionscript-2

我正在创建一个温度计,当捐赠进来时,水银会动画。我很长时间没有碰过闪光灯,所以请保持温和。

如何在不增加帧速率的情况下更改下面的代码,以便动画更快?

var maxMercuryHeight = 192; // Mercury height at 100%
var currentDonations = 80; // Percentage of donations taken
var currentHeight = (currentDonations / 100) * maxMercuryHeight;

mercury.onEnterFrame = function()
{
    if(mercury._height < currentHeight) {
        mercury._height++;
    } else {
        delete mercury.onEnterFrame;
    }
}

trace(currentHeight);

奖金问题:如何让动画缓和,以便快速启动并在结束时放慢速度?

谢谢!

1 个答案:

答案 0 :(得分:0)

var speed = 0.4; // choose speed < 1 to suit    

if mercury._height < currentHeight {
mercury._height = mercury._height + 1 + speed*(currentHeight - mercury._height);
} else ...