# This.removeMovieClip doesn't work!?

**URL:** <https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824>\
**Category:** Uncategorized\
**Created:** [April 21, 2003, 5:53pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824 "2003-04-21T17:53:50Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![thorseye](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/thorseye/32/66_2.png) [@thorseye](https://forum.kirupa.com/u/thorseye)\
**Post date:** [April 21, 2003, 5:53pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/1 "2003-04-21T17:53:50Z")

</div>

I’m doing a game (supposed to be done tomorrow).  
In this game I’ve got a hero who throws books at the enemies.  
When the book hits the enemy, I want the book to dissapear, but the thing is that it contiues to fly straight ahead and kill all the other enemies too. I’ve got a really huge source code for the game, but this part wouldn’t be too hard to do, would it?  
So I’ve put this piece of code inside the book’s movieclip.

```php
onClipEvent (enterFrame) {
	this._x += bokSpeed;
	for (i = 0; i < 3; i++) {
		if (this.hitTest(_root.tomt["fiende"+i])) {
// This part seems not to work. WHY????
			this.removeMovieClip();
			_root.tomt["fiende"+i].play();
		}
	}

```

Please help me today. I really need to get this game ready for tomorrow…

---

<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:** [April 21, 2003, 6:05pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/2 "2003-04-21T18:05:04Z")

</div>

if that’s the original MovieClip it won’t be removed… :-\

you should try with attachMovie instead of duplicateMovieClip (i assume you’re using duplicateMovieClip, am i right?)

=)

---

<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:** [April 21, 2003, 6:15pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/3 "2003-04-21T18:15:54Z")

</div>

Actually I’ve tried both and right now I’m using attachMovie. So how should I write the script for removing the book mc that hit the enemy?  
The attachMovie code goes here:

```php
if (Key.isDown(Key.SPACE) && _root.antalSkott > 0) {
		_root.antalSkott--;
		this.attachMovie("bok", "bok"+bokAntal, bokAntal);

```

---

<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:** [April 21, 2003, 6:25pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/4 "2003-04-21T18:25:47Z")

</div>

i guess you could use an onEnterFrame event handler…

```auto
this["bok"+bokAntal].onEnterFrame = function() {
if (this.hitTest(enemy)) this.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:** [April 21, 2003, 6:40pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/5 "2003-04-21T18:40:16Z")

</div>

Hmm… I can’t get your script to work. I changed it to my values, and put it in the same frame as where I’ve got the attachMovie code. Is that correct?

---

<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:** [April 21, 2003, 6:41pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/6 "2003-04-21T18:41:59Z")

</div>

well… that’s the theory. it’s hard to say without seeing the actual code. :-\

---

<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:** [April 21, 2003, 6:45pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/7 "2003-04-21T18:45:03Z")

</div>

I post the sourcefile. Lots of crapcode here, but you’ll maybe find what’s wrong?

---

<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:** [April 21, 2003, 6:49pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/8 "2003-04-21T18:49:27Z")

</div>

ok… i’ll check out your fla. just give me some time, please. 😉

---

<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:** [April 21, 2003, 6:59pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/9 "2003-04-21T18:59:25Z")

</div>

Thank you very much. Just that you’re taking the time and look through it. Take your time =) Btw… Sorry for all the variables and comments. It’s in swedish… Ⓜ

---

<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:** [April 21, 2003, 7:05pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/10 "2003-04-21T19:05:00Z")

</div>

yeah… i lose track easily. 😛

… but i’ll figure it out (i hope). =)

---

<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:** [April 21, 2003, 7:44pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/11 "2003-04-21T19:44:15Z")

</div>

im probably wrong…but isnt it \_this?  
edit…wait im wrong…never mind

---

<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:** [April 21, 2003, 7:49pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/12 "2003-04-21T19:49:07Z")

</div>

ehmm… i need some help here. :-\

i don’t understand a thing!! everytime i look to the next line of the code, i totally forgot where i was!! it’s so frustrating… ☹

besides i can’t even find all the code!! 😛

---

<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:** [April 21, 2003, 7:55pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/13 "2003-04-21T19:55:40Z")

</div>

Haha… Yeah I know… Pretty confusing it is… Well here’s the deal

In the first frame in \_root I create the map, place the player and the enemies.

In the mc “evald” (which is the player) i have the code for walking in the first frame. In this movieclip I also attach the book mc on line 35 or something… I’ve linked the mc called “boken” as “bok” so that’s the mc which is attached. In “boken” I’ve put the mc “bok” with some script in it.

If you select the player in the mc evald, I’ve got some code to check if he hits an enemy.

It’s pretty hard to know exactly where all the mc’s are positioned because I attach them inside other mc’s all the time. It IS really confusing… But this is my first game ever so…

Hope that explained something…

---

<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:** [April 21, 2003, 8:51pm UTC](https://forum.kirupa.com/t/this-removemovieclip-doesnt-work/18824/14 "2003-04-21T20:51:50Z")

</div>

this is really weird… it simply is not performing any actions. :-\

i’m clueless!! :hair:
