# actionscript 3.0 break statement



## computerboy267 (Jan 22, 2008)

in thefollowing code in "Essential Action Script 3.0":
_var address = "[email protected]";
var isValidAddress = false;
var i = 0;
while (i < address.length) {
if (address.charAt(i) == "@") {
isValidAddress = true;
break;
}
i++;
}_
which emphasizes the usage of the break statement.
Why does the execution of the while statement stop when the break statement is placed within the if code block. 
That should break the if code block and not the while code block.


----------



## jamiemac2005 (Jul 5, 2007)

Break statements only break out of loops. That's what it's there for.

Hence "if the character is an @ the e-mail address is valid so stop checking it".

You wouldnt need a break in the If statement at that point if that was the reason for it.

Cheers,
Jamey


----------



## computerboy267 (Jan 22, 2008)

thx so much Jamey
:grin:


----------

