RE: [Flashcoders] Re: zinc kills a variable with a new String()?

2006-10-11 Thread Chris Douglass
Does AS support explicit byRef and byVal function argument modifiers?  If
so, maybe that would help. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of grimmwerks
Sent: Wednesday, October 11, 2006 11:11 AM
To: Flashcoders mailing list
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; itheList.length; i++){
ret = subStuff(tList[i]);
}
}

subStuff = function(which){
for(i=0; iwhich.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

___
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


Re: [Flashcoders] Re: zinc kills a variable with a new String()?

2006-10-11 Thread Robert r. Sanders

Did you try adding an explicit variable declaration (e.g.
for (var i = 0;...)   it might be that because the var statement is 
lacking the variable is being created in a global scope.



Chris Douglass wrote:

Does AS support explicit byRef and byVal function argument modifiers?  If
so, maybe that would help. 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of grimmwerks
Sent: Wednesday, October 11, 2006 11:11 AM
To: Flashcoders mailing list
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; itheList.length; i++){
ret = subStuff(tList[i]);
}
}

subStuff = function(which){
for(i=0; iwhich.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

___
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
  



--
   Robert r. Sanders
   Chief Technologist
   iPOV
   (334) 821-5412
   www.ipov.net

___
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


Re: [Flashcoders] Re: zinc kills a variable with a new String()?

2006-10-11 Thread Muzak
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; ilen; i++) {
  ret = subStuff(tList[i]);
 }
}

function subStuff(which:Array) {
 var i:Number = 0;
 var len:Number = which.length;
 for (i=0; ilen; 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; itheList.length; i++){
 ret = subStuff(tList[i]);
 }
 }

 subStuff = function(which){
 for(i=0; iwhich.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