Hi All! It seems that assigning new dataProvider with setting new selectedIndex that equals previous selectedIndex value result in such a problem. I resolved the issue with setting -1 to selectedIndex before updating dataProvider and then setting its actual value. Are there any more suitable solutions?
Thank you in advance! Sergey. On 9/19/06, Sergey Kovalyov <[EMAIL PROTECTED]> wrote: > Hi All! > > Unfortunately, setting new dataProvider and selectedIndex properties > to HorizontalList simultaneously does not always result in actually > selecting particular item. Sometimes the dataProvider changes, but > nothing is selected. You could find the simple code sample below. > What's wrong with it? > > Sergey. > > <?xml version="1.0"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > creationComplete="onCreationComplete()" > horizontalAlign="center" > verticalAlign="middle"> > > <mx:Script> > <![CDATA[ > import mx.collections.ArrayCollection; > import mx.controls.Alert; > > private var _dataProviders : ArrayCollection = new > ArrayCollection(); > > [Bindable] > private var _dataProvider : ArrayCollection = new > ArrayCollection(); > > [Bindable] > private var _selectedIndex : int; > > private function onCreationComplete() : void { > _dataProviders.addItem(new ArrayCollection([1, > 2, 3])); > _dataProviders.addItem(new ArrayCollection([4, > 5, 6])); > _dataProviders.addItem(new ArrayCollection([7, > 8, 9, 10])); > } > > private function onSelectButtonClick() : void { > _dataProvider = > _dataProviders[Math.floor(Math.random() * > _dataProviders.length)]; > _selectedIndex = Math.floor(Math.random() * > _dataProvider.length); > } > > ]]> > </mx:Script> > > <mx:HorizontalList id="horizontalList" dataProvider="{_dataProvider}" > selectedIndex="{_selectedIndex}"> > <mx:itemRenderer> > <mx:Component> > <mx:Box width="50" height="50"> > <mx:Label text="{data}" /> > </mx:Box> > </mx:Component> > </mx:itemRenderer> > </mx:HorizontalList> > > <mx:Button label="Select" click="onSelectButtonClick()" /> > > </mx:Application> > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

