2 Replies Latest reply: Nov 5, 2014 6:41 AM by navigator81 RSS

    Removing Movieclips from an Array Displayed on stage

    navigator81 Community Member

      Hi Everyone ,

      I am new to AS3 so please forgive me in advance if I end up annoying anyone ;(

       

      I need some help in removing Movie Clips from the stage , these were initially loaded off an array

       

      Here is the Code with the NEXT Button , : for both ARRAYS , Notes and Notes15 ( referring to 15th frame)

       

      function nextframepop2(Event:MouseEvent):void{

      trace("Mouse Enabled");

      removeChild(notes15[4]);

      removeChild(notes15[3]);

      removeChild(notes15[2]);

      removeChild(notes15[1]);

      removeChild(notes15[0]);

      nextFrame();

       

       

      function nextframepop1(Event:MouseEvent):void{

      trace("Mouse Enabled");

      removeChild(notes[1]); // This is Line 635 , but I am not sure what I am doing wrong here.

      removeChild(notes[0]);

      nextFrame();

      }

       

      I am calling this Function with an If Statement , I need to make sure all the Movie Clips are loaded before the End User decides to move to next slide.

       

      Here is what I get when I run the Next Button ,

       

      ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

      at flash.display::DisplayObjectContainer/removeChild()

      at PORTDemoPresent_fla::MainTimeline/nextframepop1()[PORTDemoPresent_fla.MainTimeline::frame 2:635]

       

       

      Can anyone please help ?

        • 1. Re: Removing Movieclips from an Array Displayed on stage
          Ned Murphy CommunityMVP

          Based on what you show it is likely that some other function (like the one before it as shown) has already removed the object.  What you should do is learn to use the trace function to troubleshoot your code.  In this case put in a trace anywhere you add or remove the same object that tells you whether it is added or removed and which line of code it is, realizing that you might be storing the same object with different references to it.  That way you should be able to isolate where things are being removed when you don't expect them to be.

          • 2. Re: Removing Movieclips from an Array Displayed on stage
            navigator81 Community Member

            Thank you so much Ned for your guidance all the way  - I am trying Trace method on various Locations will try to fix it myself , in case I run in to any troubles , I will discuss with you.

             

            Thanks once again.