AS3 Loops: Simple "while" loop

var i:Number= 0;

while (i < 5) {
trace([i]);
i = i+1;
}

AS3 Loops: Simple "for" loop

for (var i:Number=0; i < 5; i++) {
trace(i);
}

AS3 Arrays: Access elements in a string array

//String array

Example

var aString:Array = new Array ("Name", "Address", "State", "Zip", "Phone");
trace(aString);
//returns the contents of the array
trace(aString[1]);
//trace the position of an object in an array. Index position must be in brackets. This trace would return "address".
trace(aString.length);
//returns the length of the array. This trace would return "5"

Programming Habits: Using Trace Statements

Trace Statements

Its a great practice to utilize the trace statements if you arent already. A trace statement is used by programmers to test functionality or debug their script. The trace statement IS NOT seen once your swf has been published for the web or viewed outside of flash. Meaning no one will see it when viewing your flash project online. This is the primary reason my flash notes all include a dynamic text box. Normally I would just use a trace statement, but if I did that users would be unable see to the the result of given example. Furthermore, it might better suit you to skip making a dynamic textbox and just use a trace command.

Actionscript:

trace("this is a simple trace statement");

Result:

traceoutput