warning: unable to bind to property ‘asset’ on class ‘Object’


When you use the dataprovider as Arrays or ArrayCollections which contains server data to populate controls like Datagrid, Tilelist..with itemrenderers and while debugging, you might be familiar with this screen below:

debug

Now why this is warning occurs ? because the Object Class  inside the Array and ArrayCollection doesn’t implements IEventDispatcher and it doesnot allow it to be treated as a bindable property. Since removing warning from the application that you develop is essential for the increasing performance of the application, the solution to this should be the following:

// consider myArrayCollection has the server data
var myArray:Array = new Array();
for(var i:Object in myArrayCollection)
{
myArray[i] = new ObjectProxy(myArrayCollection[i]);
}
targetArrayCollection = new ArrayCollection(myArray);

Here the objects are taken out and wrapped by the ObjectProxy which will enable the binding properties and you will be free from warnings. 🙂
Other solutions that can also be proposed to solve these warning. One of them would be make bindable variables inside the itemrenderer and pass the values of properties from data to the variables and then bind the variables to the controls. Warning free application certainly does give a performance boost even though performance depends on several other factors. 😉

Advertisements

Published by

Sunil Nair

I am a Software Developer currently working on developing Rich Internet Applications using Adobe Flex/AIR. I have had diverse experience of developing application in software industry for the last 4 years.

4 thoughts on “warning: unable to bind to property ‘asset’ on class ‘Object’”

  1. Thank you so much! I had seen other “solutions” to this problem, but none seemed to work for me, and your method is much simpler. Also your explanation of why it works really made sense to me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s