Skip to main content
Known Participant
February 24, 2009
Answered

removeChild help!

  • February 24, 2009
  • 3 replies
  • 445 views
ok!
on frame 3 of my swf I import another swf as a child "stage.addChild(carmenu)"
everything works perfect!
but i have a button in frame 3 that gets me back to frame 2 (in case the user misses something and wants to recheck)
So if the user goes back to frame 2 he has the "carmenu" loaded on screen which is bad LOL, so on frame 2 I added a script saying "stage.removeChild(carmenu)"
It works fine but i get the error " TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at producto10_fla::MainTimeline/frame3()"
i figured thats because the first time i get to frame 2 the carmenu.swf hasn't been loaded yet so its actually inexistent I guess to avoid that error from appearing in the output i have to add a script to say that if child(carmenu) is loaded then "stage.removeChild(carmenu)"
but i have no idea how! any ideas?

Thanks in advance!!
This topic has been closed for replies.
Correct answer Ned Murphy
How about not adding the carmenu to the stage, and instead adding it to an empty movieclip in frame 3. That will probably solve your problem(s). By anchoring it to something in frame 3, it will not appear anywhere before frame 3.

3 replies

Ned Murphy
Legend
February 25, 2009
You're welcome
Ned Murphy
Ned MurphyCorrect answer
Legend
February 24, 2009
How about not adding the carmenu to the stage, and instead adding it to an empty movieclip in frame 3. That will probably solve your problem(s). By anchoring it to something in frame 3, it will not appear anywhere before frame 3.
PonchotgAuthor
Known Participant
February 25, 2009
That sounds like a logic answer!
thank you!
Ned Murphy
Legend
February 24, 2009
Just try:

if(carmenu){
...
}
PonchotgAuthor
Known Participant
February 24, 2009
ok i did this
"if(carmenu){
stage.removeChild(carmenu);
}"
and got this! :S
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at producto10_fla::MainTimeline/frame3()
at flash.display::MovieClip/gotoAndStop()
at producto10_fla::MainMenuOver_11/gotohistoria()
and when geting back from frame 3 to frame 2 now the "carmenu" is still loaded!