2 Replies Latest reply on Oct 6, 2010 9:04 AM by prodigalmaster

    Removing movieclip after attaching from library

    prodigalmaster Level 2

      AS 2.0

      Hi! Here I attach a movieclip to another movieclip 'a'. It works.

      _root.MC_menu.MC_windowI.a.attachMovie(itemFocusInv,attachedItemA,getNextHighestDepth());

       

      Then later I want to remove the movieclip from 'a' so I tried this:

      _root.removeMovieClip(_root.MC_menu.MC_windowI.attachedItemA);

      -and variations.

      But it does nothing!

      In the first code the first argument is itemFocusInv without quotes because it is variable, once it is attached it doesnt vary but when it is not then the movieclip varys. If attachedItemA doesnt let me remove the movieclip, what will? I tried using _visible and didnt work.

       

      Here is more code if it helps!?

           _root.MC_useItem.MC_yes.onRelease = function() {
                if(itemSpaceA == "MC_inventory_berry_blue"){
                     aI = false;
                     itemSpaceA = "";
                     _root.removeMovieClip(_root.MC_menu.MC_windowI.a.attachedItemA);
                } else if(itemSpaceA == "MC_inventory_berry_red"){
                     aI = false;
                     itemSpaceA = "";
                     _root.removeMovieClip(_root.MC_menu.MC_windowI.a.attachedItemA);
                };
      

      hmm :/ I find removing movieclip from 'a' confusing.

        • 1. Re: Removing movieclip after attaching from library
          Rothrock Level 5

          You can try all kinds of variations, but only the right one will work.

           

          In your code you have given the new movieclip a name defined by a variable called attachedItemA but that is the name of the variable not necessarily the value of that variable, so that adds a level of complexity. But say the value of attachedItemA is "Bob" so in that case the newly attached movie's full path and name is:

           

          _root.MC_menu.MC_windowI.a.Bob

           

          And if you want to remove that clip you would then do this:

           

          _root.MC_menu.MC_windowI.a.Bob.removeMovieClip();

           

          Another good way to handle this would be to get a reference to the clip when it is attached:

           

          var someVar:MovieClip=_root.MC_menu.MC_windowI.a.attachMovie(itemFocusInv,attachedItemA,getNe xtHighestDepth());

           

          and then later you could just go:

           

          someVar.removeMovieClip();

           

           

          • 2. Re: Removing movieclip after attaching from library
            prodigalmaster Level 2

            Thank you!!

            _root.MC_menu.MC_windowI.a.attachedItemA.removeMovieClip(); 

            worked btw.