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

Animate CC !Please help the ActionScripts that i made have problem!!!

Community Beginner ,
Nov 08, 2019 Nov 08, 2019

Please help the ActionScripts that i made have problem!!!

I have this ActionScripts : 

 

import flash.events.MouseEvent;
stop();
kiemtraBtn.addEventListener(MouseEvent.CLICK,checkClick);
function checkClick(event:MouseEvent):void
{
if(dienchu.text == "me")
{
dunghaysai.text = "Đúng rồi";
}
else
{
dunghaysai.text = "Sai rồi";
}
}

 

I don't know why if i write "me" to dienchu.text => it's alway wrong

And it continous with the other word. 

 

dienchu is input text

dunghaysai is dynamic text. 

kiemtraBtn is a button.

Please help me.!!!

 

TOPICS
ActionScript , Code , Error , Performance
405
Translate
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

correct answers 1 Correct answer

Community Expert , Nov 08, 2019 Nov 08, 2019

Hi.

 

I ran a test here using Animate 2020 and your code worked.

 

Make sure your dienchu Text Field instance doesn't have an extra space or something like this.

 

And if this is the case a safe way would be to use the indexOf method from the String class. Like this:

import flash.events.MouseEvent;

function checkClick(event:MouseEvent): void
{
	if (dienchu.text.indexOf("me") > -1)
		dunghaysai.text = "Đúng rồi";
	else
		dunghaysai.text = "Sai rồi";
}

stop();
kiemtraBtn.addEventListener(MouseEv
...
Translate
Contributor ,
Nov 08, 2019 Nov 08, 2019

You're in a function, are you really sure dienchu has a global scope when you check it with "me"?

Translate
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 ,
Nov 08, 2019 Nov 08, 2019

Hi.

 

I ran a test here using Animate 2020 and your code worked.

 

Make sure your dienchu Text Field instance doesn't have an extra space or something like this.

 

And if this is the case a safe way would be to use the indexOf method from the String class. Like this:

import flash.events.MouseEvent;

function checkClick(event:MouseEvent): void
{
	if (dienchu.text.indexOf("me") > -1)
		dunghaysai.text = "Đúng rồi";
	else
		dunghaysai.text = "Sai rồi";
}

stop();
kiemtraBtn.addEventListener(MouseEvent.CLICK, checkClick);

 

 

Regards,

JC

Translate
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 Beginner ,
Nov 13, 2019 Nov 13, 2019

Thanks a lot

Translate
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 ,
Nov 13, 2019 Nov 13, 2019
LATEST

You're welcome!

Translate
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