That is not as bad as I thought it might be(I was expecting to see the
default resultFormat.  E4x is good!), but it is a bit odd.  You are
manually building an ArrayCollection of XML nodes.

 

I don't see any reason to do that.  Just use XMLListCollection, and
avoid the loop.

 

Now, "best practice", or at least this list's apparent consensus of best
practice, is to do what you are doing, but instead of adding xml nodes,
you populate a strongly data typed "Value Object" and add tht to the
ArrayCollection.  This is probably the most efficient and performant
approach.

 

But I mostly use XML and XMLListCollection.

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of - -
Sent: Wednesday, February 11, 2009 9:37 AM
To: [email protected]
Subject: Re: [flexcoders] ArrayCollection DataProvider question.

 

Hi Tracy, this is how I get the XML info into an ArrayCollection:

 

<mx:HTTPService url="days.php" useProxy="false" method="POST" id="Days"
resultFormat="e4x" result="get_days(event)">

 

private function get_days(event:ResultEvent):void

{

Arraydays.removeAll();

XMLdays = event.result as XML;

for each(var ourxml:XML in XMLdays.elements())
Arraydays.addItem(ourxml);

}

Is this ok?

 

Thanks

 

-David

 

________________________________

From: Tracy Spratt <[email protected]>
To: [email protected]
Sent: Tuesday, February 10, 2009 4:19:53 PM
Subject: RE: [flexcoders] ArrayCollection DataProvider question.

I suggest using e4x expressions against the XML, and then putting the
result in an XMLListCollection.

var xlResults:XMLList = xmlData.result. (attribute("id") == "1");

trace(xlResults. toXMLString( ));  //to verify your data

xlcResults = new XMLListCollection( xlResults) ;

 

You did not say how you got your XML into an ArrayCollection, but I
suspect it is not the good way.

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 

________________________________

From: flexcod...@yahoogro ups.com <http://ups.com/>  [mailto:flexcoders@
yahoogroups. com] On Behalf Of Henrique
Sent: Tuesday, February 10, 2009 2:19 PM
To: flexcod...@yahoogro ups.com
Subject: Re: [flexcoders] ArrayCollection DataProvider question.

 

Humm, you have to make a filterFunction, like this:

 

private function filterFucntion( item:Object) :Boolean

{

   return item.id <http://item.id/>  == "1";

}

 

Henrique F. Marino

blog.dclick. com.br <http://blog.dclick.com.br/> 

www.dclick.com. br <http://www.dclick.com.br/> 

On Tue, Feb 10, 2009 at 3:35 PM, sailorsea21 <sailorsea21@ yahoo.com
<mailto:[email protected]> > wrote:

I loaded the following xml as an ArrayCollection. 

<data>
<result id="1">
<date>today</date>
<yes>13154</yes>
<no>654321</no> 
</result>
<result id="1">
<date>yesterday</date>
<yes>21354</yes>
<no>5468432</no> 
</result>
<result id="2">
<date>today</date>
<yes>2665</yes>
<no>4256</no> 
</result>
<result id="2">
<date>yesterday</date>
<yes>7425</yes>
<no>7542</no> 
</result>
</data>

How can I use this as a dataprovider but only using the values in 
<result id="1"> and not <result id="2">?

My arraycollection var is "Arraydays".
I tried {Arraydays.( @id=='2')} but it gave me an error: Error #1123: 
Filter operator...

Thanks.

 

 



Reply via email to