A: 

Why don't you just do this:

public function set xlist(x:XMLList):void {

   _xlist = new XMLListCollection(x);
   _all.label = 'All (' + _xlist.length + ')';

   var full:XMLList = _xlist.source.game.(user.length() == 3);
   _full.label = 'Full (' + full.length() + ')';

   var free:XMLList = _xlist.source.game.(user.length() < 3);
   _free.label = 'Free (' + free.length() + ')';

}

You don't need a listener if the only way to set the local _xlist variable is by setting the xlist property.

John Drummond
Hello John, if I set _full.label and _free.label in the setter method, then they will never get updated again
Alexander Farber
They will get updated every time you set the xlist property of the Games component. Which is the only way to change the private _xlist variable anyway.
John Drummond
+1  A: 

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.

clownbaby
I've moved _xlist.addEventListener(CollectionEvent.COLLECTION_CHANGE, xlistChanged); into init(event:FlexEvent) method which I call on creationComplete="init(event)" of the VBox, but this hasn't fixed my both problems. And does it make sense to call addEventListener this early, while _xlist hasn't been set by the setter method?
Alexander Farber
OK - I've edited my answer...
clownbaby
Thanks, but I can't use GETTER/SETTER as you suggest, because it is XMLListCollection and the custom component gets an XMLList as parameter: <my:Games xlist="{games.game}"/>I've updated my question with the test code, I'm trying to use list.dataProvider.addEventListener() there... but still no luck.
Alexander Farber
I apologize if my edited answer was not clear enough... but you still aren't listening to what I said - which is STOP using `_xlist` in your code, unless you are in a getter / setter.Update your `xlistChanged` method to use `xlist`.And please, for the love of god, don't add event listeners in a SETTER. You are re-adding an event listener every time you set _xlist. Is that really necessary?
clownbaby
Thanks I've tried your suggestions - it still doesn't work. Please try MyTest.mxml and the updated Games.mxml and you will see it yourself.
Alexander Farber
Okay, good news for you. I setup your test case this morning and got it working. If you simply add the `CollectionEvent.COLLECTION_CHANGE` event listener to your `List` component (not list.dataProvider), it will fire as expected. So, in `onCreationComplete()` do, `list.addEventListener(CollectionEvent.COLLECTION_CHANGE, xlistChanged);` Cheers.
clownbaby
Excellent and thank you for coming back to answer my question. Also I've realized, that I can't use a 1-liner like xlist.(user.length() == 3).length() because I have game's without user's too and thus have to check for the cases when user.length()==0. Otherwise I get the error "Variable user not defined"
Alexander Farber