PDA

View Full Version : Stupid coin code



gaming monkey
February 25th, 2005, 03:01 PM
Hi everyone, could anyone please help me.
I'm using this code

_root.onEnterFrame = functions;
score=0
function functions() {
for (i = 1; i<=14; i++) {
if (fly.hitTest(_root["coin"+i])) {
_root["coin"+i].play();
score++;
}
}
}

It works ok. So I can have as many coins on stage as I want, as long as each one is named?
coin1
coin2
coin3
coin4
and so and so on....

I have named each coin like this all the way up to coin20.
BUT my problem is, only coin1 to coin 14 works. The rest dont hit test with the fly. Why does that happen!?
Surely, they would all work as long as the coins are named properly, but it doesn't.

Please can someone help me out here, why is this happening? Could someone either fix the problem or offer alternative code that works.

Thank yo very much.

SeiferTim
February 25th, 2005, 03:06 PM
_root.onEnterFrame = functions;
score=0;
maxCoins = 20;
function functions() {
for (i = 1; i<=maxCoins; i++) {
if (fly.hitTest(_root["coin"+i])) {
_root["coin"+i].play();
score++;
}
}
}

You only have it counting to 14...

gaming monkey
February 25th, 2005, 03:12 PM
Whoa, I'm so stupid, I noticed it like 5 minutes after posting it, thanks for the quick response, man I'm stupid.

What a waste of time, I should really concentrate more on the code I use, sorry for that.

SeiferTim
February 25th, 2005, 03:33 PM
9 times out of 10 its a stupid mistake that gets you ;)

gaming monkey
February 25th, 2005, 03:40 PM
Tell me about it, I get very frustrated with myself :D

Well, a new problem has reared its head. take a look at this swf
http://img71.exs.cx/my.php?loc=img71&image=testproblem0017jb.swf

What I would like is to check to see if the small black square is outside the big box, if it is then gotoandplay a certain frame.

I was thinking to check its x and y position and see if its bigger or smaller than the big box, but for some reason i cant get it to work.

Please, can someone help me with this problem, its really urgent.

Thank you.

bombsledder
February 25th, 2005, 05:52 PM
Tell me about it, I get very frustrated with myself :D

Well, a new problem has reared its head. take a look at this swf
http://img71.exs.cx/my.php?loc=img71&image=testproblem0017jb.swf

What I would like is to check to see if the small black square is outside the big box, if it is then gotoandplay a certain frame.

I was thinking to check its x and y position and see if its bigger or smaller than the big box, but for some reason i cant get it to work.

Please, can someone help me with this problem, its really urgent.

Thank you.


if(_root.bigbox.hitTest(_root.smallbox)){
_root.bixbox.gotoAndPlay("certainframe")
}

something like that?

gaming monkey
February 25th, 2005, 06:16 PM
No, I think you've misunderstood me, but it's ok because I've thought of an alternative.
Instead I used this:

if(!this.hitTest(_root.box)){
gotoandPlay(6);
}

Thank you for your time though. =)