This.removeMovieClip doesn't work!?

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.

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…

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?)

=)

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:

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

i guess you could use an onEnterFrame event handler…

this["bok"+bokAntal].onEnterFrame = function() {
if (this.hitTest(enemy)) this.removeMovieClip();
};

=)

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?

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

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

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

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… :m:

yeah… i lose track easily. :stuck_out_tongue:

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

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

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… :frowning:

besides i can’t even find all the code!! :stuck_out_tongue:

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…

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

i’m clueless!! :hair: