Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 00:44
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  The Library
| |-+  Technical Reference Area (Moderators: Flash-db, Musicman, BurtonRider1983, vesa kortelainen, Ronald Wernecke, Jorge Solis)
| | |-+  Scoping
0 Members and 2 Guests are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Scoping  (Read 4717 times)
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« on: 03/27/03, 06:28 »

A common mistake is not to think about the avaibility of variables when tryng to acces it. Here are some simple rules to keep in mind

1. This variables is avaible only inside this function
function foo(){
    var myvar=1
}

2. This variable is avaible inside current timeline
function foo(){
   myvar=1
}

3. This variable is avaible inside current timeline
myvar=1

4. This variable is avaible in root
_root.myvar = 1

5. This variable is avaible inside _global scope
_global.myvariable

Now I want to acces myvar from inside a MovieClip named target, that's inside root

1. Can't acces the variable
2. Need to use the path of the timeline
3. Need to use the path of the timeline
4. Can acces using _root.myvar
5. Can acces using _global.myvar

You can find a more indeep look inside the scope chain in http://timotheegroleau.com/Flash/articles/scope_chain.htm

Using objects, classes and a OOP way of thinking, you can encapsulate properties and avoid the problem of overwriting variables.

A good starting point in order to understand objects, classes and inheritance are the Intro and advanced lessons from Branden Hall and Samuel Wan: http://chattyfig.figleaf.com/, look on the rigth of the screen below Presentations

For advanced techniques about OOP ways of developping applications, see

http://moock.org/webdesign/lectures/ff2003Workshop/

Jorge
« Last Edit: 04/12/03, 08:44 by Jorge Solis » Logged

Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything