1 Reply Latest reply on Jul 16, 2010 2:53 AM by dmyger

    E4X Changes in Flex 4.1?

    SpartanTom

      Hi folks,

       

      Seem to be having a strange problem since I updated Flash Builder to 4.0.1 and added the Flex 4.1 SDK with AIR 2.  The same code now loads different strings from XML files -- has something changed in E4X syntax?

       

      Using this XML file:

       

      <?xml version="1.0"?>

      <!--This table is used by the communicate window component-->

      <!--to label different values differently-->

       

      <commWindowLabels>

       

      <dataGroup id="0">

      <header>Fans and Heater:</header>

      <param id="0">

      <label>F1</label>

      <units>RPM</units>

      </param>

      <param id="1">

      <label>F2</label>

      <units>RPM</units>

      </param>

      <param id="2">

      <label>F3</label>

      <units>RPM</units>

      </param>

      <param id="3">

      <label>F4</label>

      <units>RPM</units>

      </param>

      <param id="4">

      <label>H1</label>

      <units></units>

      </param>

      </dataGroup>

       

      <dataGroup id="1">

      <header>Inputs and Outputs:</header>

      <param id="0">

      <label>A/C</label>

      <state id="0">

      <label>Failed</label>

      </state>

      <state id="1">

      <label>OK</label>

      </state>

      </param>

      <param id="1">

      <label>Door</label>

      <state id="0">

      <label>Open</label>

      </state>

      <state id="1">

      <label>Closed</label>

      </state>

      </param>

      <param id="2">

      <label>AC Mains</label>

      <state id="0">

      <label>Off</label>

      </state>

      <state id="1">

      <label>On</label>

      </state>

      </param>

      <param id="3">

      <label>Major</label>

      <state id="0">

      <label>ALARM!</label>

      </state>

      <state id="1">

      <label>OK</label>

      </state>

      </param>

      <param id="4">

      <label>Minor</label>

      <state id="0">

      <label>ALARM!</label>

      </state>

      <state id="1">

      <label>OK</label>

      </state>

      </param>

      </dataGroup>

       

      <dataGroup id="2">

      <header>Temperatures:</header>

      <param id="0">

      <label>Onboard</label>

      </param>

      <param id="1">

      <label>T1</label>

      </param>

      <param id="2">

      <label>T2</label>

      </param>

      <param id="3">

      <label>T3</label>

      </param>

      <param id="4">

      <label>T4</label>

      </param>

      </dataGroup>

       

      <dataGroup id="3">

      <param id="0">

      <label>SMU Heartbeat</label>

      </param>

      <param id="1">

      <label>Fan Fault</label>

      </param>

      <param id="2">

      <label>Sensor Fault</label>

      </param>

      <param id="3">

      <label>High Temp</label>

      </param>

      <param id="4">

      <label>Low Temp</label>

      </param>

      <param id="5">

      <label>Heater Fault</label>

      </param>

      </dataGroup>

       

      <dataGroup id="4">

      <header>Analog Readings:</header>

      <param id="0">

      <label>P1</label>

      <units>Pa</units>

      </param>

      <param id="1">

      <label>A1</label>

      <units>RPM</units>

      </param>

      <param id="2">

      <label>A2</label>

      <units>RPM</units>

      </param>

      <param id="3">

      <label>A3</label>

      <units>RPM</units>

      </param>

      <param id="4">

      <label>A4</label>

      <units>RPM</units>

      </param>

      <param id="5">

      <label>A5</label>

      <units>RPM</units>

      </param>

      </dataGroup>

       

      </commWindowLabels>

       

      And this code:

       

      return (_commWindow.labelStringsXML.dataGroup.(@id==1).param.(@id==2).label + _commWindow.labelStringsXML.dataGroup.(@id==1).param.(@id==2).state.(@id==1).label);

       

      Used to result in returning the string "AC Mains On".

       

      All of a sudden, it returns:

       

      <label>AC Mains</label>

      <label>On</label>

       

      What happened?  What are the attribute names being included?  Like I said, this code acted as expected, even as recently as in the Flex 4 SDK with Air 2 beta.  For now, I'll just go back to that.

       

        • 1. Re: E4X Changes in Flex 4.1?
          dmyger

          Hi,

          I'd like to extent previous message with my issue about this question:

           

          I do load next xml file with httpService object:

           

          <?xml version="1.0"?>
          <configs>

           

          <config host="XX.XX.XX.XX">
               <param>http://YY.YY.YY.YY</param>
          </config>

           

          <config host="localhost">
                 <param>http://www.ZZZZZ.com</param>
          </config>


          <config>
                 <param>http://www.YYYYY.com</param>
          </config>

           

          </configs>

           

          And in resultHandler(event:ResultEvent) do:

          var config:XMLList = event.result..config.(@host==g_Host);

           

          It works fine with Flash Builder 4.0, but after update to 4.0.1 it produce run time error:

          "ReferenceError: Error #1065: Variable @host is not defined."

           

          Could anybody explains what happens with searching in XML?

          Why it can't understand record with out searching attribute, now?

          So if I add to the last <config>  a 'host' attribute  (like <config host="bla-bla-bla">)

          it would work fine as it was in previous version.