Skip to main content
Known Participant
November 3, 2009
Answered

removing mc?

  • November 3, 2009
  • 1 reply
  • 755 views

Hi!

I have 3 labels on the timeframe(3 different pages)

Each page has a button eventlistener that starts the dynamic mc on fadein that tweens title text onto its page.

what is the best way to remove this mc on each page?

I can get it to work on some frames, but it remains on others and they all pile up when you click from one button to the next especially if you button click pattern!

should I use removeeventlistener

removechild

or visible=false with a conditinal statement?

also, where do I place the code, at the original eventListener site?

Thanks,

barb

This topic has been closed for replies.
Correct answer kglad

I tried this and it seems to b working, right now..

btn3.addEventListener(MouseEvent.MOUSE_UP, remove2);

function remove2(event:MouseEvent):void {

gotoAndPlay("resume");

removeChild(con_txt);

}

Is this the right way? Thanks in advance!


this would be better:


btn3.addEventListener(MouseEvent.MOUSE_UP, remove2);

function remove2(event:MouseEvent):void  {

removeChild(con_txt) ;

gotoAndPlay("resume" );

}

1 reply

kglad
Community Expert
Community Expert
November 3, 2009

use removeChild() to remove a movieclip from the stage.  i'm not sure that's the best solution for you because it's not clear what you mean by "dynamic mc ...".

schugabugAuthor
Known Participant
November 3, 2009

I am using addChild() to place it on the stage when a button is clicked

ok,

So do I removeChild() at the end of the frame of code that the

addChild() is on?

I only want it to remove when you go to a the new frame after you

click a button.

I shouldn't put it at the beginning of the new frame with the new mc

should I?

kglad
Community Expert
Community Expert
November 3, 2009

add it to your button listener function before you go to the new page and before you add the next child.