I found out what was happening to cause the "unable to bind" warning in the
scenario that I described (see below). I eventually stumbled onto this
solution after trying many different searches in Google:

--------------------------------------

This is a solution for the common warning: "unable to bind to property 'XXX'
on class 'Object' (class is not an IEventDispatcher)"

This problem occurs frequently when transferring complex objects using AMF
when the object returned from the server contains an array or array
collection of more objects.
 
One symptom of this problem is that it occurs after converting the data
request from an HTTPService call to a Remote Object call.

It turns out that Flex does not handle data returned from the AMF data
service in quite the same way as HTTPService and WebService results. With
these two later services Flex will automatically wrap Arrays in
ArrayCollection and Objects in ObjectProxy wrappers so binding will work. 

The solution is to do this same thing manually, with code similar to the
following:

function resultHandler(result:Array) {
   for(var i:String in result) result[i] = new ObjectProxy(result[i]);
   targetArrayCollection = new ArrayCollection(result);
}

Note: It may be the case that the result object is already an
ArrayCollection yet the Objects in ObjectProxy wrappers. In this case you
only need to include the for loop to implement ObjectProxy for all objects
in the ArrayCollection.

--------------------------------------

I also discovered that if you add an object (i.e., one that you create
yourself) to the ArrayCollection, then you'll also need to create an
ObjectProxy for the new object or you'll get the same "unable to bind"
warnings.

Hope this helps save someone else the hours I spent trying to find a
solution :-)

Paul

---
Paul Whitelock
Denver, Colorado


======================================
                
Re: "Unable to bind" Warning 


Posted by: "Samuel Reuben"
Fri Dec 8, 2006 4:00 am (PST) 

from the looks of the code it seems that you'll have to change the name of
your ArrayCollection. Try myDataProvider

hope it works,
-sam

On 12/8/06, Paul Whitelock <[EMAIL PROTECTED] wrote:
>
> I hoping someone might know why I am getting an "unable to bind" warning
> with the following scenario. Below is a portion of my code that uses a
> DataGrid bound to an ArrayCollection data provider ("text" is one of the
> fields in the collection).
>
> --------------------------------------
>
> [Bindable]
> public var dataProvider:ArrayCollection;
>
> <mx:DataGrid id="dg" dataProvider="{dataProvider}" >
> <mx:columns>
> <mx:DataGridColumn headerText="Items" itemRenderer="renderer.RichText"
> dataField="text" editable="false" />
> </mx:columns>
> </mx:DataGrid>
>
> --------------------------------------
>
> The following is a very simple component (renderer.RichText) that simply
> converts the "text" data to rich text.
>
> --------------------------------------
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> ">
> <mx:Text id="richText" htmlText="{data.text}" width="100%" height="100%"
> selectable="false" />
> </mx:Canvas>
>
> --------------------------------------
>
> When the application is run, I get the following error:
>
> "warning: unable to bind to property 'text' on class 'Object' (class is
> not
> an IEventDispatcher)"
>
> Note that the data from "data.text" is correctly displayed in the
> DataGrid.
>
> Any idea why I am getting the "unable to bind" warning and how I might get
> rid of it? Thanks!
>
> Paul
>
> ---
> Paul Whitelock
> Denver, Colorado



Reply via email to