开发者

ActionScript Substituting Lengthy Display List Paths In Code?

开发者 https://www.devze.com 2023-01-15 20:51 出处:网络
i would like to make my code easier to read by replacing long paths with variables, or something similar.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号