2 Replies Latest reply on Aug 13, 2013 6:07 AM by pao1011

    How to change States in a Spark List Components?

    pao1011

      I have a list component, let's say with 10 list Items and I create 10 states for those list Items. So, I want to change to the corrresponding state when you click it on the list item.

      Thanks for any help.

        • 1. Re: How to change States in a Spark List Components?
          Craberoid

          Hello.

           

          You want to see something like that?

           

          <?xml version="1.0" encoding="utf-8"?>

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                                           xmlns:s="library://ns.adobe.com/flex/spark"

                                           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

                    <fx:Script>

                              <![CDATA[

                                        import spark.events.IndexChangeEvent;

           

                                        protected function list1_changeHandler(event:IndexChangeEvent):void

                                        {

                                                  currentState = event.currentTarget.selectedItem.stateName;

                                        }

           

                              ]]>

                    </fx:Script>

                    <s:states>

                              <s:State name="item1" />

                              <s:State name="item2" />

                              <s:State name="item3" />

                              <s:State name="item4" />

                              <s:State name="item5" />

                              <s:State name="item6" />

                              <s:State name="item7" />

                              <s:State name="item8" />

                              <s:State name="item9" />

                              <s:State name="item10" />

                    </s:states>

                    <fx:Declarations>

                              <!-- Place non-visual elements (e.g., services, value objects) here -->

                    </fx:Declarations>

                    <s:List change="list1_changeHandler(event)">

                              <s:dataProvider>

                                        <s:ArrayList>

                                                  <fx:Object label="Item 1" stateName="item1" />

                                                  <fx:Object label="Item 2" stateName="item2" />

                                                  <fx:Object label="Item 3" stateName="item3" />

                                                  <fx:Object label="Item 4" stateName="item4" />

                                                  <fx:Object label="Item 5" stateName="item5" />

                                                  <fx:Object label="Item 6" stateName="item6" />

                                                  <fx:Object label="Item 7" stateName="item7" />

                                                  <fx:Object label="Item 8" stateName="item8" />

                                                  <fx:Object label="Item 9" stateName="item9" />

                                                  <fx:Object label="Item 10" stateName="item10" />

                                        </s:ArrayList>

                              </s:dataProvider>

                    </s:List>

          </s:Application>

          • 2. Re: How to change States in a Spark List Components?
            pao1011 Level 1

            Yes that's exactly what I need thanks a million.