Copy link to clipboard
Copied
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.!!!
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
...
Copy link to clipboard
Copied
You're in a function, are you really sure dienchu has a global scope when you check it with "me"?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks a lot
Copy link to clipboard
Copied
You're welcome!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now