Quick Tip: Labeling Loops

Did you know you can label loops in ActionScript 3? Yes, you can! I got inspired by latest tweets referencing source code in image. Lets do some small experiments… Label all of them:

var a:uint, b:uint = 0;
loopA:for(a = 0; a < 10; a++)
    loopB:while(b++ < 100)
        loopC:for each(var c:uint in [0,1,2,3])
            break loopB;

trace(a, b, c); // traces "10 10 0"

Where to go from here

1 comment so far

  1. PSturgeon August 26, 2010 22:31

    OMG! That is freakin amazing. I had no idea. That is definitely going to come in handy with nested loops.

Leave a comment

Please be polite and on topic. Your e-mail will never be published.