[flexcoders] Filter Function on ArrayCollection with httpservices as there source

2007-04-02 Thread bnprrsh
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 




[flexcoders] Re: Filter Function on ArrayCollection with httpservices as there source

2007-04-02 Thread bnprrsh
Thanks so much it worked a treat!


--- In flexcoders@yahoogroups.com, iko_knyphausen [EMAIL PROTECTED] wrote:

 
 You could e4x as resultFormat and then bind this to an
 XMLListCollection, which in turn you can filter with a function. In 
e4x
 you would omit the root tag  (probably =stockreport in your case) 
and
 use stockFeed.lastResult.products.product as a source for
 databinding
 
 
 --- In flexcoders@yahoogroups.com, bnprrsh ben@ wrote:
 
  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
 





[flexcoders] HTTP Service doesnt seem to connect to location when running from a server

2007-02-06 Thread bnprrsh
I am currently trying to create a simple front end app which connects
to a 3rd party API made for some backup software. The API accepts HTTP
post data and generates its responses in XML.

I have built a simple app with a HTTP service which posts data to the
api and processes the responses.

The application runs fine from my local machine and I get a response
from the HTTPService (the status bar also gives the Transferring data
from... mesage. However when I upload the application to the live
server it doesn't seem to be connecting and I get no response or errors.

I have tested this on 3 servers all running IIS and windows 2003 these
servers are in 3 seperate datacentres.

Can anyone shed any light on this.

Thanks



[flexcoders] Re: HTTP Service doesnt seem to connect to location when running from a server

2007-02-06 Thread bnprrsh
Thanks cisnky,

It was down to the cross domain I created one on the API server and 
it now works. I was so sure it wasn't the cross domain as when Flex 
Builder compiled the swf the preview would connect without a problem 
plus im sure i used to get errors if flex couldnt find a croxdomain.

I would also like to thank you for informing me about Tamper Data. I 
dont know how I lived without it!



--- In flexcoders@yahoogroups.com, cisnky [EMAIL PROTECTED] wrote:

 I think the service needs a cross domain.
 
 You can use Tamper Data a Firefox plugin to see if you app makes a 
request
 for the cross domain when running it on your server.
 
 Let us know how you get on.
 
 On 2/6/07, bnprrsh [EMAIL PROTECTED] wrote:
 
I am currently trying to create a simple front end app which 
connects
  to a 3rd party API made for some backup software. The API accepts 
HTTP
  post data and generates its responses in XML.
 
  I have built a simple app with a HTTP service which posts data to 
the
  api and processes the responses.
 
  The application runs fine from my local machine and I get a 
response
  from the HTTPService (the status bar also gives the Transferring 
data
  from... mesage. However when I upload the application to the live
  server it doesn't seem to be connecting and I get no response or 
errors.
 
  I have tested this on 3 servers all running IIS and windows 2003 
these
  servers are in 3 seperate datacentres.
 
  Can anyone shed any light on this.
 
  Thanks