Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Actionscript problem with else if

Status
Not open for further replies.

leujel

Programmer
May 28, 2003
23
0
0
NL
I have made a simple loop in flash that checks if a variable is the integer 5. If it is, it has to look what the value of another variable is. According to that value it has to play a certain frame.

But I cant make it work... Why not? Can somebody help me?

This is my code:
Code:
teller = random(100 + 1);
koe = random(8 + 1);
if (teller != 5)	{
	gotoAndPlay(1);
}
if (teller == 5)	{
	if (koe == 1)	{
		gotoAndPlay(3);
	} else if (koe == 2)	{
		gotoAndPlay(41);
	}else if (koe == 3)	{
		gotoAndPlay(81);
	} else if (koe == 4)	{
		gotoAndPlay(121);
	} else if (koe == 5)	{
		gotoAndPlay(161);
	} else if (koe == 6)	{
		gotoAndPlay(201);
	} else if (koe == 7)	{
		gotoAndPlay(241);
	} else if (koe == 8)	{
		gotoAndPlay(281);
	} else {
		gotoAndPlay(1);
	}
}

This is placed on frame 2 and frame 1 has the actionscript play() to it.



Visit
 
Don't know about the rest of it, but don't you want:

random(100)+ 1;

Adam
 
Also, and this just might be my inexperience, but I've never seen two "if"'s in a row like this:

if (teller == 5) {
if (koe == 1) {
gotoAndPlay(3);

Your problem might lie in there somewhere...

Adam
 
No that part goes well, it actually plays an frame, but only the first one, it looks like it doesn't check what the value of variable "koe" is.

Visit
 
You might need an "||" in there instead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top