4 Replies Latest reply on Oct 5, 2006 5:20 AM by Whitetimer

    Control Viewstacks using Combobox .. ?

    Whitetimer Level 1
      Hi All

      Ok i'm trying to build an app/website using viewstacks & components and so what i'd like to know is how i can navigate different viewstacks in a component using a combobox..? This is my code so far!

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="980"
      height="500"
      label="About Us"
      xmlns:views="views.*">

      <mx:Script>
      <![CDATA[

      import mx.core.Container;

      ]]>
      </mx:Script>


      <mx:HBox
      x="0" y="0"
      width="980"
      height="500"
      horizontalGap="0">


      <mx:VBox width="220" height="500" horizontalAlign="center">
      <mx:Image x="10" y="10" width="180" height="50" source="images/AboutUs.jpg"/>
      <mx:ComboBox width="200" height="20"
      id="cbxAboutUs"
      cornerRadius="0"
      dataProvider="{vsAboutId.selectedChild}"/>

      </mx:VBox>

      <mx:VBox width="760" height="500"
      paddingBottom="5" paddingLeft="5"
      paddingRight="5" paddingTop="5"
      borderStyle="solid" borderColor="#000099">

      <mx:ViewStack id="vsAboutId"
      width="100%" height="100%"
      creationPolicy="all">

      <views:vAboutIntro id="aboutIntro" />
      <views:vAboutUs id="aboutUs" />


      </mx:ViewStack>



      </mx:VBox>


      </mx:HBox>

      </mx:Canvas>

      Many thanks

      Jools
        • 1. Re: Control Viewstacks using Combobox .. ?
          gladders
          Just bind the selectedIndex of one to the other - no code involved!


          <mx:ComboBox id="comboBox" dataProvider="{cards}" selectedIndex="{viewStack.selectedIndex}" />

          <mx:ViewStack selectedIndex="{comboBox.selectedIndex}" id="viewStack">
          ...


          Cheers,

          simon
          • 2. Re: Control Viewstacks using Combobox .. ?
            Whitetimer Level 1
            Hi Simon ... just tried that and still not working ...

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml"
            width="980"
            height="500"
            label="About Us"
            xmlns:views="views.*">


            <mx:HBox
            x="0" y="0"
            width="980"
            height="500"
            horizontalGap="0">


            <mx:VBox width="220" height="500" horizontalAlign="center">
            <mx:Image x="10" y="10" width="180" height="50" source="images/AboutUs.jpg"/>
            <mx:ComboBox width="200" height="20"
            id="cbxAboutUs"
            cornerRadius="0"
            dataProvider="{vsAboutId}" selectedIndex="{vsAboutId.selectedIndex}"/>

            </mx:VBox>

            <mx:VBox width="760" height="500"
            paddingBottom="5" paddingLeft="5"
            paddingRight="5" paddingTop="5"
            borderStyle="solid" borderColor="#000099">

            <mx:ViewStack id="vsAboutId"
            width="100%" height="100%"
            creationPolicy="all" selectedIndex="{cbxAboutUs.selectedIndex}">

            <views:vAboutIntro id="aboutIntro" />
            <views:vAboutUs id="aboutUs" />


            </mx:ViewStack>



            </mx:VBox>


            </mx:HBox>

            </mx:Canvas>

            Jools
            • 3. Re: Control Viewstacks using Combobox .. ?
              gladders Level 1
              Hi Jools,

              I'm not sure about using the view stack as a dataprovider - try moving the data into a seperate ActionScript object and see if that helps.

              simon
              • 4. Re: Control Viewstacks using Combobox .. ?
                Whitetimer Level 1
                Hi .. Well thats my stumbling point, i dont know actionscript, well i'm trying to learn, but struggling ... lol

                But many thanks for your advice.

                Jools