Not a stupid question at all!

If you have a list that has an id="myList", you can inspect the
selectedIndices array property.

Here is some code (courtesy of Flex 2 Help in Eclipse) to help illustrate:

----------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical">

      <mx:Script>

            private function showListSelection():void
            {
                  trace(); // breakpoint inserted here!
            }

      </mx:Script>

      <mx:Model id="mystates">
      <states>
        <state label="Alabama" data="AL"/>
        <state label="Alaska" data="AK"/>
        <state label="Arizona" data="AZ"/>
        <state label="Arkansas" data="AR"/>
        <state label="California" data="CA"/>
        <state label="Colorado" data="CO"/>
        <state label="Connecticut" data="CT"/>
      </states>
    </mx:Model>

       <mx:List id="source" width="100%" color="blue"
            dataProvider="{mystates.state}"
             allowMultipleSelection="true"/>

            <mx:Button label="show selection" click="showListSelection()"/>

</mx:Application>
----------------------------------------------------------------------------------------------

If you throw a break point in at the trace(), then you can drill down to
the selectedIndices property of that list.

I hope this helps.

 - mike




                                                                                
                                  
                                                                                
                                  
             "Lisa Lee"                        To: flexcoders@yahoogroups.com   
                                  
             <[EMAIL PROTECTED]>            cc:                                 
                               
             Sent by:                          Subject:  [flexcoders] Multiple 
Selections in a List               
             flexcoders@yahoogroups.com                                         
                                  
             01/05/2007 01:55 PM                                                
                                  
             Please respond to                                                  
                                  
             flexcoders                                                         
                                  
                                                                                
                                  




                                                                                
    
                                                                                
    
                                                                                
    
                                                                                
    
                                                                                
    
 I hate asking what I think is probably a very stupid question, but             
    
 being so new to Flex, I am still quite wet behind the ears....I have           
    
 an <mx:List> and I have set the "allowMultipleSelection" property to           
    
 true...my question is, how do I determine what selection(s) the user           
    
 has selected, if they're selected more than one?                               
    
                                                                                
    
 <mx:Script>                                                                    
    
 <![CDATA[                                                                      
    
 import mx.controls.List;                                                       
    
 [Bindable] private var serviceTypeTemp:ArrayCollection;                        
    
 private function serviceTypeHandler2(event:ResultEvent):void {                 
    
 serviceTypeTemp = event.result.serviceTypeData.serviceType;                    
    
 }                                                                              
    
 ]]>                                                                            
    
 </mx:Script>                                                                   
    
                                                                                
    
 <mx:HTTPService id="serviceTypeRPC"                                            
    
                                                                                
    
 url="http://development/dev1/workspaces/lisa/webservicedata/se                 
    
 rvicetypedata.xml"                                                             
    
 result="serviceTypeHandler2(event)"/>                                          
    
                                                                                
    
 <mx:List id="stComboList"                                                      
    
 dataProvider="{serviceTypeTemp}"                                               
    
 labelField="description"                                                       
    
 allowMultipleSelection="true"/>                                                
    
                                                                                
    
                                                                                
    
                                                                                
    
 


---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure.  If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---------------------------------------------------------------------------

Attachment: pic07958.gif
Description: GIF image

Reply via email to