Trying to understand "_root"
I'm trying to get an actionscri开发者_StackOverflow社区pt code used in a Flash CS5 example and make a ActionScript class using it in Flash Builder. And I'm trying to understand the _root
property.
This page have a brief explanation about the _root
property, but it is too vague.
My question is: What is the "_root" that exists only when the ActionScript is placed in the Flash CS5 project? How do I reference it in my class in Flash Builder? (it is an instance of what?)
I think you may have a wire crossed - there is no such thing as _root
in AS3. In AS1/AS2, _root
was basically a global variable pointing to the stage (it's actually a little more complicated, since AS2 had a slightly messy way of organizing display objects).
In AS3, the closest analogy is the stage property, but actually due to AS3's robust way of managing the display hierarchy you don't actually need to use stage
very often. Anyway, for AS3 programming the only time you ever need to think about a _root
is if you load in an AS2 SWF (which you should probably avoid if you can).
https://web.archive.org/web/20090615191715/http://www.kirupa.com/forum/showthread.php?p=1952513
I can't think of a better explanation of stage vs. root and what each means.
精彩评论