3 Replies Latest reply on Jun 12, 2008 10:24 PM by kyalong

    PopUpButton can't not work after state switch

    kyalong
      hi,nice to meet you.

      I'm working with FLEX Bulider in my labs project.

      I used the state(s) to demonstrate two different user interfaces. In one of them ,there 's a PopUpButton compenont.and the other one has not the compenont.

      when I run the appliction.I switch between the two states.I find the popUpButton cant work .it canot be opened.

      Could some one let me know WHY and How to handle this question?

      some codes of my appliction like this:
      -------------------------------------------------------------------------

        • 1. Re: PopUpButton can't not work after state switch
          kyalong Level 1
          someone give me a hand please
          • 2. Re: PopUpButton can't not work after state switch
            Gregory Lafrance Level 6
            This works. I change the visible property instead of using removeChild, though I don't know why yours does not work.

            <?xml version="1.0" encoding="utf-8"?>
            <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml"
            layout="absolute">
            <mx:states>
            <mx:State name="state2">
            <mx:SetProperty target="{popupbutton1}" name="visible" value="false"/>
            </mx:State>
            </mx:states>
            <mx:Script>
            <![CDATA[
            [Bindable]
            public var treeXml:XML=
            <Child>
            <Child fatherCategoryId="0" categoryName="expenses" categoryId="38">
            <Child fatherCategoryId="38" categoryName="eat" categoryId="40"/>
            </Child>
            <Child fatherCategoryId="0" categoryName="income" categoryId="39">
            <Child fatherCategoryId="39" categoryName="salary" categoryId="41"/>
            </Child>
            </Child>
            ]]>
            </mx:Script>
            <mx:Button x="84" y="32" label="state1" click="currentState=''"/>
            <mx:Button x="166" y="32" label="state2" click="currentState='state2'"/>
            <mx:PopUpButton id="popupbutton1" height="24" width="150"
            textAlign="left" label="please select..." x="84" y="85">
            <mx:popUp>
            <mx:Tree id="cateTree" dataProvider="{treeXml}"
            labelField="@categoryName" showRoot="false"
            width="160" textAlign="left"/>
            </mx:popUp>
            </mx:PopUpButton>
            </mx:WindowedApplication>
            • 3. Re: PopUpButton can't not work after state switch
              kyalong Level 1
              thx Greg!

              It's a nice chioce .