How to check if two elements have the same text formats?

81 Views Asked by At

How do I check if two paragraph elements or two spans have the same formats?

I have two paragraphs and when I export them they have the exact same attributes:

<p fontWeight="bold"><span>Hello world</span></p>
<p fontWeight="bold"><span>Hello world</span></p>

I can find a way to get the string with regex and do a string compare but I'm sure there was a method like this which seems more robust:

paragraph1.formatsMatch(paragraph2);
1

There are 1 best solutions below

1
1.21 gigawatts On

I think this is the answer:

var same:Boolean = myParagraph.equalUserStyles(myOtherParagraph);

It is always showing true so I have to run some more tests. But I think it only checks users styles and not textlayout format or computed format.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flashx/textLayout/elements/FlowElement.html