Hi,

I am trying to use the filter function on anrray collection with a 
http service lastResult source. 

I can't get passed this error "TypeError: Error #1034: Type Coercion 
failed: cannot convert mx.collections::[EMAIL PROTECTED] to 
Array." It seems to work fine when using my had coded object but I 
cant get it working with a httpservice no matter what resultFormat I 
choose.

My Code:
======================================================================

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical" creationComplete="stockFeed.send()">

<mx:Script>
<![CDATA[
import mx.utils.ArrayUtil;

// On startup 
public function initApp():void
{

// Set filter function
// Be careful to set filterFunction
// only after ArrayCollection has been
// populated. 
myData.filterFunction=processFilter;
}

// Filter function 
public function processFilter(item:Object):Boolean
{
var result:Boolean=false;

// If no filter text, or a match, then true 
if (!item.code.length
|| item.code.toUpperCase().indexOf(txtFilter.text.toUpperCase()) >= 0)
result=true;
return result;
}
]]>
</mx:Script>

<mx:HTTPService
id="stockFeed"
url="http://www.1on1wholesale.co.uk/members_area/status-xml.asp
showBusyCursor="true"
resultFormat="object"
result="initApp()"/>

<!-- Array Collection Using HTTPSERVICE Source -->
<mx:ArrayCollection id="myData" 
source="{stockFeed.lastResult.stockreport.products.product}"/>


<!-- Array Collection using Hard coded information -->
<!--
<mx:ArrayCollection id="myData">
<mx:source>
<mx:Object code="N0505" name="Monica Rose" status="In Stock" />
<mx:Object code="N0506" name="Randy Candice" status="In Stock" />
<mx:Object code="N0507" name="Jump Start Foot Pump" status="In 
Stock" />
<mx:Object code="N0508" name="Carla Doll" status="Out of Stock" />
</mx:source>
</mx:ArrayCollection>
-->


<!-- UI -->
<mx:HBox width="100%">
<mx:Label text="Filter:"/>
<mx:TextInput id="txtFilter" width="100%"
change="myData.refresh()"/>
</mx:HBox>

<!-- Tile List showing results from filtered array collection --> 
<mx:TileList dataProvider="{myData}" width="100%" height="300"
columnCount="2" rowCount="2">
<mx:itemRenderer>
<mx:Component>
<mx:VBox paddingLeft="30" width="150" height="150"
horizontalScrollPolicy="off" verticalScrollPolicy="off">

<mx:Label text="{data.code}" />
<mx:Label text="{data.name}"/>
<mx:Label text="{data.status}"/> 
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:TileList> 

<!-- Data Grid showing results from filtered array collection -->
<mx:DataGrid dataProvider="{myData}"
width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="code"
dataField="code"/>
<mx:DataGridColumn headerText="name"
dataField="name"/>
<mx:DataGridColumn headerText="status"
dataField="status"/>
</mx:columns>
</mx:DataGrid>

<!-- Datagrid showing results without filtering -->
<mx:DataGrid 
dataProvider="{stockFeed.lastResult.stockreport.products.product}" 
id="testing"/>
</mx:Application> 


Reply via email to