Home > Flex > Binding Warnings in PureMVC Arch101Demo

Binding Warnings in PureMVC Arch101Demo

January 12, 2008

I’ve been enjoying using PureMVC as of late. I recently started working on loading the Arch101Demo (Flex) example into an AS3 shell created in Flash. This required modifying the Flex example so it could be controlled by the loading Object. In the process of tracing results in the Flash IDE I started noticing some warning messages – the good old “unable to bind to propery ‘XYZ’ on Class ‘SomeClass’ (class is not an IEventDispatcher)”.

At least I knew that was a Flex issue and not a problem in my Flash-to-Flex loader. After a while, it’s bothering to look at those messages. It might bother other users who are just tracing out information to the console in Flex while learning PureMVC. So, here is a quick workaround to get you started on removing the messages.

In the file, UserForm.mxml add the line of code,

[Bindable] private var __deptEnums:Array = DeptEnum.comboList;

and change the binding in the “department” ComboBox,

<mx:FormItem label=”Department” required=”true”>
<mx:ComboBox id=”department” labelField=”value”
enabled=”{user != null}” />

In the file, RolePanel.mxml, make the similar modification

[Bindable] private var __comboList:Array = RoleEnum.comboList;

<mx:ComboBox id=”roleCombo” labelField=”value” dataProvider=”{__comboList}” change=”selectRoleToAdd()”/>

Instead of binding to the public variable user:UserVO, replace with

private var __user:UserVO;

public function get user():UserVO { return __user; }
public function set user(_user:UserVO):void
__user = _user;
this.status = _user.givenName;
roleCombo.enabled = _user != null;

In this case, all the dependencies on changing ‘user’ are localized in one setter function, but that’s another discussion for another time. At least this should get you started on an Arch101Demo application without warning messages.

If you want more information on the binding chain, check out http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/js/html/wwhelp.htm?href=databinding_091_06.html#164738

Here is a nice introduction to ObjectProxy by the Wheeler Street team and an interesting article by Ryan Taylor on binding in MXML vs. Actionscript . Another discussion on this issue can be found on the FlexCoders list.

Categories: Flex Tags:
  1. January 16, 2008 at 2:50 pm

    Thanks for that, nice tip 🙂

  1. No trackbacks yet.
Comments are closed.
%d bloggers like this: