Warning Unable to bind to Property "somevar" on object 'Object' class is not an IEventDispatcher

I saw this message in my console while developing a flex application with Cairngorm.

Problem
I'm using the more "generic" object class when returning results from the Cairngorm Service. The results contain data which is bound to a TileList component. In the TileList is a custom item renderer, I'm using to display an image.

Solution
Cast the data in your itemrenderer as an objectProxy.

 

photoRenderer.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
    verticalScrollPolicy="off"
    horizontalScrollPolicy="off"
    creationComplete="init();">

    <mx:Script>

         <![CDATA[
            import mx.utils.ObjectProxy;        

            [Bindable]
            public var dataProxy:ObjectProxy;

            private function init():void {
                dataProxy = new ObjectProxy(data);
            }
        ]]>
    </mx:Script>

    <mx:Image source="{dataProxy.image}" height="65" />

</mx:HBox>

Happy Coding....

 

4 responses to “Warning Unable to bind to Property "somevar" on object 'Object' class is not an IEventDispatcher”

  1. Taniguchi, J.T. Dec 24, 2009 at 5:14 PM
    Actually, there's 2 types of passing data through dataProvider that generate this kind of error. First one it's the image [ source ] and the other one it's the text type.
    If you're binding data to image, the solution it's already posted here :)
    If you wanna bind text (coming from XML for example), here is a sample:

    ...
    <Label text="{XML(data).@text}" />
    ...

    - Hope it helps you save some hours of headache :)
  2. Sid Maestre Dec 28, 2009 at 2:53 PM
    Thanks for the addition. As always there can be many variations of problems and solutions. Keep on Flexing...
  3. johans Feb 21, 2010 at 2:44 PM
    This solved the problem but created a different one. In Flex 4 if the container is resized and the items are reordered. For example say I have thumbnail images and I scroll or resize then images reappear lower down - the order is changed, not the total number of items. If I do not use a proxy then it works as expected - but of course I get the warning. I assume the "resize" event somehow needs to update the proxy. Any ideas?
  4. Sid Maestre Feb 21, 2010 at 4:44 PM
    Hi Johans,

    I'm sorry, i don't have an answer for Flex 4. I know the List component changed a lot in Flex 4, but I'm unsure how this would impact the use of ObjectProxy.

Leave a Reply

Leave this field empty:

Powered by Mango Blog.