Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top