that's because 'i' isn't local to the function but lives in the 'timeline' the function is defined in. Define them inside the function using var. It's also a good thing to do the same for the 'condition', because the length might change during the loop process, which may mess up the loop as well.
function mainStuff() { var i:Number = 0; var len:Number = theList.length; for (i=0; i<len; i++) { ret = subStuff(tList[i]); } } function subStuff(which:Array) { var i:Number = 0; var len:Number = which.length; for (i=0; i<len; i++) { //whatever } } regards, Muzak ----- Original Message ----- From: "grimmwerks" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com> Sent: Wednesday, October 11, 2006 5:11 PM Subject: [Flashcoders] Re: zinc kills a variable with a new String()? > Of course, the var i fixed it (in the 'for') -- but I don't get why it > blewup; I've noticed this elsewhere too today. > > Say I had a function that calls a subfunction, ie > > mainStuff = function(){ > for(i=0; i<theList.length; i++){ > ret = subStuff(tList[i]); > } > } > > subStuff = function(which){ > for(i=0; i<which.length; i++){ > //whatever > } > } > > I noticed that 'i' would get shared across the instances, that it wouldn't > work. ie it would work in mainstuff, bounce to subStuff which would iterate > more, get mainStuff confused, etc. > > This is in direct violation to what the local var should be, no? I mean, > I've never experienced that before. _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com