Restrict text input to certain characters

Create four TextInput boxes on your stage.
Give the first an instance name of tLetters.
Give the second an instance name of tNumbers.
Give the third an instance name of tCaps.
Give the last an instance name of tSymbols.

Actionscript:

//allows only defined characters in the textboxes.
tLetters.restrict="a-z A-Z";
tNumbers.restrict="0-9";
tCaps.restrict="A-Z";

//notice that the "-" and "^" symbol must be between "\\" and "\\" in order to be recognized in the string
tSymbols.restrict= "! @ # $ % & ( ) _ + * / = \\-\\ \\^\\ ";

Example:

Get Adobe Flash player

Loops: Create a "for loop" in AS3

Create a button movieclip on your stage.
Give it an instance name of bStart.

Create an input text box on your stage.
Give it an instance name of itSteps.

Create a dynamic text box on your stage.
Give it an instance name of tMessages.

Actionscript:

bStart.addEventListener(MouseEvent.CLICK, fLoop);

itSteps.restrict = "0-9";
itSteps.maxChars = 3;

function fLoop(event:MouseEvent):void {
tMessages.text="";
var vString:String = itSteps.text;
var vExample:Number = Number(vString);
for (var i:Number=0; i < vExample; i++) { tMessages.appendText([i]+", "); } }

Example:

Get Adobe Flash player