开发者

get the last value of, as3

开发者 https://www.devze.com 2023-01-08 04:57 出处:网络
Is there a method for getting the last valu开发者_Go百科e of? I want the last number value of an amount that\'s incremented.

Is there a method for getting the last valu开发者_Go百科e of? I want the last number value of an amount that's incremented. I know I've seen this method. Thanks,


Subtract 1 from the current value. That will give you the previous value of a number that has been incremented. For example:

var current:Number = 0;
current += 1;
var previous:Number = current - 1;

You could wrap this in your own custom method if you want:

function getPreviousValue(current:Number):Number
{
    return current - 1;
}


Perhaps:

var inc:Number = 450;
var total:Number = 100000000;
var target:Number = 0;

while( target < total ) {
    var n:Number = target + inc < total ? inc : total - target;
    target += n;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消