2010-03-12 110 views
0

我正在創建一個溫度計,將捐贈的汞進行動畫。我很久沒有碰過閃光燈,所以請溫和。AS2提高速度和緩解問題

如何更改下面的代碼,使動畫更快而不增加幀率?

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); 

獎金的問題:我怎樣才能使動畫緩出,因此啓動速度快,並在年底減慢?

謝謝!

回答

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

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