Sang Park
Sang Park

Reputation: 402

how do you check if two textflow objects are equal

Is there an easy way to compare two TextFlow objects with each other? I have two text flow objects that are created with TextConverter.importToFlow() and want to check if they are equal or not. Only way I found so far is to use TextConverter.export() to export them to a string then compare which seems bit convoluted...

Upvotes: 1

Views: 359

Answers (2)

Donatas Kucinskas
Donatas Kucinskas

Reputation: 21

If you need to compare text with styles, you can use:

var s1:String = TextConverter.export(textFlow1, TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.STRING_TYPE) as String;
var s2:String = TextConverter.export(textFlow2, TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.STRING_TYPE) as String;
s1 == s2;

Upvotes: 0

shaunhusain
shaunhusain

Reputation: 19748

Using getText() on the TextFlow objects returns a string representation of the contents, the string comparisons should give you the equality value between the two TextFlow objects assuming formatting or other elements within the TextFlow are not to be considered.

textFlow1.getText()==textFlow2.getText()

is the simplest solution I can see from the docs.

Upvotes: 4

Related Questions