4 Replies Latest reply on Mar 1, 2011 9:23 AM by Jerry62712

    How do I get State to work?

    Jerry62712 Level 1

      I've used states in Flex 3 and have a reason to use it in a Flex 4 application.

       

      I want to display a PrintDataGrid when the user clicks something.  The addition of states has caused the page to fail to compile.  I tried putting it right after the top:

      <?xml version="1.0" encoding="utf-8"?>
      <options:OptionContent
          xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:options="gov.il.dhs.wvs.view.options.*"
          xmlns:cust="cust.*"
          creationComplete="_init();"
          show="showHandler(event)">

       

          <s:states>
              <s:State name="normal" />
              <s:State name="print" />
          </s:states>

      and I tried to put it right after the initial panel (first displayed object on the page):

          <s:Panel id="casenotes"
                  title="Manage Case Notes"
                  width="100%" height="100%"
                  styleName="mainPanel">

              <s:states>
                  <s:State name="normal" />
                  <s:State name="print" />
              </s:states>

      and I tried putting it here:

          <fx:Declarations>
              <s:states>
                  <s:State name="normal" />
                  <s:State name="print" />
              </s:states>      

       

      None of these will compile.  Where does it need to go?

        • 1. Re: How do I get State to work?
          _spoboyle Level 4

          your first attempt was right, what error did you get?

          • 2. Re: How do I get State to work?
            Jerry62712 Level 1

            Error message:

            Could not resolve <s:states> to a component implementation.

             

            In the case the problem was something not imported (the "not resolve" part), here are the inports and namespaces:

            <options:OptionContent

             

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

             

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

             

                xmlns:mx="library://ns.adobe.com/flex/mx"

             

                xmlns:options="gov.il.dhs.wvs.view.options.*"

             

                xmlns:cust="cust.*"

             

                creationComplete="_init();"

             

                show="showHandler(event)">

             

            <!--    <s:states>


                    <s:State name="normal" />
                    <s:State name="print" />
                </s:states>
            -->
                <fx:Script>
                    <![CDATA[

             

                        import gov.il.dhs.utils.Utils;
                        import gov.il.dhs.wvs.code.Const;
                        import gov.il.dhs.wvs.code.ErrorMsgs;
                        import gov.il.dhs.wvs.events.SaveCaseNotesEvent;
                        import gov.il.dhs.wvs.events.SearchEvent;
                        import gov.il.dhs.wvs.vo.CaseNotesVO;
                        import gov.il.dhs.wvs.vo.CaseloadVO;
                       
                        import mx.binding.utils.BindingUtils;
                        import mx.collections.XMLListCollection;
                        import mx.controls.Alert;
                        import mx.events.CloseEvent;
                        import mx.events.ListEvent;
                        import mx.events.ValidationResultEvent;
                        import mx.printing.FlexPrintJob;
                        import mx.printing.PrintAdvancedDataGrid;
                        import mx.utils.ObjectUtil;
                        import mx.validators.Validator;

             

            Oddly enough, if you right click on the "option" at the file header, you go to here:

            <?xml version="1.0" encoding="utf-8"?>
            <s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009"
                                xmlns:s="library://ns.adobe.com/flex/spark"
                                xmlns:mx="library://ns.adobe.com/flex/mx"
                                width="100%"
                                height="100%"
                                enabled="{!isNaN(model.selectedCustomer.individualId)}">
            <s:states>
                <s:State name="x"/>
                <s:State name="y"/>
            </s:states>
            Where the "states" doesn't cause an error.  You can't use "x" or "y" in the original component, however.  I'm not sophicasticated enough to see how they tie together, unfortunately.

            • 3. Re: How do I get State to work?
              kevinklin Adobe Employee

              "states" is a property of the component. So, it must be in the same namespace as the component. Try:

               

              <?xml version="1.0" encoding="utf-8"?>
              <options:OptionContent
                  xmlns:fx="http://ns.adobe.com/mxml/2009"
                  xmlns:s="library://ns.adobe.com/flex/spark"
                  xmlns:mx="library://ns.adobe.com/flex/mx"
                  xmlns:options="gov.il.dhs.wvs.view.options.*"
                  xmlns:cust="cust.*"
                  creationComplete="_init();"
                  show="showHandler(event)">

               

                  <options:states>
                      <s:State name="normal" />
                      <s:State name="print" />
                  </options:states>

              • 4. Re: How do I get State to work?
                Jerry62712 Level 1

                Sorry for the late reply.  Your suggestion worked!  I still can't get it to print right, but it's a step forward.