So a developer in my team recently created a variable in a managed object :

Code:

[Bindable(event="customChangeEvent")]
public var customVar:String;

In other function of this managed object, this event is dispatched (whole class is Event Dispatcher) as

Code:

dispatchEvent(new Event("customChangeEvent"));

We've discovered that if we use Publish / Subscribe, it suddenly stops working and the value change isn't propagated to Subscribers when the custom event is dispatched. When looking into logs, both publishes and subscriber are registered and the value is initialized and updated at the beginning but later, when the custom event is dispatched, nothing shows in log.

We've figured out that if we use bindable getter instead of variable, it will work.

Code:

[Bindable(event="customChangeEvent")]
public function get customVar():String {}

Nothing special in architecture, just two managed objects in subcontext, the same scope, one publishes, one subscribes. We use mxml declarations, so we have lines like :

I realize that using custom event with bindable and no getters/setters might be somewhat unusual, but I'm really curious why it's not working? I couldn't spot anything in the code that would help me with figuring this out. In MXML, this kind of binding works (value is updated when event is dispatched). I've seen some 3.1 TODO notes referencing to "black magic" :) - maybe that's the case?_________________Sebastian Zarzycki
Feerie Software

and there, it's clear that it only takes accessors and methods into consideration. Because I've used a variable (so, not accessor or method), it was simply omitted. Why it's exactly like this, no idea, but I'm really amazed that I've learned this after so many years.

As you can see, the author of that blog figured out the very same solution, by trial/error - just use a custom getter (accessor)._________________Sebastian Zarzycki
Feerie Software