• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Problem regarding an AS3 program

New Here ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

I stuck on a program which I want to run for checking whether the given answer is right or wrong. In the program, I ask the user whether an equation is linear or non-linear. when the user type the answers in the output window, by default it marks them as incorrect, but after that when I reset them, for the same answers it evaluate the answers correctly. Can you please help me out with this? I would highly appreciate your help. Thank you.

 

c1.visible = false;
f1.visible = false;
c2.visible = false;
f2.visible = false;
c3.visible = false;
f3.visible = false;
c4.visible = false;
f4.visible = false;
reset.visible = false;
check.addEventListener(MouseEvent.CLICK, chek);
reset.addEventListener(MouseEvent.CLICK, killreset);
function chek(evt: MouseEvent): void {


if (q1.text == "" && q2.text == "" && q3.text == "" && q4.text == "" ) {
c1.visible = false;
f1.visible = false;
c2.visible = false;
f2.visible = false;
c3.visible = false;
f3.visible = false;
c4.visible = false;
f4.visible = false;

} else {
if (q1.text == "linear" || q1.text == "LINEAR" || q1.text == "Linear") {
c1.visible = true;
} else {
f1.visible = true;
}
if (q2.text == "non-linear" || q2.text == "NON-LINEAR" || q2.text == "Non-linear") {
c2.visible = true;
} else {
f2.visible = true;
}
if (q3.text == "linear" || q3.text == "LINEAR" || q3.text == "Linear") {
c3.visible = true;
} else {
f3.visible = true;
}
if (q4.text == "non-linear" || q4.text == "NON-LINEAR" || q4.text == "Non-linear") {
c4.visible = true;
} else {
f4.visible = true;
}
}
check.visible = false;
reset.visible = true;
}

function killreset(evt: MouseEvent): void {
c1.visible = false;
f1.visible = false;
c2.visible = false;
f2.visible = false;
c3.visible = false;
f3.visible = false;
c4.visible = false;
f4.visible = false;
reset.visible = false;
check.visible = true;
q1.text = "";
q2.text = "";
q3.text = "";
q4.text = "";
}

 

If you want to see the output video I can also enclose that. 

TOPICS
ActionScript

Views

203

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

Hi.

 

I'm not sure what the problem is. Can you provide more details:

 

Anyway, you can use the toLowerCase method in the if statements instead of verifying several scenarios. Like this:

else
	{
		if (q1.text.toLowerCase() == "linear")
			c1.visible = true
		else
			f1.visible = true;
		
		if (q2.text.toLowerCase() == "non-linear")
			c2.visible = true
		else
			f2.visible = true;
		
		if (q3.text.toLowerCase() == "linear")
			c3.visible = true
		else
			f3.visible = true;
		
		if (q4.text.toLowerCase() == "non-linear")
			c4.visible = true
		else
			f4.visible = true;
	}

 

Please let us know.

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

LATEST

https://drive.google.com/file/d/1KzLmj0i9gL077nmh6XQTIwawb7-3MsMl/view?usp=sharing 

 

I hope you can access the fla file by the aforementioned link. In this quiz, my desired answers should be "linear, non-linear, linear, non-linear" respectively, but when I put these as my answers it is not showing me the correct output. Kindly help me with that portion. Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines