PDA

View Full Version : continue; what is it?


Flash Gordon
03-23-2005, 12:04 AM
here is my code:

var info:Array = [["John", "919-555-5698"], ["Kelly", "232-555-3333"], ["Ross", "434-555-5655"]];
function search() {
var matchFound:Boolean = false;
var i:Number = -1;
while (++i<info.length) {
if (info[i][0].toLowerCase() != name_txt.text.toLowerCase()) {
continue;
}
result_txt.text = info[i][1];
matchFound = true;
break;
}
if (matchFound == false) {
result_txt.text = "No Match";
}
}
search_btn.onRelease = search;


I don't understand what continue; does. Wont it "continue" looping anyway because i is < 3?

tg
03-23-2005, 05:58 AM
its telling flash to continue executing the loop (but starting at the while again, instead of executing the code after the if statement. ( i think).

its kinda ass backwards tho. i think most folks would check to see if the values are equal, then setting the matchfound flag and breaking out of the loop.... maybe i've enterpretted it incorrectly tho.

Flash Gordon
03-23-2005, 06:21 PM
i agree it is backwards. I'm beginning to dislike Flash Mx 2004 Training at the souce more and more with each chapter.
Thanks tg.

But wouldn't the script go back to the while loop anyway without the continue command?

Flash Gordon
03-23-2005, 06:25 PM
oh wait it makes it skip this part:
result_txt.text = info[i][1];
matchFound = true;
break;
right?

tg
03-23-2005, 10:37 PM
correct....
but again, i would just check for equivlance, then if they are equal do that bit.... the other way seems less intuitive.