Copy link to clipboard
Copied
I need to compare two word in two different text.
I use the "if" condition, for exemple:
if (MytextA == MytextB)
{
trace("==");
}
else
{
trace("!=");
}
But I suppose == and !== is a wrong method for text and my purpose.
Can you help me?
Thank you.
Copy link to clipboard
Copied
If MytextA and MytextB are the names of the two textfields, you need to test their text properties...
if (MytextA.text == MytextB.text)
Copy link to clipboard
Copied
Thank you Ned,
of course! I write it in my post a short form,
but also " if (MytextA.text == MytextB.text)" doesn't work.
Thank you again.
Copy link to clipboard
Copied
It should. Explain what you have done on the stage for what you call MytextA and MytextB
Copy link to clipboard
Copied
Thanks Ned!
On the stage I have two texts that I change dinamically with two button.
With this two buttons I assign different world to text on the stage.
At some points I need to compare two text but as I say before the result is always !== also when both texts contains the same words.
Copy link to clipboard
Copied
I don't know what you might have done that causes it to not work properly... maybe you have things on different frames or something. Here is a link to a quick example file I made for you to look at. Run it and click the button to have the texts change and get compared.
Copy link to clipboard
Copied
Make sure both fields are set to singleLine or MultiLine... if one is single line and the other multiLine you will get false when it should be true.
Copy link to clipboard
Copied
Thank you both Ned and Dmennenoh!
I need to mantain my original script cause it is a little complex.
In my test if both two text are set to MultiLine, if I compare the two text (and both text contain the same word)
with "=" it's ok if use "==" the result is wrong;
If I set Single Line "=" and "==" are both good.
Thank you both!
Copy link to clipboard
Copied
Using "=" is not doing what you need if that is what you ended up doing... "=" assigns the value of one to be equal to the other.