Skip navigation
Currently Being Moderated

How do you remove a movie clip from the stage via a dispatch event?

May 1, 2012 6:45 PM

Tags: #dispatchevent

I have a movie clip that is added to the stage. There is a close button on that movie clip that I would like to close and remove the clip from the stage. But the close button does not work when it is clicked, nothing happens.


Here's the flow along with the code:


//Adds the movie clip to the stage

var myPlayCredits:mc_playCredits = new mc_playCredits();


stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtons);

function goButtons(event:MouseEvent):void


    if ( == Credits_bnt)




        myPlayCredits.x = 511;

        myPlayCredits.y = 386;




//This is the code on the button inside the movie clip that calls the dispatch



closeCredit.addEventListener(MouseEvent.MOUSE_DOWN, closeCreditPopupScreen);

function closeCreditPopupScreen (event:MouseEvent):void


      dispatchEvent(new Event("RemoveMCcredit"));





//Removes (is supposed to remove) the MovieClip from the stage when the user clicks on the close button inside the MovieClip.

stage.addEventListener("RemoveMCcredit", RemoveCreditClip);

function RemoveCreditClip(e:Event):void





Anybody have any thoughts?

  • Currently Being Moderated
    May 1, 2012 7:46 PM   in reply to Mr. Baker the Shoe Maker

    Why don't you just assign the event listener to the closeCredit button after you instantiate myPlayCredits and just have the event listener call the RemoveCreditClip function directly...


    var myPlayCredits:mc_playCredits = new mc_playCredits();

    myPlayCredits.loseCredit.addEventListener(MouseEvent.CLICK, RemoveCreditClip);\



    If you want to use the dispatch event approach, try assigning the listener to the myPlayCredits mc, not the stage. (Or set the Event's bubbling argument to true if you assign it to the stage)

    Mark as:
  • Currently Being Moderated
    May 3, 2012 12:16 PM   in reply to Mr. Baker the Shoe Maker

    You're welcome

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points