[Flashcoders] Declaring Function Variables

2010-01-08 Thread David Benman
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

RE: [Flashcoders] Declaring Function Variables

2010-01-08 Thread Cor
] 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

Re: [Flashcoders] Declaring Function Variables

2010-01-08 Thread Paul Andrews
David Benman wrote: 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

Re: [Flashcoders] Declaring Function Variables

2010-01-08 Thread Paul Andrews
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

RE: [Flashcoders] Declaring Function Variables

2010-01-08 Thread Cor
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

Re: [Flashcoders] Declaring Function Variables

2010-01-08 Thread Paul Andrews
...@chattyfig.figleaf.com] 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

RE: [Flashcoders] Declaring Function Variables

2010-01-08 Thread Cor
...@chattyfig.figleaf.com] 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

[Flashcoders] Declaring Function Variables

2010-01-08 Thread Greg Ligierko
: [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: flashcoders-boun

Re: [Flashcoders] Declaring Function Variables

2010-01-08 Thread Steven Sacks
The rule I follow (and one that I think is best for code readability) is that you declare a variable the first time you use it. If you're using it in multiple loops, you declare it above the first loop that uses it. This is a trivial example: private function foo(data:Array):void { var