Posts Tagged loop

Loops With int and uint

Tags: , , , , , , , , ,

AS3 has two integer types: int and uint. In my experience, most AS3 programmers just use int everywhere and ignore uint. This is usually acceptable as the need for unsigned integers is rare compared to their signed counterparts. However, there are significant performance differences between the two. Read on for the impact of uint on your loops. The original version of this article’s performance test contained a small-but-critical error that led to a lot of incorrect analysis and results. This version of the article has been corrected.

Read the rest of this article »

8 Comments

Advanced break and continue Statements

Tags: , , , ,

There’s more to AS3’s break and continue statements than you might think. Chances are, you’ve used them to skip to after a loop (break) and skip the current loop iteration (continue), but they can do so much more. Today’s article will cover some of the advanced ways to use the break and continue statements in AS3 resulting in nicer—and maybe even faster—code.

Read the rest of this article »

15 Comments

For Vs. While Revisited

Tags: , , ,

I wrote an article last November titled For Vs. While that needs a bit of updating an expanding today. While I updated the performance figures in my series on Flash 10.1 performance, I continue to get questions in the comments section of the original article that explore new areas. So today we’ll look at the ubiquitous for and while loops a little more.

Read the rest of this article »

8 Comments

For Vs. While

Tags: , , ,

I’ve recently been seeing more and more usage of while loops by those who I presume are interested in performance. I’ve always assumed that these was not faster than for loops, but today I am finding out.

Read the rest of this article »

12 Comments

Loop Speed

Tags: , , , , , ,

AS3 gives you a good number of potential ways you can loop over collections. When Flash Player 10 first came out, I went ahead and tested out the new Vector class in a variety of ways. One of them was to pit it against the collections available in Flash Player 9: Array, Object, Dictionary, ByteArray, and even BitmapData. Below I’ll show you my test and discuss its results.

Read the rest of this article »

14 Comments

Changing Arrays Midstream

Tags: ,

I often wonder about language features that I know have a lot going on behind the scenes. In AS3, this commonly has me wondering about the for-in and for-each loops, which I use frequently. This article is about what happens to those loops when you change the array you’re iterating over during the iteration.

Read the rest of this article »

4 Comments

Flexible Loop Syntax

Tags:

First things first: this might be a bug in MXMLC. It sure did cause a bug in my program though! Read on for the stupid mistake that had me scratching my head.

Read the rest of this article »

4 Comments

Loop Safety

Tags:

This is a curiosity I’ve had for far too long. Why didn’t I make these simple tests years ago when I was first learning AS3? I’m not sure, but judging by a lot of other people’s AS3 that I’ve read, many people don’t seem to understand it.

Read the rest of this article »

4 Comments

Messing With Iterators

Tags:

The for-in and for-each loops are convenient and likely to be the loops you use most. For this reason alone you should make sure you know what you can and can’t do with them. Here’s one thing I just found can save me some typing and some bloat.

Read the rest of this article »

2 Comments

ActionScript 3 Loops

Tags:

The for-each and for-in loops in JavaScript and AS3 are very convenient ways to avoid the repetition of C-style for loops. Let’s take a look at them all, what they’re good for and bad for, and see if we can find any gotchas.

Read the rest of this article »

3 Comments