;

PDA

Click to See Complete Forum and Search --> : Dynamic function


mackey555
12-19-2005, 10:29 AM
I'm having trouble making this function dynamic. I've done similar code before, why doesn't this work?

function makeSmall(){
for(i=1;i<=samples.length;i++){
with(windows){
this["w"+i].winOff();
trace(this["w"+i]);
}
}
//windows.w1.winOff();
//windows.w2.winOff();
//windows.w3.winOff();
//windows.w4.winOff();
//windows.w5.winOff();
//windows.w6.winOff();
//windows.w7.winOff();
//windows.w8.winOff();
}

>flashl!ght<
12-19-2005, 01:38 PM
What does the trace() output? Copy/paste the entire output window.

From looking at the code, it looks good, only the samples array reference makes me wonder... are you sure that is the correct scope? Did you try trace(samples) and trace(samples.length) to double check that? Also, I'm not fond of the with() command, I would have just done:

function makeSmall(){
for(i=1;i<=samples.length;i++){
windows["w"+i].winOff();
trace(windows["w"+i]);
}
}