break a loop from a function?
basically i want to break a for loop from an external function, like that:
PHP Code:
for (i=0; i<=10; i++) {
test(5);
trace(i);
}
function test(value) {
if (i == value) {
break;
}
}
is there a way? i want to avoid that:
PHP Code:
for (i=0; i<=10; i++) {
if (i == 5) {
break;
}
trace(i);
}
why avoid that above code if it's so simple? because in my game it looks more like:
PHP Code:
for (i=0; i<=10; i++) {
function_a(x)
function_b(x)
function_c(x)
function_d(x)
function_e(x)
...etc
}
do you see the point? if the first function (here function_a) is true, then the for loop is broken and all the other functions below ignored...
maybe there's a way to target that for loop with that break command? something like _parent.break;, or give that for loop a name...
thanks in advance for the infos.