7 Replies Latest reply on Jun 22, 2007 7:45 AM by SurgicalSteel

    erasing "dynamically created" movie clips

      hey all,
      sorry for all the questions, but i have yet another one. how would one get rid of movie clips put on the stage with attachMovie. I've tried removeMovieClip and clear but they remain on the stage. I remember doing this last year in a class but I've lost the project files for that and can't remember how to do it. Is there some screen refresh or something that I'm missing? Thanks.
        • 1. Re: erasing "dynamically created" movie clips
          Rothrock Level 5
          Well a good place to start would be the help files. If you didn't know what to look for start with the method you are using to put them there, so if you read MovieClip.attachMovie() at the bottom is suggests that you also check out MovieClip.removeMovieClip();

          So I follow that link. You don't say which version of Flash you are using, but I'm going to guess Flash 8 or 9 (CS3)? There the documentation says that it removes movieclips created with attachMovie(). So if that is what you are using that is what you need to use to remove them.

          Next it goes on to give a lot of reasons why it might fail. Do any of them match up with things you are doing? My guess is that you are using a component, and that you attached the movie with a getNextHighestDepth which placed it in a range too high to be removed. My advice for that would be to stop using getNextHighestDepth(), but otherwise you could swap the depths to a lower value and then remove it.

          Of course there could be other reasons. Perhaps there is a scoping issue? Test your swf in the testing environment. When it is at a point where you think the clip should be removed, go up to the Debug menu and select list variables. Find in the output window the name of the clip that was to be removed. Note down the whole path. Then check to see if that is where your removeMovieClip is looking for it.
          • 2. Re: erasing "dynamically created" movie clips
            SurgicalSteel Level 1
            Sorry, I'm using AS2. I keep forgetting that there is more than one version of AS. Anyways, I went through and checked everything you said. I am not using a component, the movie I am attaching is just a little graphic I made with the authoring tools as they call 'em, with a couple of dynamic text fields. I got rid of getNextHighestDepth() and replaced it with a number system starting from 0 and increasing with each added movie clip. I did the debug>>list variables thing and got "_level0.noteB". So I tried using _level0.noteB.removeMovieClip() and nothing, I also tried _root.noteB.removeMovieClip() just for kicks and nothing.

            I then had my program trace out _root.gui.notes[n].ivar on onPress and it traces out correctly. Which would lead me to believe that _root.gui.notes[n] is the correct path, unless I'm missing something. I also tried this.removeMovieClip() on onPress and nothing. I get the feeling I'm missing some little nuance of attachMovie.
            • 3. Re: erasing "dynamically created" movie clips
              Rothrock Level 5
              I figured it was AS2, I just wasn't sure which version of the help files you would have. (AS3 doesn't have attachMovie!) Well this all seems correct. Here are two more things.

              Often when I'm having trouble I try a different method/property to see if it works. So try:


              Does that change the alpha?

              The other thing is you've shared a lot about your removeMovieClip, but how about the actual code for the attaching?
              • 4. Re: erasing "dynamically created" movie clips
                SurgicalSteel Level 1
                thanks, i'll try a different method and see what happens. Since I have to go upstairs to a different computer to do this I'm just going to give you the details of the attaching here and now:

                I have a button called "addNote", when that button is clicked it calls the addNote method of the gui class (which is instantiated when the program starts) which does a little something i like to call:

                function addNote(x:Number, y:Number, num:Number){
                notes.push(_root.attachMovie("noteBox", "noteB", num, {_x:x, _y:y, elNum:num});

                "notes" being an array field variable of the gui class file. I'm pushing attachMovie()s into an array because I need to be able to change the content of the dynamic text fields in individual noteBox movies from a different button (specifically modifyNote). It's been a while since I've used flash or AS, so I wouldn't be surprised if I'm doing everything back-asswards and convoluted, haha.
                • 5. Re: erasing "dynamically created" movie clips
                  SurgicalSteel Level 1
                  ok, i tried _root.gui.notes[n]._alpha = 50 and it decreases the alpha of the movie clip, except for the text fields in the movie clips. is that normal?
                  • 6. Re: erasing "dynamically created" movie clips
                    Rothrock Level 5
                    How about if you use the global method:


                    It all seems right. Are you mixing timeline stuff in here?

                    I'm guessing the text field issue is because the fonts aren't embedded.
                    • 7. Re: erasing "dynamically created" movie clips
                      SurgicalSteel Level 1
                      Ah, it works. Thanks for the help, much appreciated.