Skip to main content
Participant
November 8, 2019
Answered

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

  • November 8, 2019
  • 4 replies
  • 432 views

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.!!!

 

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer JoãoCésar17023019

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

4 replies

JoãoCésar17023019
Community Expert
Community Expert
November 14, 2019

You're welcome!

pesaoAuthor
Participant
November 13, 2019

Thanks a lot

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
November 8, 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

Inspiring
November 8, 2019

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