# Movieclip unloading itself

**URL:** <https://forum.kirupa.com/t/movieclip-unloading-itself/21904>\
**Category:** Uncategorized\
**Created:** [May 27, 2003, 9:04pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904 "2003-05-27T21:04:18Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![schling](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@schling](https://forum.kirupa.com/u/schling)\
**Post date:** [May 27, 2003, 9:04pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/1 "2003-05-27T21:04:18Z")

</div>

Well, yes it me again… 😉

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() {  
this.\_root.removeMovieClip(“myMovieClip”);  
};

How can I make this work??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2003, 9:14pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/2 "2003-05-27T21:14:12Z")

</div>

if you actually want to unload its content…

```auto
this._parent.unloadMovie();

```

but yeah, you could use removeMovieClip.

```auto
this._parent.removeMovieClip();

```

😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2003, 9:16pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/3 "2003-05-27T21:16:34Z")

</div>

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…

[AS]this.\_parent.swapDepths(1);  
this.\_parent.removeMovieClip();[/AS]

I think… lol.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2003, 9:17pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/4 "2003-05-27T21:17:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2003, 9:40pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/5 "2003-05-27T21:40:11Z")

</div>

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

Witch leaves me with a code like this.

remove.onRelease = function() {  
this.\_parent.swapDepths(1);  
this.\_parent.removeMovieClip(“whoami”);  
}

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2003, 9:45pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/6 "2003-05-27T21:45:13Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2003, 10:03pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/7 "2003-05-27T22:03:34Z")

</div>

Okey, tried :

remove.onRelease = function() {  
this.removeMovieClip();  
}

and

remove.onRelease = function() {  
this.\_parent.removeMovieClip();  
}

and

remove.onRelease = function() {  
this.\_whoami.removeMovieClip();  
}

But none of the codes work ☹ 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 😉

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 3:58am UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/8 "2003-05-28T03:58:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 7:15am UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/9 "2003-05-28T07:15:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 7:26am UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/10 "2003-05-28T07:26:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 7:33am UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/11 "2003-05-28T07:33:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 7:50am UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/12 "2003-05-28T07:50:49Z")

</div>

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});  
};[/AS]

And by changing this… [AS]remove.onRelease = function() {  
this.\_parent.removeMovieClip();  
}[/AS] to this… [AS]drag.onPress = function() {  
this.\_parent.startDrag();  
};  
drag.onRelease = drag.onReleaseOutside=function () {  
this.\_parent.stopDrag();  
};  
remove.onRelease = function() {  
this.\_parent.removeMovieClip();  
};[/AS]

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 7:58am UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/13 "2003-05-28T07:58:53Z")

</div>

Hey 🙂 Nice one lostinbeta. Thanks, this really helps me.

Now, just let me test it.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 8:03am UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/14 "2003-05-28T08:03:16Z")

</div>

Test away. I hope it helps.

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 8:07am UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/15 "2003-05-28T08:07:28Z")

</div>

It works fine. Thanks again 🙂

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2003, 4:36pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/16 "2003-05-28T16:36:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2003, 8:34pm UTC](https://forum.kirupa.com/t/movieclip-unloading-itself/21904/17 "2003-05-29T20:34:26Z")

</div>

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