3 Replies Latest reply on Jul 15, 2006 12:58 PM by Rothrock

    Removing MC from stage?

    Nickname339966 Level 1
      I have a MC on stage called "label_SF" that slowly fades away. After it's completely faded (_alpha < 0), I was taught to remove the MC so it doesn't take up processing power. This is the only script I have in the file so far (just started this project), but it doesn't work:

      label_SF.onEnterFrame = function(){
      label_SF.speedA = 10;
      label_SF._alpha -= label_SF.speedA;
      trace(label_SF._alpha);
      if (label_SF._alpha < 0) {
      label_SF.removeMovieClip();
      }
      }

      The "if" statement should work, but the trace still shows the alpha values continue to drop... so it tells me that the clip is not removed. Help...

      David
        • 1. Re: Removing MC from stage?
          kglad Adobe Community Professional & MVP
          only movieclips that have depths between 0 and 1,048,575 are removable. so, use swapDepths() to place your movieclip at one of those depths and then execute your removeMovieClip() statement.
          • 2. Removing MC from stage?
            Wolf_van_Ween Level 1
            Cancelled -- Sorry
            • 3. Re: Removing MC from stage?
              Rothrock Level 5
              I don't think who ever taught you taught you quite right. Removing clips is a good idea, but in this case it isn't the most important part.

              First and foremost you should stop the onEnterFrame, that is going to be the biggest useless (once the clip is faded) waste of resources. Here is what I would put inside that if statement at the end.

              this._alpha=0;
              this._visible=false;
              delete this.onEnterFrame

              Since the alpha could be some crazy negative number setting it to zero is a good idea incase you need to fade it up later or some such.

              Setting the visibility to false will make sure that any rollovers, etc defined for that clip won't work.

              And finally deleting the onEnterFrame will save on resources.

              If a movie is hidden away and not referenced again Flash will automatically minimize its impact on the processor.

              As for removeMovieClip(). You should start with the help files on it. If you check there you will see that it can only remove dynamically instanced clips – e.g. those created with duplicateMovieClip, attachMovie, and createEmptyMovieClip. I think it is possible to use with a authoring environment placed clip if you first swapDepths() to a positive value depth – maybe, but not necessary.