AS3.0 Reversed for loop

Today I came across an easy mistake to make when new to AS3.

I set up a for loop, to count backwards through an Array. But for some strange reason the loop was never terminating! It was simple, here’s the original code

var i:uint;
for( i=arr.length-1; i>=0; i– )

The mistake was simple, I had set i as a uint, so it could never go below 0, so just had to make i an int. It sounds stupid once you realise it, but it wasted enough of my time!

Comments are closed.