As far as I understand, binding to a var in ActionScript is carried out via events which are automatically fired when a var is changed. I have a few questions about this:
- What happens if the class doesn't explicitly extend EventDispatcher? Is there is some sort of magic that goes on in the compiler which essentially makes the class an EventDispatcher?
- How does binding to static vars work? Is some sort of implicit static addEventListener() function added to the class?
- I've noticed that you can put [Bindable] on static vars but not static functions, why is this?
Edit:
Thanks to Christophe Herreman for his illuminating answer. However, I have a few follow-ons from my questions above. I wonder if anyone could fill in the gaps for me (I tried to number these questions 4, 5, 6 but they show up 1, 2, 3 for some reason!)
I've added the -keep option to the compiler and looked at the generated binding code. Could anyone explain how this code is applied? The compiler seems to generate a class called BindableProperty for each class, which contains the getter and setter. How does this get folded into the class I wrote? The feature looks kind of like partial classes in C# - is this exclusively behind-the-scenes compiler functionality, or is it something I could use myself?
The BindableProperty class still does not explicitly implement EventDispatcher, how does the generated class implement event dispatching?
In question 3, I asked about binding to static functions, but I actually meant static getter and setter functions. This doesn't seem to be allowed.