I have a simple HTTPService that gets an XML document. The XML
document is structured like this:

<STOCK_EXCHANGE>
 .....
 <STOCK_HISTORY>
   <STOCK>
      <SYMBOL>GOOG</SYMBOL>
      <FULLNAME>Google Corporation</FULLNAME>
      <RATES>
         <RATE>123,12</RATE>
         <RATE>123,13</RATE>
         ....
      </RATES>
   </STOCK>
   <STOCK>
      ...
   </STOCK>
 </STOCK_HISTORY>
</STOCK_EXCHANGE>

I have a resulthandler on the HTTPService, that handles the
ResultEvent. It basically makes an ArrayCollection:
stockDetailCollection = event.result.STOCK_EXCHANGE.STOCK_HISTORY.STOCK;

So when done my ArrayCollection contains a collection of stocks. Now I
want to filter my collection to select just one specific stock, so I
added a filterFunction, which filters the stockDetailCollection to
show only the specific stock by using the SYMBOL:

private function stockDetailCollectionFilter(item:Object):Boolean {
        return item.SYMBOL == stockDetailSymbol;
}

In this function stockDetailSymbol is a bindable that gets set in a
pulldown or whatever. After applying the filter function, I call
stockDetailCollection.refresh() to filter.

The problem I have is that now I have 1 item in the ArrayCollection.
>From this item I want to use the RATES elements to create a new
collection that I can use as a datasource for a line-chart. If I try
something like: 

stockDetailCollection.filterFunction=stockDetailCollectionFilter;
stockDetailCollection.refresh();
stockData = ArrayCollection(stockDetailCollection.getItemAt(0).RATES);

It fails with the message:

TypeError: Error #1034: Type Coercion failed: cannot convert
mx.utils::[EMAIL PROTECTED] to mx.collections.ArrayCollection.

I hope it's clear what I'm trying to achieve. Can someone point me in
the right direction? This is my first Flex application, and I'm
struggling a bit ;-)

TIA,
Bastiaan

Reply via email to