开发者

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

getChildB开发者_如何学PythonyName('name') will work as long as that child is in the first frame.


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.


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


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()).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜