Pori
Pori

Reputation: 696

How to retrieve the index of an XML element with a specific attribute in AS3?

Does anyone know if there is a way to retrieve the index of an XML child element with a specific a attribute in ActionScript?

Say...

foo.child.@attribute //index of

I tried using the method like this:

[email protected]()

but it returns -1.

Upvotes: 0

Views: 2397

Answers (1)

Art
Art

Reputation: 831

Using hasOwnProperty method works for me:

foo.child.(hasOwnProperty("@attribute")).childIndex()

But if element with @attribute is not unique, then the right code is:

foo.child.(hasOwnProperty("@attribute"))[0].childIndex()

Upvotes: 1

Related Questions