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
] 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
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
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
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
...@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
...@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
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
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
9 matches
Mail list logo