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

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

+2


a source to share


3 answers


Display objects in other frames have not yet been created, so it is not that you cannot access them; they shouldn't be available. When the game point moves to a keyframe with a specific object, this object is created and added to the scene, and when the game point moves to a new keyframe that does not have this object, the object is destroyed. Thus, the only way to access an object is gotoAndStop()

to a frame where the object exists in the timeline.



If this is causing problems - that is, if you have an object that only appears in a stage in frame 5 and you need to access it in frame 1, try changing the timeline so that the object exists in frame 1, but offscreen or otherwise hidden from view. As long as it exists, you can access it normally, and you can simply move it to the scene at frame 5 or wherever you like.

+1


a source


do not use frames, use external files and classes.



+1


a source


You cannot access children from the frames in front of the playhead.

But jonathanasdf is right; don't use frame scripts. Always . (Well, except maybe random ones stop()

).

0


a source







All Articles