Two things:
1) The reason your event is not firing is because you are adding the listener after you set _xlist
.
2) You should not be adding an event listener within your setter anyways. You should add it on the initialize or creationComplete events of your VBox component.
EDIT
Alright, after looking at your code again I can see the problem... so just a few more things.
3) Why are you naming a method init
, when it gets called on creationComplete
? You should get into the habit of naming methods appropriately. For example, the method that gets called on creationComplete
should be named: onCreationComplete
, or handleCreationComplete
That way, you will know what your code is doing 6 months down the road.
4) This is your main problem: You are using the getters / setters in appropriately. If you have a setter, you should also implement a getter (unless you have a write-only field). More importantly, you should use the getter to access your data. In your xListChanged
method you are not using the setter you have defined, thus nothing is getting told the _xlist
actually changed. As such, you should change your code to:
private var _xlist:XMLListCollection;
[Bindable]
public function get xlist():XMLListCollection { return this._xlist; }
public function set xlist(value:XMLListCollection):void
{
this._xlist = value;
}
Whenever you want to access _xlist
, use the GETTER. For example, change the dataProvider of your List
component to be {xlist}
. And the xListChanged
method should be using the getter: xlist
instead of directly accessing the member _xlist
.