Skip to main content
Participant
November 3, 2011
Question

The problem with multiplication by a fractional number (iphone 3gs)

  • November 3, 2011
  • 1 reply
  • 347 views

Hi

I have a loop in the event handler enterframe. Inside the loop — the multiplication by a fractional number.

for (var i:int = 0; i < 200; i++){

var n:Number = 10 * 0.12;

}


As a result, on the iphone 3gs very fast memory is wasted. About 20 KB per second. After some time the memory is reset and starts again to grow. Each time you reset FPS jumps, it is not suitable for my game. When multiplied by an integer, then there is no problem.


Does anyone had a similar problem? Is it possible to optimize this operation?

P. S. I try Air 2.6, 2.7 and 3. This is a problem everywhere.

This topic has been closed for replies.

1 reply

Colin Holgate
Inspiring
November 3, 2011

In your example you are setting up a Number variable 6000 times per second. If you changed it to have the var n:Number =10; outside the loop, and had n*=1.01; inside the loop, do you get the same results?