5 Replies Latest reply on May 4, 2006 12:17 PM by pwyon

    RemoveMovieClip doesn't work?

    uxk8396
      Hi,
      Kindly advise the best way to remove duplicateMovieClip in other frames!

      I tried the folowing:

      this.onEnterFrame=function(){
      back1_btn.onRelease = function() {
      gotoAndStop("one");
      unloadMovie("snowflake");
      removeMovieClip("snowflake");
      snowflake.removeMovieClip();
      };
      }
        • 1. Re: RemoveMovieClip doesn't work?
          TimSymons Level 1
          Why do you have this inside an onEnterFrame event?

          I'm assuming that you created the "snowflake" mc with a duplicateMovieClip or attachMovieClip method. I think your problem is a scoping issue. When you defined the button back1_btn function, the reference is from inside that button. So unless "snowflake" is inside the back1_btn your calls won't work from there.

          if your "snowflake" movie was created on the same level as the back1_btn then you should be able to use this:

          back1_btn.onRelease = function() {
          this._parent.snowflake.removeMovieClip();
          // this : refers to the button
          // _parent : refers to the level just above the button
          };

          If it is on a different path than the back1_btn, you will need to use the correct path to the movieclip before the removeMovieClip method will work.

          Tim
          • 2. Re: RemoveMovieClip doesn't work?
            Level 7
            Why do you have this inside an onEnterFrame event?

            I'm assuming that you created the "snowflake" mc with a duplicateMovieClip or
            attachMovieClip method. I think your problem is a scoping issue. When you
            defined the button back1_btn function, the reference is from inside that
            button. So unless "snowflake" is inside the back1_btn your calls won't work
            from there.

            if your "snowflake" movie was created on the same level as the back1_btn then
            you should be able to use this:

            back1_btn.onRelease = function() {
            this._parent.snowflake.removeMovieClip();
            // this : refers to the button
            // _parent : refers to the level just above the button
            };

            If it is on a different path than the back1_btn, you will need to use the
            correct path to the movieclip before the removeMovieClip method will work.

            Tim

            • 3. Re: RemoveMovieClip doesn't work?
              uxk8396 Level 1

              Hi Tim:
              Actually I made use of the following in frame "two" to create the duplicate MovieClip:
              stop();
              for (var i = 0; i<100; i++) {
              snowflake.duplicateMovieClip("snowflake"+i, i);
              }

              But how do I trace on which level or path is "snowflake" in reference to back1_btn

              I tried the following on the frame "one" where I want to get rid of the "snowflake" MovieClip

              _root.snowflake.removeMovieClip();

              But it did not work either.
              Please clarify.
              Thx
              Uti
              • 4. Re: RemoveMovieClip doesn't work?
                TimSymons Level 1
                Nope that won't work because you didn't create "snowflake" dynamically. You did create "snowflake0", "snowflake1", "snowflake2", etc. dynamically. So your code would have to reflect this.

                _root.snowflake0.removeMovieClip();

                This should remove the first movieclip you created. You would then probably have to loop through the rest to get them as well.

                Tim
                • 5. Re: RemoveMovieClip doesn't work?
                  pwyon
                  Try this:
                  //this goes on a frame.
                  for( i=0 ; i<100 ; +i++ ){
                  sf = snowflake.duplicateMovieClip( "snowflake"+i , i );
                  sf._x = Math.random() * Stage.width;
                  sf._y = Math.random() * Stage.height;
                  }//end for



                  //this goes on a button called "myButton".
                  myButton.onPress = function( ){
                  for( i=0 ; i<100 ; i++ ){
                  sf = _root["snowflake"+i]
                  removeMovieClip( sf );
                  }//end for
                  }//end button

                  Hope that helps! Take care.