3

I found another similar question, but don't quite follow the explanation there, and not sure if it applies the same to me.

I am getting the error:
warning: unable to bind to property 'Description' on class 'Object' (class is not an IEventDispatcher)

this is only when the data is bound to a List as an ArrayList, though. I had it in a Datagrid before (just as an Array) and it did not cause any issue. I'm not expecting to be able to bind any data back to the class 'object' not even sure which object exactly it's referring to.

My list data-provider is an ArrayList.. populated by a result event from an SQL query contained in another class:

   private function loadDayComplete():void
        {   
            var Meals:Array = _day.MealResults;
            var MealsListResult:ArrayList = new ArrayList(Meals);
            MealPanelDataGrid.dataProvider = Meals;
            MealListView.dataProvider = MealsListResult;
        {

The day class I have is a data holder to get all the data (from several tables) for a 24 hour span.. I have classes for each individual datatype for editing them. But I'm not sure do I even need to worry about the warning if I don't plan on editing the values? it completely spams the console though whenever I touch anything, so I really would like to get rid of it. I tried an object proxy as I saw described elsewhere but nothing changed. And I'm pretty confused why it's suddenly an issue on a list component when it wasn't on a datagrid... The text is in label fields right now anyway, which can't even be edited.

Damon
  • 10,493
  • 16
  • 86
  • 144

2 Answers2

6

The objects causing this warning are probably items inside Meals array. Make sure that these items are strongly typed (Data Transfer Objects / Value Objects patterns) and that Description field is marked [Bindable].

Depending on the remoting mechanism you are using you may be able to use something like makeObjectsBindable flag which replaces returned Object items with bindable ObjectProxy instances.

But I'll advise strong typing anyway.

Iwo Banas
  • 892
  • 8
  • 12
  • I added [Bindable] to all the variables in all the classes being instantiated (there were 2) and now it's working! excellent. – Damon Apr 09 '11 at 04:09
  • ObjectProxy is convenient for quickie solutions. But, I agree with Iwo Banas that you should prefer strongly typed objects with correct bindable properties - lots of good compiler support if you do. I'd further advocate for performance that you don't use the generic [Binding] tag, but instead use the [Binding("customChangeEvent")] pattern. This reduces performance-sucking binding event "storms" by allowing the compiler to narrowly focus the event listeners. You see this throughout Adobe's own code for this reason. – verveguy Jun 15 '11 at 15:12
0

You can get rid of it by making your dataProvider an EventDispatcher: ObjectProxy is an EventDispatcher. It will automatically wrap your data to a specified or infinite depth (default behavior).

metaPanelDataGrid.dataProvider = new ObjectProxy(meals);

It's basically the same thing as with ArrayCollection but deeper.

Kodiak
  • 5,978
  • 17
  • 35