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/
 



Reply via email to