...Or if you like to perform a recursion (particular case of nesting). I do not belive there is a good way to re-declare a variable inside the scope of one function.
(?) You could comment out vars, copy/paste them with active code and uncomment when needed; it is more a text editor issue: //var x:Number; //var y:Number; //var a:Number; a = x + y; I think that splitting long function bodies into separate short ones is a better idea. All local variables may be declared (and not re-declared) inside these short functions: var x = calcA( calB() + calcC() ) / calcD(); g Friday, January 08, 2010 (1:18:45 PM) Cor wrote: > OOOh, indeed, that would be a bad choice. > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Paul Andrews > Sent: vrijdag 8 januari 2010 13:16 > To: Flash Coders List > Subject: Re: [Flashcoders] Declaring Function Variables > Cor wrote: >> Mmmm, I have never experienced any problems with it. >> > It just means you havent used the same variable in a loop with nested > functions that are also using the variable. >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On Behalf Of Paul > Andrews >> Sent: vrijdag 8 januari 2010 12:47 >> To: Flash Coders List >> Subject: Re: [Flashcoders] Declaring Function Variables >> >> Cor wrote: >> >>> Declaring it within a function will make the variable LOCAL (= usage in >>> >> that >> >>> function only). >>> You only declare it outside, once and (re)use it as often as you like. >>> >>> >> I would advise that it's best to avoid doing that. Most of the time it >> won't give you a problem, but then you'll spend some time trying to find >> out why that function call is messing up the loop count of the code it's >> called in. >> >>> HTH >>> Cor >>> >>> -----Original Message----- >>> From: [email protected] >>> [mailto:[email protected]] On Behalf Of David >>> >> Benman >> >>> Sent: vrijdag 8 januari 2010 12:16 >>> To: Flash Coders List >>> Subject: [Flashcoders] Declaring Function Variables >>> >>> What's the best practice for declaring reused variables within a >>> function in AS3? For example, if you use "count" several times in your >>> function, if you declare it at the start of your function, "var >>> count:Number;" it makes it harder to cut and paste your code for use >>> elsewhere but you get errors if redeclare it (like you could in AS2) >>> throughout your script. >>> >>> >>> David Benman >>> Interactive Developer >>> [email protected] >>> http://www.dbenman.com >>> (508) 954-1202 (cell) >>> (315) 637-8487 (home office) >>> >>> >>> >>> _______________________________________________ >>> Flashcoders mailing list >>> [email protected] >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >>> No virus found in this incoming message. >>> Checked by AVG - www.avg.com >>> Version: 9.0.725 / Virus Database: 270.14.129/2605 - Release Date: >>> >> 01/07/10 >> >>> 08:35:00 >>> >>> _______________________________________________ >>> Flashcoders mailing list >>> [email protected] >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >>> >>> >>> >> >> _______________________________________________ >> Flashcoders mailing list >> [email protected] >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> No virus found in this incoming message. >> Checked by AVG - www.avg.com >> Version: 9.0.725 / Virus Database: 270.14.129/2605 - Release Date: > 01/07/10 >> 08:35:00 >> >> _______________________________________________ >> Flashcoders mailing list >> [email protected] >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >> > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 9.0.725 / Virus Database: 270.14.129/2605 - Release Date: 01/07/10 > 08:35:00 > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

