Here a little example, the combobox does a binding on the XML that is
loaded by the model, and the
Viewstack does a binding on the combobox's selectedItem.data : 

file.mxml
<?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
    <mx:Model id="myOptions" source="test.xml" />
    <mx:ComboBox id="mP" dataProvider="{ myOptions.item }"/>
    <mx:ViewStack id="myView" selectedIndex="{mP.selectedItem.data}"
width="400" height="400">
      <mx:HBox backgroundColor="#FF9900" width="100%" height="100%"
hideEffect="Fade" showEffect="Fade">
        <mx:Label text="View 1" />
      </mx:HBox>
      <mx:HBox backgroundColor="#0099FF" width="100%" height="100%"
hideEffect="Fade" showEffect="Fade">
        <mx:Label text="View 2" />
      </mx:HBox>
    </mx:ViewStack>
</mx:Application>

test.xml
<doc>
<item label="View 1" data="0"/>
<item>
  <label>View 2</label>
  <data>1</data>
</item>
</doc>
--- In [email protected], "Abdul Qabiz" <[EMAIL PROTECTED]> wrote:
> It would still work, you have to write the logic to select the
index of
> ViewStack based on ComboBox selection. In this case, I assumed that
data
> property of ComboBox item contains the index. But it is just for
> example, in more practicle case it could be anything...
>  
> So bottom line is that, you can use DataBinding or change handler of
> ComboBox to do such things...
>  
> -abdul
> 
> ________________________________
> 
> From: [email protected] [mailto:flexcod
[EMAIL PROTECTED] On
> Behalf Of nithya karthik
> Sent: Friday, June 03, 2005 3:50 PM
> To: [email protected]
> Subject: RE: [flexcoders] ComboBOx
> 
> 
> hi,
>  thanks. it works. But what if i have the dataprovider as an
external
> xml file?
> 
> Abdul Qabiz <[EMAIL PROTECTED]> wrote:
> 
>       Hi Nithya,
>        
>       It depends how you are doing. You can use Data Binding or handle
> the change event of ComboBox. Look at the following example it shows
> both approach.
>        
>        
>       -abdul
>        
>       <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
>           <mx:Script>
>                   function changeView(event)
>                   {
>                       viewStack.selectedIndex =
> Number(event.target.selectedItem.data);
>                   }
>           </mx:Script>
>           
>           <mx:HBox>
>               <mx:VBox>
>               <mx:Label text="Change Handler"/>
>                   <mx:ComboBox change="changeView(event)">
>                           <mx:dataProvider>
>                               <mx:Array>
>                                       <mx:Object label="View1"
> data="0"/>
>                                       <mx:Object label="View2"
> data="1"/>
>                               </mx:Array>
>                           </mx:dataProvider>
>                   </mx:ComboBox>
>               </mx:VBox>
>               
>               <mx:VBox>
>               <mx:Label text="Change Handler"/>
>                   <mx:ComboBox id="cb2">
>                           <mx:dataProvider>
>                               <mx:Array>
>                                       <mx:Object label="View1"
> data="0"/>
>                                       <mx:Object label="View2"
> data="1"/>
>                               </mx:Array>
>                           </mx:dataProvider>
>                   </mx:ComboBox>
>               </mx:VBox>
>           </mx:HBox>
>           
>           <mx:HBox width="100%" height="100%">
>           <mx:Label text="ViewStack:" fontSize="16" />
>           
>        
>           <mx:ViewStack id="viewStack"
> selectedIndex="{Number(cb2.selectedItem.data)}" borderStyle="solid"
> width="100%" height="100%">
>               <mx:HBox label="View 1">
>                   <mx:Label text="View1"/>
>                   
>               </mx:HBox>
>               <mx:HBox label="View 2">
>                   <mx:Label text="View2"/>
>               </mx:HBox>
>           </mx:ViewStack>
>          </mx:HBox>
>       </mx:Application>
>        
> 
> ________________________________
> 
>       From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of nithya karthik
>       Sent: Friday, June 03, 2005 12:03 PM
>       To: flexcoders
>       Subject: [flexcoders] ComboBOx
>       
>       
>       hai,
>            I have  a combobox with 3 items. on selecting an item I
> want the viewstack beneath it to change from one view to another.
Pls
> help me with code for this. 
>       thanks,
>       nithya
> 
>       Send instant messages to your online friends
> http://uk.messenger.yahoo.com 
> 
> Send instant messages to your online friends
> http://uk.messenger.yahoo.com 
> 
> ________________________________
> 
> Yahoo! Groups Links
> 
> 
> *     To visit your group on the web, go to:
>       http://groups.yahoo.com/group/flexcoders/
>         
> *     To unsubscribe from this group, send an email to:
>       [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> 
>         
> *     Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> .




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> 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