Okay from the looks of things. You want the even to change when you change the XML in the games variable? The collectionChange event is fired when you change something in the existing collection. Your changing the collection itself. This means that your listening to a change in a subsequently unbound collection. Adding a node to the existing collection will fire the event.
If your just trying to find if Xlist has been changed within your component I suggest the following. Games.mxml: <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:my="*"> <mx:Script> <![CDATA[ import mx.collections.*; import mx.events.*; private var _xlist:XMLList; [Bindable(event="xlistChanged")] public function get xlist():XMLList { return _xlist; } public function set xlist(x:XMLList):void { _xlist = x; dispatchEvent(new Event("xlistChanged")); } private function gameLabel(item:Object):String { return "game: " + it...@label; } ]]> </mx:Script> <mx:Label id="all" text="{'All games' + xlist.game.length}" /> <mx:Label id="full" text="{'Full games: ' + _xlist.game.(user.length() == 3).length()}"/> <mx:Label id="vacant" text="{'Vacant games: ' + _xlist.game.(user.length() < 3).length()}" /> <mx:List id="list" labelFunction="gameLabel" dataProvider="{xlist}"/> </mx:VBox> OR THE OTHER WAY <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:my="*" creationComplete="setupEventListeners()"> <mx:Script> <![CDATA[ import mx.collections.*; import mx.events.*; private var _xlist:XMLList; private function setupEventListeners() { this.addEventListener("xlistChanged", xlistChanged); } [Bindable(event="xlistChanged")] public function get xlist():XMLList { return _xlist; } public function set xlist(x:XMLList):void { _xlist = x; trace("set(" + x +")"); list.dataProvider = x; list.dataProvider. addEventListener(CollectionEvent.COLLECTION_CHANGE, xlistChanged); dispatchEvent(new Event("xlistChanged")); } private function gameLabel(item:Object):String { return "game: " + it...@label; } private function xlistChanged(event:Event):void { trace("xlistChanged(" + event +")"); all.text = "All games: " + _xlist.game.length(); full.text = "Full games: " + _xlist.game.(user.length() == 3).length(); vacant.text = "Vacant games: " + _xlist.game.(user.length() < 3).length(); } ]]> </mx:Script> <mx:Label id="all" text="All games"/> <mx:Label id="full" text="Full games"/> <mx:Label id="vacant" text="Vacant games"/> <mx:List id="list" labelFunction="gameLabel"/> </mx:VBox> On Sat, Aug 21, 2010 at 8:59 PM, Alexander Farber < [email protected]> wrote: > > > Hello Wesley and others, > > I have prepared a simple test case to demo my problem - > I'm trying to create a custom component which is being > fed with XML repeatedly coming from server. > My problem is that the CollectionEvent listener isn't fired. > > Games.mxml: > > > <?xml version="1.0" encoding="utf-8"?> > <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:my="*"> > > > <mx:Script> > <![CDATA[ > import mx.collections.*; > import mx.events.*; > > private var _xlist:XMLList; > > [Bindable] > public function get xlist():XMLList { > return _xlist; > > } > > public function set xlist(x:XMLList):void { > _xlist = x; > trace("set(" + x +")"); > list.dataProvider = x; > list.dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, > xlistChanged); > } > > private function gameLabel(item:Object):String { > return "game: " + it...@label; > > } > > private function xlistChanged(event:CollectionEvent):void { > trace("xlistChanged(" + event +")"); > all.text = "All games: " + _xlist.game.length(); > full.text = "Full games: " + _xlist.game.(user.length() == 3).length(); > vacant.text = "Vacant games: " + _xlist.game.(user.length() < 3).length(); > } > ]]> > </mx:Script> > > <mx:Label id="all" text="All games"/> > <mx:Label id="full" text="Full games"/> > <mx:Label id="vacant" text="Vacant games"/> > > <mx:List id="list" labelFunction="gameLabel"/> > > </mx:VBox> > > MyTest.mxml: > > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:my="*"> > <mx:Script> > <![CDATA[ > import mx.events.*; > > private function changeXML1():void { > games = <games> > <game label="1"> > <user/> > <user/> > <user/> > </game> > <game label="2"> > <user/> > <user/> > </game> > <game label="3"> > <user/> > <user/> > <user/> > </game> > </games>; > } > > private function changeXML2():void { > games = <games> > <game label="A"> > <user/> > <user/> > <user/> > </game> > <game label="B"> > <user/> > <user/> > </game> > <game label="C"> > </game> > </games>; > } > ]]> > </mx:Script> > > <mx:XML id="games"> > <games> > <game label="X"> > <user/> > <user/> > </game> > <game label="Y"> > <user/> > <user/> > </game> > </games> > </mx:XML> > > <mx:Button label="Change XML 1" click="changeXML1()"/> > <mx:Button label="Change XML 2" click="changeXML2()"/> > <my:Games xlist="{games.game}"/> > </mx:Application> > > What am I doing wrong? > > Regards > Alex > >

