Recently was called up to fix an issue with a client's SWF file that we were trying to use on one of our channels. The file worked on its own, but not in the container SWF on our site. Jumping into the client's code, I immediately spotted the problem where their developer declared a class instance used in their movie on the "_root" timeline. Since we loaded their SWF into a movieclip within our SWF, the scope had changed, breaking the entire file.
Scope is one of the first things I usually check for when debugging ActionScript. It's easy to make errors related to scope and it seems that many Flash designers and developers don't have a 100% grasp on the idea of what it is. That's sometimes due to the Normal Mode in our editor, through free Flash tutorials or through the copy and paste learning pattern of the self taught (guilt am I of this at first.) So why is using "_root" such a headache when it's provided for us to use? In reference to "_root", I think it's the fact that we learn it as an absolute path which doesn't always hold true. In addition it's knowing how to code with good practice and trying not to cut corners. Let's take a look at some types of scope and use of them within Flash.
Understanding _level
The keyword "_level" refers to the absolute main timeline of a specified level (ie: _level4). When you start with a SWF file, that movie is always referred to as "_level0", the first in any possible stack of movies. By using "_level", your code will only work in the intended "_level" order. If code tries to reach data on "_level4" and we rearrange our stack in another project, the data won't be there, breaking our code. Levels can be thought of like floors on a building, when loading new SWF files into additional levels, they reside on top of one another. It's not necessarily bad practice to use "_level", you just need to understand the consequences of being tied to a rigid structure.
Understanding _root
The keyword "_root" is used to refer to the absolute main timeline of a given "_level". Depending on where a SWF resides, the reference to "_root" can be different. When using a SWF file all on its own, that file is "_level0". In this case, referencing the file's main timeline with "_root" is the same as saying "_level0". If the same file were loaded into "_level5" we would be referencing the main timeline of "_level5" with "_root". However, if we load that same SWF file into a target movieclip vs. a "_level" our scope changes because the SWF isn't used being used in the context of a "_level" anymore. What was referenced as "_root" in the SWF's main timeline while used on its own now points to the main timeline of the SWF loading it. It's important to know that using "_root" as an absolute can be misleading and for all intents and purposes it should be avoided.
Contrasting _level & _root
The above explanations are similar when described but they are very different when used. Code using "_level3" for example, written on a given timeline in a given movie will ALWAYS refer to the main timeline in "_level3" regardless of its position. In contrast, if you're working in a SWF and using "_root", your code will refer to the main timeline of the current "_level". Where the use of "_level" will always be the same, "_root" changes based on where your SWF file is used. Even though both are considered "absolute" paths in Flash's ActionScript dictionary, "_root" in my opinion is actually a "relative" path based on where your clip is used. While it does always point to "_root" as an ideal, "_root" can vary based on load position.
Understanding _global
In contrast to "_root", the "_global" scope never changes and, unlike the other two fore mentioned spaces, "_global" isn't a physical location. If you think of a timeline as a physical location (ie: places you can attach objects to like graphics and movieclips), "_global" acts differently. It's a name space within Flash where only code can reside. You can find a lot of articles with pros and cons to using "_global" but all I'll say here is that you can always set data within the "_global" space and your path will never change. Once set, anything can access that data from anywhere inside your movie. Data written to "_global" should be limited due to the chance of overwriting other references in that scope.
Wrapping Up
Portability is king. As a developer or designer, you should write code that is portable and can be reused. You don't need to reinvent the wheel every time you start a new project. Using relative paths and reference variables within classes and even simple pieces of Flash work enables you to reuse code that you have already written.
This will allow you to reuse script within different locations of different movies, as well as load those movies into others without losing functionality due to broken paths. There are many articles on what is referred to as the Singleton Pattern on the web, which some consider an alternative to "_global" as a reference point within class structure. GSkinner has a good example as well as other discussion on scope.
So the next time you decide to just drop in a quick reference to "_root" or "_level" consider the file's future use. That quick and dirty solution can be done in a better manner and save you (or someone like me) even more time down the road. There is always a better solution to a given problem, you just need to take a moment to find it.