Highlighted

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

Community Beginner ,
Nov 08, 2019

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

 

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
ActionScript, Code, Error, Performance

Views

162

Likes

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

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

Community Beginner ,
Nov 08, 2019

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

 

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
ActionScript, Code, Error, Performance

Views

163

Likes

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

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"?

Likes

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
Reply
Loading...
Nov 08, 2019 1
Adobe Community Professional ,
Nov 08, 2019

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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Nov 08, 2019 1
Community Beginner ,
Nov 13, 2019

Copy link to clipboard

Copied

Thanks a lot

Likes

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
Reply
Loading...
Nov 13, 2019 1
Adobe Community Professional ,
Nov 13, 2019

Copy link to clipboard

Copied

You're welcome!

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Nov 13, 2019 0