views:

1746

answers:

3

Hi there

I have a movieclip which unloads two other movieclips when it is clicked. This bit works fine, but it should also remove itself after this, which particularly does not work. Here is my code, can someone please tell me what I am doing wrong:

close_button.onRelease = function() {
 background.unloadMovie();
 loading.unloadMovie();
 this.unloadMovie();
}

Regards and TIA

// edit

Here is the code I create the movieclips:

// load background, movieclip container (loading) and close button
var background:MovieClip = _root.attachMovie("mc_back","loading_background", 100000);
var loading:MovieClip = _root.createEmptyMovieClip("loading",_root.getNextHighestDepth());
var close_button:MovieClip = _root.attachMovie("close_button","close_button",_root.getNextHighestDepth());

I tried:

this._parent.close_button.unloadMovie(); // it removed the whole _root movieclip, as _root is the parent

and

_parent.close_button.unloadMovie(); // did just nothing

Both failed.

A: 

In the event handler, 'this' would refer to close_button, not the main movie. All you need to do is either declare a variable equal to this outside of the close button onRelease handler, or try this.parent.unloadMovie() (assuming the parent of the close button is the movie you're trying to remove).

Alex Jillard
Thanks, I tried it, but it did not work, instead it unloaded everything in the swf, which was to be expected. Extra information in the post.
Anriëtte Combrink
A: 

Try

close_button.onRelease = function() {
    background.unloadMovie();
    loading.unloadMovie();

    this.removeMovieClip();  // This 'removes' the movie clip
                             // which is the closest to 'unload'

}
victor hugo
Thanks, I tried it, but it did not work. Extra information in the question.
Anriëtte Combrink
So you mean you want to unload the button? The button can't be unloaded but just hidden. I'm updating the answer
victor hugo
A: 

Hi! Maybe this can help:

http://board.flashkit.com/board/showthread.php?t=805607

Max

max