flex tree check property of selected itm

I have a function which handles the click of an item in tree, I want to check if the item that has been selected contains a specific property

the obj variable has all the xml from the selected item and down but the property check does not seem to work, how exactly do I fix this?
private function clickedItem(event:ListEvent):void
		var parentArray:Array = new Array();
		var obj:Object = id_myTree.selectedItem;
		if(!(obj.(hasOwnProperty("@myProperty") && @myProperty== "true")))


Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Well, your code is kind of weird.  

obj.(hasOwnProperty("@myProperty") is wrong

first, it should be written obj.(hasOwnProperty("@myProperty")), with two closing parenthesis.  But even so, that statement will evaluate to something like obj.true or obj.false.  Which isn't really what you're looking for.

Because it's an object, you can just put the property name there, like obj.myProperty.

I would suggest you set a break point just after that line of code, run your debugger, and then check the debug variables window to see that object obj, and be able to get the exact property reference you're looking for.  I don't think @myProperty is going to give it to you.
Hi NewtonianB,

if u already have  xml and want check attribute exist or not,please check follwing url,



I think its just a small mistake that you directly trying @myProperty == "true" instead of item.@myProperty == "true".

var item:Object = Tree(evt.currentTarget).selectedItem;
                if( item.name().toString() == "item" ){
                	if( item.hasOwnProperty("@myProperty") && item.@myProperty == "true"){
                		trace( "myProperty" ); 

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NewtonianBAuthor Commented:
fantastic vindy thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.