The two resultFormats have their own issues,  you need to decide first
which you want to use.

 

I advise e4x.  You do not get the search and filter capability with the
default object tree.

 

If you go e4x, you will either need to use XMLListCollection , or
manually loop over the XMLList and build an ArrayCollection of Vos.  You
can't automatically convert an XMLList to ArrayCollection, hence that
error.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of jer_ela
Sent: Tuesday, March 25, 2008 8:58 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Accessing XML attribute through
ArrayCollection

 

its not clear where board comes from, but assuming it exists and is an
xml var that has an id attrib one of the following should work

trace(board.attribute("id")); 
trace([EMAIL PROTECTED]); 

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tony Armstrong" <[EMAIL PROTECTED]>
wrote:
>
> Hello all,
> I am using an ArrayCollection, outputted from an HTTPService. I wish
> to access the 'id' attribute from an XML file. I've tried using the
> e4x methods to no avail. I get an error:
> 
> "TypeError: Error #1010: A term is undefined and has no properties."
> 
> If I add the resultFormat="e4x" to the HTTPService, I get the error:
> 
> "Type Coercion failed: cannot convert [EMAIL PROTECTED] to
> mx.collections.ArrayCollection."
> 
> Any help would be appreciated...
> 
> Here's a code snippet below:
> 
> [Target XML]
> <ma> 
> <sitelist>
> <item id="11113">
> <name>weebls-stuff forums weebls-stuff forums</name>
> <url>http://forums.weebls-stuff.com/ <http://forums.weebls-stuff.com/>
</url>
> <pubdate>1-1-08</pubdate>
> <live>true</live>
> </item>
> </sitelist>
> </ma>
> 
> [AS3 snippets]
> ...
> 
> <mx:Script>
> function init()
> {
> siteDataIn.send();
> }
> 
> function siteHandler(event:ResultEvent):void
> {
> sites = event.result.ma.sitelist.item;
> }
> 
> function getSiteData(repeatData:MouseEvent):void
> {
> ...
> var site:Object = repeatData.target.getRepeaterItem();
> trace(board.attribute(id)); <-- this is where things blow up!!!
> }
> 
> </mx:Script>
> 
> <mx:HTTPService id="siteDataIn" url="..."
result="siteHandler(event)"/>
> 
> ...
>

 

Reply via email to