0 Replies Latest reply on May 10, 2006 1:03 PM by mike_inf

    Flash player freeznig when loading in small XML files

    mike_inf
      Hi all,

      I could really use some help in finding a reasonable solution to this problem. I'm getting a problem where the flash player freezes giving the "A script is causing the flash player to run slowly" dialog box, when it's trying to load in XML files for content. Therre are 15 files and they are all between 1-3kb. I wrote a loop so that the next file doesn't begin loadnig until the previous file has finished. But on some machines I still randomly get this problem.

      I've tried using the download simulator in flash and it seems that this error always occurs on lower connection speeds, but we are on a fast connection here and I still randomly get it freezing I traced which files it freezes on and it's different ones every time.

      Any help would be greatly appriciated.

      Thanks.

      Here is the code for my xml functions:
      // LOAD XML CONTENT FILE
      function loadXMLFile(fileName, callBackFunction){
      var_xml = new XML();
      var_xml.load(fileName);
      var_xml.ignoreWhite = true;
      var_xml.onLoad = callBackFunction;
      }

      // FUNCTION: getNodes()
      function getNodes(success) {
      if (success == true) {
      loadParentNode(this);
      }
      else {
      trace("ERROR: XML not loaded");
      }
      }

      // CREATE VARIABLES FROM NODES
      function loadParentNode(myXMLobj) {
      var obj_xml = myXMLobj;
      //Determine number of parent nodes
      var noOfParentNodes = obj_xml.firstChild.childNodes.length;
      var content_xml = findXMLNode(obj_xml, "content");
      if (noOfParentNodes > 0) {
      for (x=0; x < noOfParentNodes; x++){
      var currentNode = content_xml.childNodes[x].nodeName;
      var currentValue = findXMLValue(content_xml, currentNode);
      this[content_xml.childNodes[x].nodeName] = currentValue;
      }
      gotoAndPlay("xmlOK");
      }
      else {
      trace ("1 ERROR: No Parent Nodes Found");
      }
      }

      // GET VALUE OF CHILD NODE
      function getChildNode(sectionName, desiredNodeName) {
      var obj_xml = this.var_xml; // create a pointer to the XML object
      var noOfParentNodes = obj_xml.firstChild.childNodes.length;
      if (noOfParentNodes > 0) {
      for (x=0; x < noOfParentNodes; x++){
      //Find parent Node (sectionName)
      if (obj_xml.firstChild.childNodes[x].nodeName == sectionName) {
      var nodeFound = 1;
      var XMLvars = obj_xml.firstChild.childNodes[x];
      var noOfChildNodes = XMLvars.childNodes.length;
      if (noOfChildNodes > 0) {
      for (var i = 0; i < noOfChildNodes; i++) {
      if (XMLvars.childNodes .nodeName == desiredNodeName) {
      return XMLvars.childNodes
      .firstChild.nodeValue;
      }
      }
      }
      }
      }
      } else {
      trace ("ERROR: No Parent Nodes Found");
      }
      if (nodeFound <> 1) {
      trace ("ERROR: Parent Node \"" + XMLnodeName + "\" Not Found.");
      }
      }

      //===FIND XML NODE=======================================================
      _global.findXMLNode = function(node_xml, XMLnodeName) {
      while (node_xml.nodeType == 1) {
      if (node_xml.nodeName == XMLnodeName) {
      return node_xml;
      } else if (node_xml.firstChild.nodeType == 1){
      checkChildNodes = findXMLNode(node_xml.firstChild, XMLnodeName);
      if (checkChildNodes != undefined) return checkChildNodes;
      }
      node_xml = node_xml.nextSibling;
      }
      }

      //===FIND XML VALUE=======================================================
      _global.findXMLValue = function(node_xml, XMLnodeName){
      while (node_xml.nodeType == 1) {
      if (node_xml.nodeName == XMLnodeName) {
      return node_xml.firstChild.nodeValue;
      } else if (node_xml.firstChild.nodeType == 1){
      return findXMLValue(node_xml.firstChild, XMLnodeName);
      }
      node_xml = node_xml.nextSibling;
      }
      }