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:[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=""/>
                                <mx:Object label="View2" data=""/>
                        </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=""/>
                                <mx:Object label="View2" data=""/>
                        </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

Reply via email to