7 Replies Latest reply on Dec 8, 2008 11:15 AM by kglad

    HELP: XML or Data Grid failing from server

    GaryWalthrop
      Help,

      I am working a proof-of-concept flash function for a client that reads an XML file into a data grid. As coded, it works great when I run it locally, but when I transfer it to the web server it doesn't work (grid object shows but no data). And I guess I don't understand remote debugging because when I "Begin remote debugging session" and then "Open from site" it appears to download and again, runs fine.

      The the remote SWF is located at http://www.gw-webs.com/TSI/teamTSI.SWF. The XML and HTML are also located in the same remote folder.

      The code is all in Frame 1 of the file (not in a movie clip):

      _global.nameAR = new Array;
      _global.titleAR = new Array;
      _global.biographyAR = new Array;
      _global.contactAddressAR = new Array;
      _global.contactPhoneAR = new Array;
      _global.contactEmailAR = new Array;
      _global.pictureFileAR = new Array;
      _global.ARindex = 0;

      hd_name._visible = false;
      hd_title._visible = false;
      hd_biography._visible = false;
      hd_phone._visible = false;
      hd_email._visible = false;
      hd_mail._visible = false;


      function processXMLData(xml:XML)
      {
      var i :Number = 0;
      var num:Number = xml.firstChild.childNodes.length;

      for (var i = 0; i < num; i++) {
      _global.nameAR = xml.firstChild.childNodes.childNodes[0].childNodes[0].nodeValue;
      _global.titleAR = xml.firstChild.childNodes.childNodes[1].childNodes[0].nodeValue;
      _global.biographyAR = xml.firstChild.childNodes.childNodes[2].childNodes[0].nodeValue;
      _global.contactAddressAR = xml.firstChild.childNodes.childNodes[3].childNodes[0].nodeValue;
      _global.contactPhoneAR = xml.firstChild.childNodes.childNodes[4].childNodes[0].nodeValue;
      _global.contactEmailAR = xml.firstChild.childNodes.childNodes[5].childNodes[0].nodeValue;
      _global.pictureFileAR = xml.firstChild.childNodes.childNodes[6].childNodes[0].nodeValue;
      }
      var dataAR = new Array;

      for (i = 0; i < num; i++) {
      dataAR = ({Name: _global.nameAR, Title: _global.titleAR });
      }

      dg_team.dataProvider = dataAR;
      }

      var xmlData=new XML();
      System.useCodepage = true;
      xmlData.ignoreWhite=true;

      xmlData.onLoad = function(ok:Boolean) {
      if (ok) {
      processXMLData(this);
      } else {
      trace("XML did not load");
      }
      };

      // Create data grid click listener object
      var dgListener:Object = new Object();
      dgListener.cellPress = function(evt_obj:Object) {
      i = evt_obj.itemIndex;

      if (_global.nameAR
      <> null) {
      hd_name._visible = true;
      tx_name.text = _global.nameAR ;
      }
      else {
      hd_name._visible = false;
      tx_name.text = "";
      }

      if (_global.titleAR
      <> null) {
      hd_title._visible = true;
      tx_title.text = _global.titleAR ;
      }
      else {
      hd_title._visible = false;
      tx_title.text = "";
      }

      if (_global.biographyAR
      <> null) {
      hd_biography._visible = true;
      tx_biography.text = _global.biographyAR ;
      }
      else {
      hd_biography._visible = false;
      tx_biography.text = "";
      }

      if (_global.contactPhoneAR
      <> null) {
      hd_phone._visible = true;
      tx_phone.text = _global.contactPhoneAR ;
      }
      else {
      hd_phone._visible = false;
      tx_phone.text = "";
      }

      if (_global.contactEmailAR
      <> null) {
      hd_email._visible = true;
      tx_email.text = _global.contactEmailAR ;
      }
      else {
      hd_email._visible = false;
      tx_email.text = "";
      }

      if (_global.contactAddressAR
      <> null) {
      hd_mail._visible = true;
      tx_mail.text = _global.contactAddressAR ;
      }
      else {
      hd_mail._visible = false;
      tx_mail.text = "";
      }
      };

      xmlData.load("teamTSI_en.xml");

      // Add listener.
      dg_team.addEventListener("cellPress", dgListener);

      stop();