tototototototot

All posts tagged loop

Nice AS3 Performance tester (loops, arrays, division, instantiations, constants, …)

When you look for something, there are always more chances that you don’t find it when you need it. It’s only weeks later, when looking for something else that you step on it. (some unwritten laws that I know most of you have encountered many times) Anyway, here is a great open-source performance tester written […]

Calculate the surface/area of an irregular polygon

There are many ways to calculate the surface of a polygon. It all depends on what kind of data you have to deal with. If you have only vertices (points) or if you have the segments associated to them as well. The most evident solution would be to divide the polygon in triangles and calculate […]

AS3 arrays against linked lists performance benchmarking

Let’s have a look at arrays vs. linked lists, and for what use. Here, the assumption is that we need to access a property and/or call a function from a lot of objects in a list at the highest speed possible. Let’s say we are making a game and we want to go through all […]

AS3 loops performance benchmarking

I just went through a post from polygonal labs that shows the difference in performance between several loops in AS3. If you go have a look at his post, you’ll see that the “for (i = 0; i < n; i++) {}” loop wins the first place. I have set up a benchmarking tool just […]

The continue statement and labels

The continue statement skips the rest of the code inside a loop and starts at the beginning of this loop as if the end of the loop had been reached normally. Thus, the code after the continue statement in the code below will never get executed by flash: [sourcecode language=’cpp’] for(var i:int = 0 ; […]

Break statement and labels

The break statement allows us to skip the execution of a loop or statement: [sourcecode language=’cpp’] for(var i:int = 0 ; i < 10 ; i++) { if ( i >= 5 ) { break; } } [/sourcecode] Simple. Now imagine we have a loop nested in another loop: [sourcecode language=’cpp’] for(var i:int = 0 […]