Skip to main content
Participant
November 26, 2007
Question

Remove children on frame change?

  • November 26, 2007
  • 1 reply
  • 367 views
What I'd like to do is this: I have a really simple application with two keyframes on the timeline. Both frame contain some graphics I drew using the rectangle tool. At loading time I add some textfields to the stage via Actionscript (3) using the addChild method.

When I go to the second keyframe, which contains another 'page' of my website, the rectangles I drew on the stage are removed and the graphics I drew at the second keyframe appear, that what's I want to happen. The fields I added through actionscript remain visible though! That's not what's supposed to happen.

So for the fields that are added through code I would like the same behavior as the ones that you just drag on the stage. Can that be done? Or, alternatively, is there some way, perhaps through an eventlistener to 'listen' for a frame change, upon which I can remove all children that I added? How do you people do this?

If not...I fear I'm going to have to code my entire site again (and in truth it's much bigger than the two-frame example I sketched above) Hope that isn't the case.
This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
November 26, 2007
use removeChild() or removeChildAt() to remove those displayobjects added via actionscript.