Forum Topic: if, else

(224 views • 11 replies)

This topic is 1 page long.

<< < > >>
None

chouji7

Reply To Post Reply & Quote

Posted at: 8/25/07 01:55 PM

chouji7 NEUTRAL LEVEL 26

Sign-Up: 11/01/06

Posts: 91

ok, so im making a game.
but the if else control i have that defines if you pass the level(if you have enough points) or not, doesnt work.

what i have is a dynamic text, the instance name is "score_txt" and it keeps the points, it works just fine.
than i have a movie clip. and on the internal timeline of the movie clip, on the last frame, i have the if else control. it looks like this.

if (_global.score=_global.score_txt==300) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}

now it should work just fine, if you have 300 points you go to frame 3(next level) and if you dont you go to frame 95(game over screen)
but when i didnt work i played around with it, and i discovered, it wasnt even looking at the condition, and if i had "==" or "===" it would automatically go to frame 95 when the frame of the internal timeline was entered, and when i had "=" or ">=" it would just take me to frame 3.
what is wrong with this control? please help me, tell me what to fix, or whatever it needs.


None

Forgetthename

Reply To Post Reply & Quote

Posted at: 8/25/07 01:57 PM

Forgetthename NEUTRAL LEVEL 18

Sign-Up: 11/20/04

Posts: 64

Try to make it like this:

if (_global.score=_global.score_txt.text==3 00) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}


None

souled

Reply To Post Reply & Quote

Posted at: 8/25/07 02:06 PM

souled NEUTRAL LEVEL 14

Sign-Up: 09/18/06

Posts: 1,558

I'm confused. Does this happen after you've been in the level for example 30 seconds and if you have 300 points by then you go to frame 3, and if you don't you go to frame 93 or whatever it was? Or is it when you reach 300 points you go to the next level because then you can't get game over and the else shouldn't be there.


None

chouji7

Reply To Post Reply & Quote

Posted at: 8/25/07 02:13 PM

chouji7 NEUTRAL LEVEL 26

Sign-Up: 11/01/06

Posts: 91

At 8/25/07 02:06 PM, souled wrote: I'm confused. Does this happen after you've been in the level for example 30 seconds and if you have 300 points by then you go to frame 3, and if you don't you go to frame 93 or whatever it was? Or is it when you reach 300 points you go to the next level because then you can't get game over and the else shouldn't be there.

no, the movie clip, that has the control on its last frame, is the amo, so when you run out of bullets, it sees if you have enough points or not
its operated by a screen that covers everything, so when you click, it activates:

on (release) {_root.amo.nextFrame();

}

which makes a bullet disappear. and amo's timeline reaches the last frame(0 bullets, and where the if else control is) it sees if you pass or not. atleast, thats how it should be. but it doesnt work, hence me inquiring about this.


None

Forgetthename

Reply To Post Reply & Quote

Posted at: 8/25/07 02:16 PM

Forgetthename NEUTRAL LEVEL 18

Sign-Up: 11/20/04

Posts: 64

Hmmm, could'n you just type this then:

if (global.score_txt >= 300) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}


None

chouji7

Reply To Post Reply & Quote

Posted at: 8/25/07 02:21 PM

chouji7 NEUTRAL LEVEL 26

Sign-Up: 11/01/06

Posts: 91

At 8/25/07 02:16 PM, Forgetthename wrote: Hmmm, could'n you just type this then:

if (global.score_txt >= 300) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}

i tried this when i was playing around with different combinations, its the same, since it is ">=" it goes automatically to frame 3.


None

chouji7

Reply To Post Reply & Quote

Posted at: 8/25/07 02:31 PM

chouji7 NEUTRAL LEVEL 26

Sign-Up: 11/01/06

Posts: 91

At 8/25/07 01:57 PM, Forgetthename wrote: Try to make it like this:

if (_global.score=_global.score_txt.text==3 00) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}

ugh, i got my hopes up with this one. but disappointingly it gave me the same result, if i had "==" frame 95,
if i had "=" or ">=" it would go frame 3.
thanks though.


None

chouji7

Reply To Post Reply & Quote

Posted at: 8/25/07 03:08 PM

chouji7 NEUTRAL LEVEL 26

Sign-Up: 11/01/06

Posts: 91

please help, its really needed.


None

Forgetthename

Reply To Post Reply & Quote

Posted at: 8/25/07 03:14 PM

Forgetthename NEUTRAL LEVEL 18

Sign-Up: 11/20/04

Posts: 64

if (_global.score >= 300) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}

Here it just checks the score var. It should work if the score is 300 or higher. If it doesn't I really don't know.


None

souled

Reply To Post Reply & Quote

Posted at: 8/25/07 03:17 PM

souled NEUTRAL LEVEL 14

Sign-Up: 09/18/06

Posts: 1,558

At 8/25/07 02:21 PM, chouji7 wrote:
At 8/25/07 02:16 PM, Forgetthename wrote: Hmmm, could'n you just type this then:

if (global.score_txt >= 300) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}
i tried this when i was playing around with different combinations, its the same, since it is ">=" it goes automatically to frame 3.

How about trying:

if (_global.score_txt >= 300) {
_root.gotoAndStop(3);
} else if (_global.score_txt < 300) {
_root.gotoAndPlay(95);
}


None

chouji7

Reply To Post Reply & Quote

Posted at: 8/25/07 06:39 PM

chouji7 NEUTRAL LEVEL 26

Sign-Up: 11/01/06

Posts: 91

At 8/25/07 03:17 PM, souled wrote:
At 8/25/07 02:21 PM, chouji7 wrote:
At 8/25/07 02:16 PM, Forgetthename wrote: Hmmm, could'n you just type this then:

if (global.score_txt >= 300) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}
i tried this when i was playing around with different combinations, its the same, since it is ">=" it goes automatically to frame 3.
How about trying:

if (_global.score_txt >= 300) {
_root.gotoAndStop(3);
} else if (_global.score_txt < 300) {
_root.gotoAndPlay(95);
}

wow, i got my hopes up with this one too. but once again, its taking me to frame 3 no matter how many points i have. so i tried changing ">=" to "==" and than it just ignored the control completely, it didnt do anything when it entered the frame on the timeline.


None

chouji7

Reply To Post Reply & Quote

Posted at: 8/25/07 09:22 PM

chouji7 NEUTRAL LEVEL 26

Sign-Up: 11/01/06

Posts: 91

At 8/25/07 03:14 PM, Forgetthename wrote: if (_global.score >= 300) {
_root.gotoAndStop(3);
} else {
_root.gotoAndPlay(95);
}

Here it just checks the score var. It should work if the score is 300 or higher. If it doesn't I really don't know.

score var?
will that work if its just dynamic text?


All times are Eastern Standard Time (GMT -5) | Current Time: 04:59 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!