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

43 24005
mightybob
offline
mightybob
360 posts
Peasant

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
Nomad

Replace removeMovieClip() with unloadMovie()

removeMovieClip only works with clips generated with code.

mightybob
offline
mightybob
360 posts
Peasant

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
Nomad

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
360 posts
Peasant

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
Nomad

insert this into your enterFrame code:

trace(char);

Tell me what is returned.

mightybob
offline
mightybob
360 posts
Peasant

Nothing returns.

mightybob
offline
mightybob
360 posts
Peasant

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

arobegamr
offline
arobegamr
130 posts
Nomad

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

mightybob
offline
mightybob
360 posts
Peasant

mhm I've been looking at the output panel

arobegamr
offline
arobegamr
130 posts
Nomad

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

mightybob
offline
mightybob
360 posts
Peasant

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
360 posts
Peasant

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
Nomad

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