I need help ( checking function)

on (release) {
if (Scene12input1 == “+Tcos45” || scene12input1 == “-Rcos60” && scene12input2 == “+Tcos45” || scene12input2 == “-Rcos60” && scene12input3 == “+Tcos45” || scene12input3 == “-Rcos60” && scene12input4 == “+Tcos45” || scene12input4 == “-Rcos60” && scene12input5 == “+Tcos45” || scene12input5 == “-Rcos60” )
{
gotoAndStop(“Scene 12”, 2);
}

}

It cant seems to work, basically there are 5 input boxes: scene12input1 - scene12input5…

Basically as long as user key in “+Tcos45” and “-Rcos60” in any of the 5 boxes, it will go to frame 2… but it some does not work… 0_0~~

Some works fine but some cant…:trout:

Try this one (but is the instancename of your button, put the code in a frame)
[AS]a1 = a2 = a3 = a4 = a5 = atot = 0;
but.onRelease = function() {
scene12input1 == “+Tcos45” || scene12input1 == “-Rcos60” ? a1=1 : null;
scene12input2 == “+Tcos45” || scene12input2 == “-Rcos60” ? a2=1 : null;
scene12input3 == “+Tcos45” || scene12input3 == “-Rcos60” ? a3=1 : null;
scene12input4 == “+Tcos45” || scene12input4 == “-Rcos60” ? a4=1 : null;
scene12input5 == “+Tcos45” || scene12input5 == “-Rcos60” ? a5=1 : null;
atot = a1+a2+a3+a4+a5;
atot == 5 ? gotoAndStop(“Scene12”, 2) : null;
};
[/AS]

scotty(-:

Eh it cant work upon reaching the screen, the input boxes are filled with default textx like “_level0.scene12input3”

Try:

on (release) {
	for (var i = 1; i<=5; i++) {
		if (this["Scene12input"+i] == "+Tcos45" || this["Scene12input"+i] == "-Rcos60") {
			trace("success");
			gotoAndStop("Scene 12", 2);
			break;
		}
	}
}

Thanks a lot but it also goes to next scene even though u enter onli one correct answer…

*Originally posted by MaTilDA *
Basically as long as user key in “+Tcos45” and “-Rcos60” in any of the 5 boxes, it will go to frame 2.
Isnt that what you want??

Basically as long as user key in “+Tcos45” and “-Rcos60” in any of the 5 boxes, it will go to frame 2.

its Both must key in… “+Tcos45” AND “-Rcos60” not or…

:h:

As long as two out of the five boxes have “+Tcos45” and “-Rcos60”… it will got to next frame…

Thanks claudio…

Ahh i get it now… try:

on (release) {
	for (var i = 1; i<=5; i++) {
		if (this["Scene12input"+i] == "+Tcos45") {
			for (var i = 1; i<=5; i++) {
				if (this["Scene12input"+i] == "-Rcos60") {
					trace("success");
					gotoAndStop("Scene 12", 2);
					break;
				}
			}
		}
	}
}

OMG!!! IT reallie works…

One last thing to solve:

How abt there are four sets of correct answers…

For example the first sets of answers are “+Tcos45” , “-Rcos60”

second sets is “apple” , “orange”, etc…

Ah let me take another road then…
Place the following code on a frame:

answers = [["+Tcos45", "-Rcos60"], ["apple", "orange"]];//add the other pairs here
function validate(n) {
	for (var i = 1; i<=5; i++) {
		if (this["Scene12input"+i] == answers[n][0]) {
			for (var i = 1; i<=5; i++) {
				if (this["Scene12input"+i] == answers[n][1]) {
					return true;
				}
			}
		}
	}
}

And this one on the button:

on (release) {
	for (var i = 0; i<answers.length; i++) {
		if (validate(i)) {
			trace("success");
			gotoAndStop("Scene 12", 2);
			break;
		}
	}
}

:slight_smile:

what if there are three answers in one set of answer???

Try to add another for if statement but cant ???
??

[AS]answers = [["+Tcos45", “-Rcos60”, “+Ltan30”], [“apple”, “orange”, “citron”]];
function validate(n) {
for (var i = 1; i<=5; i++) {
for (var k = 1; k<=3; k++) {
if (this[“Scene12input”+i] == answers[n][k]) {
return true;
}
}
}
}[/AS]
Not tested but give it try:)

scotty(-:

Answers will be ckecked upon clicking a button…
So what actions should be perform at the button???

Sorry I didn’t tell. Like the one Claudio gave you
[AS]on (release) {
for (var i = 0; i<answers.length; i++) {
if (validate(i)) {
trace(“success”);
gotoAndStop(“Scene 12”, 2);
break;
}
}
}
[/AS]

scotty(-:

quite a lot of errors, no matter what i input, it just go to next scene…:red:

[AS]answers = [["+Tcos45", “-Rcos60”, “+Ltan30”], [“apple”, “orange”, “citron”]];
function validate(n) {
for (var i = 1; i<=5; i++) {
if (this[“Scene12input”+i] == answers[n][0]) {
for (var i = 1; i<=5; i++) {
if (this[“Scene12input”+i] == answers[n][1]) {
for (var i = 1; i<=5; i++) {
if (this[“Scene12input”+i] == answers[n][2]) {
return true;
}
}
}
}
}
}
}[/AS]

code on your button stays the same

scotty(-:

it cant work either???