A ComboBox takes a dataProvider that is an array of objects. You cannot
hook up a ComboBox to a visual component the way you have done below.
That is for components like TabBars and LinkBars, which can take a
ViewStack object as its dataProvider.

What you would want to do is something like:

<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>

<mx:Script>
var mainViewStackDP = [{label:"View 1", index:0}, {label:"View 2",
index:1}, ...];
</mx:Script>

<mx:ComboBox dataProvider="{mainViewStackDP}" labelField="label"
change="mainViewStack.selectedIndex=event.target.selectedItem. index;"/>

-deepa

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of face7hill
Sent: Monday, October 10, 2005 11:19 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Binding a ComboBox to a ViewStack

Hi Everyone,

Anybody have any luck binding a ViewStack as a dataProvider for a 
ComboBox?  Is this even possible?  I tried a couple of things but 
all I get is an empty ComboBox.  Ideally, I'd like the ComboBox to 
use the "label" attribute from the ViewStack and use the ViewStack 
component id as the "data" field for the ComboBox.

This seems like it would be pretty straight-forward but I have not 
been able to find anything in the docs/archives.

Any guidance would be greatly appreciated!


<!-- ViewStackComboBox.mxml -->
<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
            
        <mx:ComboBox id="mainComboBox" 
dataProvider="mainViewStack.selectedChild" />

        <mx:ViewStack id="mainViewStack" width="100%" height="100%">
                <mx:HBox id="view1" label="View 1">
                        <mx:Label text="This is view 1"/>
                </mx:HBox>
                <mx:HBox id="view2" label="View 2">
                        <mx:Label text="This is view 2"/>
                </mx:HBox>
        </mx:ViewStack>
    
</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



 






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

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

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