Flash AS3 - How do I access display object in other frames (aka a frame other than one)

一世执手 提交于 2019-12-13 16:42:27

问题


getChildByName('name') will work as long as that child is in the first frame.


回答1:


Display objects in other frames haven't been instantiated yet, so it's not so much that you can't access them; they aren't there to be accessed. When the playhead passes into a keyframe with a certain object, that object is created and added to the stage, and when the playhead passes into a new keyframe that doesn't have that object, the object is destroyed. So the only way to access the object is to gotoAndStop() to a frame where the object exists on the timeline.

If this causes problems - that is, if you have an object that only appears on the stage at frame 5, and you need to access it in frame 1, try changing your timeline so that the object exists on frame 1 but is offstage or otherwise hidden from view. As long as it exists, you can access it normally, and you can just move it onto the stage in frame 5 or wherever.




回答2:


don't use frames, use external files and classes.




回答3:


You cannot access children from frames ahead of the playhead.

But jonathanasdf is right; don't use frame scripts. Ever. (Well, except for maybe the occasional stop()).



来源:https://stackoverflow.com/questions/2747770/flash-as3-how-do-i-access-display-object-in-other-frames-aka-a-frame-other-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!