I have two buttons in Flash. The aim is that when you click one, the counter will go up by 1.9, and if you click the other it will go down by 1.9. However when you try and increase/decrease the number by 1.9, the math is slightly off after a few clicks. The number is one or two decimals from what it should be.
var count1:uint = 0;
var unit:Number = 0;
add1_btn.addEventListener(MouseEvent.CLICK, add1);
take1_btn.addEventListener(MouseEvent.CLICK, take1);
counter1.text = '0';
function add1(event:Event):void
{
count1++;
counter1.text = count1.toString();
unit+= 1.9;
var unitRound= int((unit)*10)/10;
units.text = unitRound.toString();
}
function take1(event:Event):void
{
count1--;
counter1.text = count1.toString();
unit-= 1.9;
var unitRound= int((unit)*10)/10;
units.text = unitRound.toString();
}