ActionScript Substituting Lengthy Display List Paths In Code?
i would like to make my code easier to read by replacing long paths with variables, or something similar.
in my code, i can target an instance many times, but the开发者_StackOverflow社区 instance can have a lengthy path deep within the display list. for example: myButton instance could be located at myButtonsPanel.section2.redArea.myButton, or something like that.
is it possible to substitue this long path as a variable or constant? something like:
var myPath = myButtonsPanel.section2.redArea;
therefore, calling the instance would be:
myPath.myButton;
Not the path , but the actual Button
var myButton:MovieClip = myButtonsPanel.section2.redArea.myButton;
although you could also do this:
var myContainer:MovieClip = myButtonsPanel.section2.redArea; //then access your button like this myContainer.myButton
It really depends on what you need to do, but the idea is that instead of storing a path, you're actually referencing a MovieClip directly, then using that variable to access this MovieClip
精彩评论