Problem solved, see below
Question
I'm working in Flex Builder 3 and I have two ActionScript 3 classes (ABC
and XYZ
) and a Flex MXML project (main.mxml
). I have an instance of XYZ
as a property of ABC
, and I want XYZ
's properties to be visible ([Bindable]
) in the Flex project in text controls.
Unfortunately, only prop3
and prop4
update when they are changed. I've entered the debugger to make sure that prop1
and prop2
change, but they are not being updated in the text controls.
Here's the code:
ABC.as
[Bindable]
public class ABC extends UIComponent {
/* Other properties */
public var xyz:XYZ = new XYZ();
/* Methods that update xyz */
}
XYZ.as
[Bindable]
public class XYZ extends Object {
private var _prop1:uint = 0;
private var _prop2:uint = 0;
private var _prop3:uint = 0;
private var _prop4:uint = 1;
public function get prop1():uint {
return _prop1;
}
public function set prop1(value:uint):void {
_prop1 = value;
}
/* getters and setters for prop2, prop3, and prop4 */
}
main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:com="com.*" />
<com:ABC id="abc" />
<mx:Text text="{abc.xyz.prop1}" />
<mx:Text text="{abc.xyz.prop2}" />
<mx:Text text="{abc.xyz.prop3}" />
<mx:Text text="{abc.xyz.prop4}" />
</mx:Application>
Answer
It's not apparent from the small code snippets that I posted, but from within XYZ
I was updating _prop3
and _prop4
using their setters. In constrast, I updated _prop1
and _prop2
through their private variables, not their setters. Thus, properties 1 and 2 were not dispatching update events.