I'm not exactly sure how the Flash Pro compiler treats this stuff (I always use the free mxmlc compiler from the Flex SDK).
Does this work for you?
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.getTimer;
import mx.binding.utils.BindingUtils;
public class BindingExample extends Sprite {
private var model:Model;
public function BindingExample()
{
model = new Model();
BindingUtils.bindProperty(this, 'spy', model, ['value']);
addEventListener( Event.ENTER_FRAME , onEnterFrame);
}
public function onEnterFrame(e:Event):void
{
model.value = getTimer();
}
public function set spy(value:int):void
{
trace('Bound property set to: ' + value);
}
}
}
class Model
{
[Bindable]
public var value:int;
}
If not, try this for the Model definition:
import flash.events.Event;
import flash.events.EventDispatcher;
class Model extends EventDispatcher
{
private var _value:int;
[Bindable("valueChange")]
public function get value():int
{
return _value;
}
public function set value(value:int):void
{
if (_value != value)
{
trace('Model property set to: ' + value);
_value = value;
dispatchEvent(new Event("valueChange"));
}
}
}
If that doesn't work, try this for the Model:
import flash.events.EventDispatcher;
import mx.events.PropertyChangeEvent;
import mx.events.PropertyChangeEventKind;
class Model extends EventDispatcher
{
private var _value:int;
[Bindable("propertyChange")]
public function get value():int
{
return _value;
}
public function set value(value:int):void
{
if (_value != value)
{
trace('Model property set to: ' + value);
var oldValue:int = _value;
_value = value;
dispatchEvent(new PropertyChangeEvent(
PropertyChangeEvent.PROPERTY_CHANGE, false, false,
PropertyChangeEventKind.UPDATE, "value", oldValue, value, this));
}
}
}
Or, perhaps with an ObjectProxy:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.getTimer;
import mx.binding.utils.BindingUtils;
import mx.utils.ObjectProxy;
public class BindingExample extends Sprite {
private var model:ObjectProxy;
public function BindingExample()
{
model = new ObjectProxy({value: 0});
BindingUtils.bindProperty(this, 'spy', model, ['value']);
addEventListener( Event.ENTER_FRAME , onEnterFrame);
}
public function onEnterFrame(e:Event):void
{
model.value = getTimer();
}
public function set spy(value:int):void
{
trace('Bound property set to: ' + value);
}
}
}
All of the above work fine when compiling with mxmlc. I'd avoid the ObjectProxy as it's the least typesafe.