Thanks Chris and Matt for the explanation

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:bounce-fugli-
> [EMAIL PROTECTED] On Behalf Of Matt Voerman
> Sent: Thursday, 25 August 2005 3:50 PM
> To: Flash Developers List
> Subject: [fugli] Re: variable scope
> 
> Hey Seb,
> Chris is partially correct when he says 'variables declared outside a
> function are global'.
> 
> The reality is that the scope of variables declared outside a function
can
> be either Timeline or Global based depending on how they are declared.
> 
> In your scenarios you actually have two different variable scope
examples.
> 
> The first one is an example of a Timeline based variable scope. This
is
> where a variable is declared outside a function without explicitly
being
> being declared global. As such, the value of 'colour' would be
accessible
> to any script trying to access it from the same TIMELINE.
> 
> If you wanted to make 'colour' a global variable (ie: accessible to
ANY
> timeline and scope within your document) you'd need to add a _global
> identifier to the front of your declaration eg: var
_global.colour:String
> = "Red";
> 
> In your second example you've actually given an example of a Local
> variable. The reason it's considered Local is because when btn2 tries
to
> trace out the value of 'colour' its still wrapped up (locally) within
the
> function block of btn1.
> 
> Hope that helps.
> 
> Cheers
> Matt
> 
> _________________________________
> Matt Voerman
> Partner
> 
> RocketBoots
> Professional Services for Macromedia technologies
> http://www.rocketboots.com.au
> 
> ---
> You are currently subscribed to fugli as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
[EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/

---
You are currently subscribed to fugli as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to