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.htmUsing 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