9 Replies Latest reply on Jun 7, 2006 3:30 PM by Rothrock

    createEmptyMovieClip    removeMovieClip???

    Tolk Level 1
      How do you remove a movie clip created with the createEmptyMovieClip() function?
      I have tried:
      movieclip.removeMovieClip
      movieclip.unloadMovie
      but neither seems to work and in "help" it states they are for other movieclip loading functions.
      I have been trying to call these using the: this["var"+var] and the eval() version, i don't know if this makes a difference (i.e.
      this["test"+i].removeMovieClip(); )
      Anyway thanks for help!
        • 1. Re: createEmptyMovieClip
          blemmo Level 1
          Normally it's enough to say instancename.removeMovieClip(), so maybe the instance name you use isn't correct. If you use the 'this' keyword, check its scope (e.g., in a mouse event or an event of an MC, like onRelease, it refers to the object that throws the event). You can check the scope with trace(this), this will show to which object it refers.
          If the MC you're trying to remove has a negative depth, you must use swapDepths() with a positive depth first before you can remove it.

          hth,
          blemmo
          • 2. Re: createEmptyMovieClip
            Tolk Level 1
            Hmmm, i wouldnt think its out of the scope of "this" because i'm creating the object and trying to remove it in the same couple of lines of code. I know the create is working but the remove isnt.
            The instance name is definately correct.
            The depth of the created movieclip on creation is getNextHighestDepth so they shouldnt be stored in negative depths?
            I'm lost as to what to do, anyone got any opinions?
            • 3. Re: createEmptyMovieClip
              Rothrock Level 5
              this.createEmptyMovieClip("NewClip",100);
              NewClip.removeMovieClip();

              Works just fine for me under Flash 7. Are you using any MM components. If so then using getNextHighestDepth() will give you a depth that is too high to be removed. So either don't do that or swap it to a lower depth before you try and remove it.
              • 4. Re: createEmptyMovieClip
                Tolk Level 1
                Basically (this is all in multiple loops (where the i's and a's etc. come from))
                I create the movie clip and draw into it as below, this all works great:

                this.createEmptyMovieClip(("bar"+i),this.getNextHighestDepth());

                this["bar"+i].beginFill(colour);
                this["bar"+i].moveTo(((i/a)*100), (100-(_global.bars.bars /t*100)));
                this["bar"+i].lineTo(((((i+1)/a)*100)-1), (100-(_global.bars.bars
                /t*100)));
                this["bar"+i].lineTo(((((i+1)/a)*100)-1), 100);
                this["bar"+i].lineTo(((i/a)*100), 100);
                this["bar"+i].lineTo(((i/a)*100), (100-(_global.bars.bars /t*100)));
                this["bar"+i].endFill();

                Then I try and remove the movie clip with this code, but this doesnt work (all code is in same frame on same movieclip... etc.):

                this["bar"+i].removeMovieClip();

                Iv'e checked the depths its printing them to by doing trace(getNextHighestDepth); before drawing to it and they seem fine, rangeing from 1 to around 6 so not negative and not too high.
                Using no components.
                HELP!
                • 5. Re: createEmptyMovieClip
                  Rothrock Level 5
                  Why are you putting parens around "bar"+i in the createEmptyMovieClip.

                  Also are you sure that i still has the same value that you had. Alot of times people have incremented their counter before they get to the next usage and don't realize it.

                  Of course if you remove the clip in the same frame, you won't see the clip at all since all the code in a frame executes and then the screen is redrawn. Just a thought.
                  • 6. Re: createEmptyMovieClip
                    Tolk Level 1
                    The parens where left there from something i tried earlier but they shouldnt effect anything.
                    If you give me an address i can email you the fla so you can see better what i'm doing - Basically draw a chart from submitted data then evertime the data is re-submit draw over old chart (which is wat doesnt work).

                    If you do give me an address read this once recieved file:

                    I'm still in the middle of this so there's some stuff with no functionality (i.e. the rows and cols box).
                    Type the data in and hit the submit button, then change the data and re-submit and you should see the problem.
                    The code that's not working is in the first frame of the symbol mcBarChart.
                    The counter value shouldn't be an issue because it re-runs over all old objects.
                    Hopefully this will help you help me
                    • 7. Re: createEmptyMovieClip
                      Tolk Level 1
                      No worries mate,
                      Sorted it, had to use this:

                      var mTemp:MovieClip = this.getInstanceAtDepth(0);
                      mClip.swapDepths(0);
                      mClip.removeMovieClip();
                      if(mTemp != undefined) {
                      mTemp.swapDepths(0);
                      }

                      Depths weren't over the top so i thought i wouldn't need to swap, tried swap anyway and didn't work, tried swap with this to replace anything stored in 0 and worked YEY!
                      • 8. Re: createEmptyMovieClip
                        from what I have seen negative depth level movieclips can't be removed.

                        anyone else know this to be true?
                        • 9. Re: createEmptyMovieClip    removeMovieClip???
                          Rothrock Level 5
                          Don't know. I think you are probably correct. Have you tried it?

                          Here is a great tutorial about depths in Flash: http://www.kirupa.com/developer/actionscript/depths.htm

                          Also you might not want to call them "depth level." _levels are something else that folks often confuse with depths. Just "depths" will do.