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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex IF ? 1

Status
Not open for further replies.

coder1964

IS-IT--Management
Aug 28, 2003
29
CA
Greetings,

On a button press I need to jump to a certain frame. The frame I want to go to will depend on the value of a variable(s) received from an asp page. I can trace the variables so that part works OK.

This is where it gets sticky. I have tried various permutations but none work right so I wont post them.

Simplified psuedo code goes something like this:-

If var1 = 10,000 or var2 = "repeat" goto 2 else if var1 = 40,000 & var2= "bonus" goto 3 else if var1 = 80,000 & var 2 = "bonus" or "repeat" goto 17 else (default) goto "new".

The actual example I am working with is more complex but if I could get the above to work I will have made real progress.

T.I.A.



 
this ought to work
Code:
my_btn.onRelease = function(){
jump = (var10000 == 1 || var2 == "repeat") ? 2 :(var1 == 40000 || var2=="bonus")? 3:(var1 == 80000 && (var2 == "bonus" || var2 == "repeat"))? 17 : "new";
gotoAndStop(jump);
}
but if your example is more complicated id say use a switch statement
 
Thanks billwatson,

That works but I am none the wiser. I just dont understand the code.

Can you show me how to do it with switch?

T.I.A.
 
this should be allright and easier to follow and edit

Code:
on(release){
switch (var1){
	case 10000:
	jump = 2;
	break;
	case 40000:
	jump = 3;
	break;
	case 80000:
	jump = 17;
	break;
	default:
	jump = "new"
}
switch (var2){
	case "repeat":
	if(var1 !==10000||var1 !==40000||var1 !==80000)
	jump = 2;
	if(var1==80000)
	jump = 17;
	break;
	case "bonus":
	if (var1==40000)
	jump = 3;
	if (var1==80000)
	jump =17;
	break;
	default:
	jump = "new"
}
gotoAndStop(jump);
}
 
Billwatson,

Thank you for taking the time with me. I can follow that script just fine and I successfully edited parts.

Problem solved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top