A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] removeMovieClip() in this script isn't working

  1. #1
    Member
    Join Date
    Dec 2006
    Posts
    45

    [F8] removeMovieClip() in this script isn't working

    I have absolutely no idea why the following code isn't working. I've checked the documentation for removeMovieClip at least a dozen times. The only thing I've noticed is the following:

    Method; removes a movie clip instance created with duplicateMovieClip(), MovieClip.duplicateMovieClip(), or MovieClip.attachMovie().
    As you will notice, I'm using createEmptyMovieClip() - not one of the methods mentioned - but I swear I've used removeMovieClip to delete movieclips created this way before and it's worked fine. I can't find an alternative command, either.

    Here is my code. When I trace white in the onRollOut function, it returns the correct path, so it's not a targetting issue. I've also tried adjusting one of the movieclip white's properties (alpha) and it's worked fine.

    Code:
    planet.onRollOver = function(){
    	var over:MovieClip = createEmptyMovieClip("white",this.getDepth()-1);
            //other events
    }
    
    planet.onRollOut = function(){
            white.removeMovieClip(); //trace here returns proper path
    }
    Any ideas as to why this command isn't working would be great.
    Using: Flash Professional 8 | Flash Player 8/9 | Actionscript 2 | PHP 5.1.6 | MySQL 5.0 |


    Latest Helpful Links: XML Dropdown Menu - How To Use Fusekit

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    removeMovieClip() can remove ANY movie clip as long as the depth of the movie clip is POSITIVE AND LESS THAN 1,048,575

    Movieclips that are made during author time can hence be removed by first making them positive and then using the removeClipMethod()

    Hence ANY movieclip mcHolder (dynamic or authortime) can be removed

    mcHolder.swapDepths(_root.getNextHighestDepth()):
    mcHolder.removeMovieClip();


    However if you use components sometimes elements are placed at a depth greater than 1,048,575, hence it cant be removed unless you lower the depth.

    So check the depth of the movieclip and if its higher than 1,048,575 first lower it to a lower depth and then try rmeoving it. so basically u can use something like:

    Code:
    if(mcHolder.getDepth() >= 1048575 || mcHolder.getDepth() <= 0 ){
        mcHolder.swapDepths(2000);
    }
    mcHolder.removeMovieClip();
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Member
    Join Date
    Dec 2006
    Posts
    45
    Hey, silentweed.

    Thanks for that information. May I ask where you found it? It wasn't in any of documentation I read.
    Using: Flash Professional 8 | Flash Player 8/9 | Actionscript 2 | PHP 5.1.6 | MySQL 5.0 |


    Latest Helpful Links: XML Dropdown Menu - How To Use Fusekit

  4. #4
    Junior Member
    Join Date
    Nov 2001
    Posts
    6
    Silentweed, I know this is a couple of years after the fact - just wanted to say thanks for posting that solution; it worked like a charm and saved me a lot of grief. Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center