4 Replies Latest reply on May 8, 2007 9:05 AM by BLXWebMaster

    View Stack and List

    MadamZuZu Level 1
      hi :)
      i want to display a viewstack, depending on the list item chosen.

      i played with it, but can't get it to work properly.
      please helllllp


      [code]
      <mx:Model id="MyQuestions" >
      <states>
      <state label="asdfsadfsfd?" data="test test2" id="test"/>
      <state label="fdghdgdasgf?" data="test asdfasdftest2" id="test2"/>
      </states>
      </mx:Model>


      <mx:List id="QAList" width="100%" color="#004080"
      dataProvider="{MyQuestions.state}"
      change="this.selectedItem=List(event.target).selectedItem" click="myViewStack.selectedChild=[this is where i want to pass in the ID from my XMLList]" />


      <mx:HBox >


      <mx:Button id="searchButton" label="Search Panel"
      click="myViewStack.selectedChild=search;"/>
      <mx:Button id="cInfoButton" label="Customer Info Panel"
      click="myViewStack.selectedChild=custInfo;"/>
      <mx:Button id="aInfoButton" label="Account Panel"
      click="myViewStack.selectedChild=accountInfo;"/>
      </mx:HBox>

      <mx:ViewStack id="myViewStack" borderStyle="solid" width="100%" height="80%">
      <mx:Canvas id="test" backgroundColor="#FFCCFF" label="Account sadfInfo" width="100%" height="100%">
      <mx:Label text="Account asdfasd Info" color="#000000"/>
      </mx:Canvas>
      </mx:ViewStack>

      ....
      [/code]


      or maybe you can suggest something else?
      i could display it in regular text boxes, but the issue i'm having is that i can't put HTML tags in the XMLList... and i need my text formatted.

      Thanks!
        • 1. Re: View Stack and List
          BLXWebMaster Level 1
          This should be what you want...

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          layout="absolute"
          width="100%"
          height="100%"
          xmlns:ns1="*">
          <mx:Script>
          <![CDATA[
          import mx.events.*;
          import mx.controls.*;

          //Click event handler for the main button.
          public function clickHandler():void {
          var selectedItem:String = QAList.selectedItem.data.toString();
          myViewStack.selectedChild=this[selectedItem];
          }

          ]]>
          </mx:Script>

          <mx:Model id="MyQuestions" >
          <states>
          <state label="Select search Canvas" data="search"/>
          <state label="Select custInfo Canvas" data="custInfo"/>
          <state label="Select accountInfo Canvas" data="accountInfo"/>
          </states>
          </mx:Model>

          <mx:List id="QAList" click="clickHandler();" width="100%" dataProvider="{MyQuestions.state}" height="107"/>

          <mx:HBox x="0" y="75">
          <mx:Button id="searchButton" label="Search Panel" click="myViewStack.selectedChild=search;"/>
          <mx:Button id="cInfoButton" label="Customer Info Panel" click="myViewStack.selectedChild=custInfo;"/>
          <mx:Button id="aInfoButton" label="Account Panel" click="myViewStack.selectedChild=accountInfo;"/>
          </mx:HBox>

          <mx:ViewStack id="myViewStack" borderStyle="solid" width="100%" height="312" y="105">
          <mx:Canvas id="test" label="Account sadfInfo" width="100%" height="325" cornerRadius="5" backgroundColor="#ffff00">
          <mx:Label text="Account asdfasd Info"/>
          </mx:Canvas>
          <mx:Canvas id="search" backgroundColor="#00ff00">
          <mx:Label x="2" y="2" text="search" fontWeight="bold"/>
          </mx:Canvas>
          <mx:Canvas id="custInfo" backgroundColor="#ff0080">
          <mx:Label x="2" y="2" text="custInfo" fontWeight="bold"/>
          </mx:Canvas>
          <mx:Canvas id="accountInfo" backgroundColor="#00ffff">
          <mx:Label x="2" y="2" text="accountInfo" fontWeight="bold"/>
          </mx:Canvas>
          </mx:ViewStack>
          </mx:Application>
          • 2. Re: View Stack and List
            MadamZuZu Level 1
            Thanks!!! :)
            • 3. Re: View Stack and List
              MadamZuZu Level 1
              but... what if have multiple lists, dipslyaing in each separate accordian window, how would i go about the "ClickHandler" function?
              what i mean is, how woul di tell it, which list to use?
              • 4. Re: View Stack and List
                BLXWebMaster Level 1
                Easiest solution is to simpley have different function names.
                click=ClickHandler1, click=ClickHanlder2, etc.

                Make Sense?