ForumsProgramming ForumHittesting multiple movie clips with the same identifier? (AS2)

43 9292
mightybob
offline
mightybob
363 posts
Shepherd

Well somewhere I read that the more enterFrame's I use the more lag there will be.

So I am trying to make a lot of things be in 1 enterFrame, like coins.

So I need it to be so that when you hit a coin, it goes away, and you 1 point, just like it already does but so that I only need 1 enterFrame. Kind of like target objects in As3. But I don't know how to do this in as2â¦

Help?

  • 43 Replies
arobegamr
offline
arobegamr
130 posts
Peasant

Replace removeMovieClip() with unloadMovie()

removeMovieClip only works with clips generated with code.

mightybob
offline
mightybob
363 posts
Shepherd

Still does not work, I don't think you get it.

It doesn't even trace "You win", which means something with the code itself is wrong.

arobegamr
offline
arobegamr
130 posts
Peasant

I've checked the code and it works fine for me.

What flash version are you using, and what method are you using to move your char clip?

mightybob
offline
mightybob
363 posts
Shepherd

I'm using Flash cs6 action script 2, exporting to Flash Player 10.3

To move my char clip I am just doing "_x += speed" etc.

arobegamr
offline
arobegamr
130 posts
Peasant

insert this into your enterFrame code:

trace(char);

Tell me what is returned.

mightybob
offline
mightybob
363 posts
Shepherd

Nothing returns.

mightybob
offline
mightybob
363 posts
Shepherd

I also tried tracing "Hello world" inside the onEnterFrame. It doesn't trace, so the problem is the enterFrame.

arobegamr
offline
arobegamr
130 posts
Peasant

Make sure you're looking at the output panel, not the compiler errors panel

mightybob
offline
mightybob
363 posts
Shepherd

mhm I've been looking at the output panel

arobegamr
offline
arobegamr
130 posts
Peasant

Have you tried a trace function outside of the enterFrame function?

mightybob
offline
mightybob
363 posts
Shepherd

I have a trace above the onEnterFrame thing, it traces it. It also traces if I put it after the onEnterFrame is over.

mightybob
offline
mightybob
363 posts
Shepherd

I have no clue what this had to do with everything, but I removed another enterFrame in a different frame and all works great! Thank you everyone, you were very helpful!

arobegamr
offline
arobegamr
130 posts
Peasant

A single clip can only have one onEnterFrame function.

See, what you are doing when you say onEnterFrame = function() { is specifying a function called onEnterFrame, which is reserved by flash and called each frame.

Say you had two functions called gameLoop() and gameOverLoop(), and you did the following:

onEnterFrame = gameLoop;
onEnterFrame = gameOverLoop;


Flash replaces the original onEnterFrame (gameLoop), with the new one (gameOverLoop).

It's the same as any variable or method, when you specify a new one, it overwrites the old one. A very good thing to know for the future.

Keep at it. You'll learn the common mistakes and how to avoid them.

Showing 31-43 of 43