Movieclip unloading itself

Well, yes it me again… :wink:

Okey. I am trying to make a movieclip unload itself when I press a button in it.

Here is the code I have tried so far but that don’t work. (or else I would have posted here right?)

button.onRelease = function() {

How can I make this work??

if you actually want to unload its content…


but yeah, you could use removeMovieClip.



If the clip is on the stage you can only use removeMovieClip() if the clip is on a removeable depth. So… that leaves us with…


I think… lol.

i use this.unloadMovie() all the time… it works… or i might be missing something… :q:

Well, I tried many different codes now and none seems to work.

Witch leaves me with a code like this.

remove.onRelease = function() {

Kax, if it helps you, the moveclip I am now trying to remove is the one I loaded from the library.

If you loaded it from the library via actionscript, you don’t need to do the swapDepths() method as you probably already loaded it into a removeable depth.

As for it not working, It is probably because of the “whoami” when you use removeMovieClip you target it as clip.removeMovieClip() not removeMovieClip(clip). In that script , after you remove the “whoami” you are telling the clip you are pressing to removed.

If that doesn’t work, try changing it to just [AS]this.removeMovieClip()[/AS]

Okey, tried :

remove.onRelease = function() {


remove.onRelease = function() {


remove.onRelease = function() {

But none of the codes work :frowning: What am I missing. Bet I am code blind right now since I have been sitting all days with codes. Like to try on my own before I ask… but I always end up asking anyway :wink:

Night here in norway so I will go to bed now. Good night,

this._whoami wouldn’t work for multiple reasons. the whoami clip isn’t inside that movie clip, and you don’t target clip instance names with an underscore first.

And I don’t see why none of those didn’t work. Is the clip you are pressing the clip that you want to be removed?

Yes, I have a button inside a movieclip that I have loaded from the library. And I want this button to remove the newly opend movieclip.

Wait, you have a button inside of a movie clip and you are trying to remove a movie clip from where?

Inside the movie clip, or outside the movie clip in another timeline?

Can you post your .fla? It would make this a lot easier.

Okey… hopefully I can post this fla. I had some trouble with it yesterday.

Ok, now this makes more sense.

The code isn’t working not because of the code, but because of how you have this set up.

When you load the movie you add onPress and onRelease actions to the clip to make it draggable, but see, this makes the whole thing a button.

And this button is over top of your button inside of the clip. So therefore the button inside the movie clip cannot be pressed.

To fix this we will need to make a new button inside the clip that will be used to drag instead of the main clip itself. You can do this by changing this [AS]myButton.onRelease = function() {
this._parent.attachMovie(“myMovieClip”, “myMovieClip”, 0, {_x:240, _y:140, onPress:startDrag, onRelease:stopDrag});
};[/AS] to this… [AS]myButton.onRelease = function() {
this._parent.attachMovie(“myMovieClip”, “myMovieClip”, 0, {_x:240, _y:140});

And by changing this… [AS]remove.onRelease = function() {
}[/AS] to this… [AS]drag.onPress = function() {
drag.onRelease = drag.onReleaseOutside=function () {
remove.onRelease = function() {

Then making the white area of your movie clip a movie clip symbol or a button symbol with the instance name “drag” (no quotes) so that the code above will target it to be a button and draggable.

Check my .fla to see it in action.

Hey :slight_smile: Nice one lostinbeta. Thanks, this really helps me.

Now, just let me test it.

Test away. I hope it helps.

And see, uploading the example .fla did help a lot better :slight_smile: I would have never guess that was what was wrong in a million years.

It works fine. Thanks again :slight_smile:

Yeah, uploading the files always help but yesterday I had real trouble getting anything uploaded. So I was suprised to se it work today.

Hmm, thats weird. Kirupa is working on setting up themes for the forum that you can choose in your user options, perhaps in that process things were acting oddly and that is why it didn’t work.

Yeah, kinda strange. But it’s working again now tought.