5 Replies Latest reply on Oct 4, 2011 7:59 AM by Jerry62712

    State of the State

    Jerry62712 Level 1

      In Flex 4 I'm trying to change the state.  In a button on the input form there is a script called that will change the state for the application.  When this happens, the input form disappears and the results form should appear.  This doesn't work.

       

      Input form has a button that calls a script that is included in that component.  I get this error:

      ArgumentError: Undefined state 'Results'.
          at mx.core::UIComponent/getState()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:10168]
          at mx.core::UIComponent/findCommonBaseState()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:10188]
          at mx.core::UIComponent/commitCurrentState()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:10010]
          at mx.core::UIComponent/setCurrentState()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:9961]
          at components::InputForm/swapToResultsState()[C:\FSCalc\Flex\FSCalc\src\scripts\FSUtil.as:71]
          at components::InputForm/doItToIt()[C:\FSCalc\Flex\FSCalc\src\components\InputForm.mxml:213]
          at components::InputForm/__calculateButton_click()[C:\FSCalc\Flex\FSCalc\src\components\InputForm.mxml:585]
      

       

      Line 585 is the button.

      Line 213 is the function called by the button.

      Line 71 is in the function included in the script included in the component.  This line sets the State.

       

      The main application (FSCalc.mxml) sets the states (Input, Results, Help) at line 112 which is not mentioned in the above error.

       

      Is there a limit that a component can only change the states within itself?

      Do I need to qualify the state so the application will globally know of it?

        • 1. Re: State of the State
          Amy Blankenship Level 4

          Does your InputForm actually have a Results state?  This error says Flex doesn't believe so.

          • 2. Re: State of the State
            Jerry62712 Level 1

            That's what my question was.  The application has it so the question is do all the children of the application have it as well - do they inherit the condition.

             

            Given it isn't working that way then the question becomes how do you tell the application to function using states.

            • 3. Re: State of the State
              Amy Blankenship Level 4

              Can you show some code?  I don't think States in Spark work the way you think, but I'm not 100% clear on what you think they do.

              • 4. Re: State of the State
                Jerry62712 Level 1

                What I expect States to do is to decide if something is presented on the stage or not.  In my case, on startup I want the state to include the input form so the container that holds that has a "includeIn" of the State "Input".  When the user clicks the "go" button, I expect the state to change such that the input form is no longer visible and in its place is the result form which is in a container that is associated with the State of "Results".

                 

                I think I might have fixed this one by refering the "currentState" assignment to the application level.  (I realize that is deprecated and once it is working I generally go back and eliminate all warnings that I can.)

                • 5. Re: State of the State
                  Jerry62712 Level 1

                  Hi Amy,

                   

                  I changed the "Application..." as I stated I would.  You mentioned code, so here it is (below).  The problem is when I switch from "Input" to "Result" states, the top of the page disappears.  That area doesn't have any state and should be available to all states if I understand that.  This happened when I changed the single BorderContainer which had the input and output forms to two BorderContainers.  I did that because the second state (Result) had a smaller content than the initial state (Input).  The container retained the size of the now invisible Input causing a gap below it and the rest of the content.

                   

                   

                  <!-- ************************************************************** -->
                  <!-- ** header area component ************************************* -->
                  <DHSComp:DHSHeader
                  id="headerComp"
                  width="100%"/>

                   

                  <!-- ************************************************************** -->
                  <!-- ** Title and universal buttons ******************************* -->
                  <s:BorderContainer
                  width="100%"
                  backgroundColor="#DEDACF"
                  height="25"
                  chromeColor="#DEDACF"
                  borderVisible="false">

                   

                  <!--
                  click="helpAccess();"
                  <s:Button
                  id="helpAccessButton"
                  label="{helpBtnText}"
                  toolTip=""
                  left="4"
                  top="4"
                  width="15%" height="22"
                  tabIndex="9" />
                  -->

                   

                  <s:TextArea
                  id="fsPageTitle"
                  text="{pageTopText.pageTitleText}"
                  styleName="pageTitle"
                  width="60%" height="25"
                  textAlign="center"
                  tabIndex="10"
                  contentBackgroundColor="#dedacf"
                  horizontalCenter="0"
                  fontSize="16"
                  top="0"
                  borderVisible="false"
                  verticalAlign="middle"/>

                   

                  <s:Button
                  id="languageSwitchButton"
                  label="{pageTopText.pageLangText}"
                  click="swapLanguage()"
                  right="4"
                  top="0"
                  width="15%" height="22"
                  tabIndex="11"
                  verticalCenter="0"/>
                  </s:BorderContainer>

                   

                  <!-- ************************************************************** -->
                  <!-- ** Input form ************************************************ -->
                  <s:BorderContainer
                  width="100%"
                  includeIn="Input"
                  backgroundColor="#DEDACF"
                  chromeColor="#DEDACF"
                  borderVisible="false">
                  <s:Group
                  horizontalCenter="0"
                  width="100%">
                  <DHSComp:InputForm
                  width="100%"
                  includeIn="Input" />
                  </s:Group>
                  </s:BorderContainer>

                   

                  <!-- ************************************************************** -->
                  <!-- ** Result form *********************************************** -->
                  <s:BorderContainer
                  width="100%"
                  includeIn="Results"
                  backgroundColor="#DEDACF"
                  chromeColor="#DEDACF"
                  borderVisible="false"
                  minHeight="300">
                  <s:Group
                  horizontalCenter="0"
                  width="100%">
                  <DHSComp:ResultForm
                  width="100%"
                  includeIn="Results"/>
                  </s:Group>
                  </s:BorderContainer>

                   

                  <!-- ************************************************************** -->
                  <!-- ** start of the notice area (bottom of page) ***************** -->
                  <s:BorderContainer
                  width="100%"
                  backgroundColor="#dedacf"
                  borderVisible="false">
                  <DHSComp:DHSNotice
                  id="noticeComp"
                  horizontalCenter="0"/>
                  </s:BorderContainer>

                   

                  (I don't know how to copy in to this forum and not have it as a table.  Help greatly appreciated.)

                   

                  The page has several components (header, input/results, notice shown here) and a couple of controls (title, button, potentially another button).  Not shown is the footer component.  Header, notice and footer will always appear.  Either Input or Result will appear.  They are different lengths.