home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 136 / MOBICLIC136.ISO / pc / DATA / HOTE / prod_gen_JLM / moteur.swf / scripts / __Packages / prod / moteur / V001_ChargementXML.as next >
Text File  |  2011-07-20  |  4KB  |  128 lines

  1. class prod.moteur.V001_ChargementXML
  2. {
  3.    function V001_ChargementXML(movieRoot, moduleXmlRoot, moduleOnline)
  4.    {
  5.       trace("(!) ChargementXML : \r movieRoot : " + movieRoot + "\r moduleXmlRoot: " + moduleXmlRoot + "\r moduleOnline: " + moduleOnline);
  6.       this.movieRoot = movieRoot;
  7.       this.XmlStocker = new XML();
  8.       this.XmlStocker.ignoreWhite = true;
  9.       this.XmlStocker.load(moduleXmlRoot);
  10.       this.XmlStocker.onLoad = mx.utils.Delegate.create(this,this.onXmlLoaded);
  11.    }
  12.    function onXmlLoaded(success)
  13.    {
  14.       trace("(!) onXmlLoaded ");
  15.       if(success)
  16.       {
  17.          this.movieRoot.xmlLoaded();
  18.       }
  19.       else
  20.       {
  21.          trace("/!\\ERREUR lors du chargement du fichier xml");
  22.          this.movieRoot.debugger.text = "Chargement de fichier xml : ERROR";
  23.       }
  24.    }
  25.    function filterNode(nodePath, attribute, valeur)
  26.    {
  27.       this.tempNode = new XML();
  28.       var _loc3_ = this.recusiveGetNodesByAttribute(this.returnNodeByPath(nodePath),attribute,valeur);
  29.       var _loc2_ = this.tempNode.cloneNode(true);
  30.       return _loc2_;
  31.    }
  32.    function returnNodeByPath(nodePath)
  33.    {
  34.       var _loc4_ = nodePath.split(".");
  35.       var _loc3_ = this.XmlStocker.firstChild;
  36.       var _loc2_ = 0;
  37.       while(_loc2_ < _loc4_.length)
  38.       {
  39.          _loc3_ = this.getbyNodename(_loc4_[_loc2_],_loc3_);
  40.          _loc2_ = _loc2_ + 1;
  41.       }
  42.       return _loc3_;
  43.    }
  44.    function returnNodeByPathRandomise(nodePath)
  45.    {
  46.       var _loc4_ = this.returnNodeByPath(nodePath);
  47.       var _loc5_ = new XML();
  48.       var _loc6_ = _loc4_.childNodes.length;
  49.       var _loc2_ = 0;
  50.       while(_loc2_ < _loc6_)
  51.       {
  52.          var _loc3_ = this.movieRoot.randomValue(0,_loc4_.childNodes.length - 1);
  53.          _loc5_.appendChild(_loc4_.childNodes[_loc3_]);
  54.          _loc2_ = _loc2_ + 1;
  55.       }
  56.       return _loc5_;
  57.    }
  58.    function getbyNodename(nodeName, XMLBlock)
  59.    {
  60.       var _loc1_ = 0;
  61.       while(_loc1_ < XMLBlock.childNodes.length)
  62.       {
  63.          if(XMLBlock.childNodes[_loc1_].nodeName == nodeName)
  64.          {
  65.             return XMLBlock.childNodes[_loc1_].cloneNode(true);
  66.          }
  67.          _loc1_ = _loc1_ + 1;
  68.       }
  69.       return undefined;
  70.    }
  71.    function returnNodeByPos(nodePath, nodePos)
  72.    {
  73.       var _loc2_ = this.returnNodeByPath(nodePath);
  74.       return _loc2_.childNodes[nodePos - 1].cloneNode(true);
  75.    }
  76.    function returnNodeValueByPos(nodePath, nodePos)
  77.    {
  78.       var _loc2_ = this.returnNodeByPos(nodePath,nodePos);
  79.       return _loc2_.firstChild.nodeValue;
  80.    }
  81.    function getNodeFromNode(node, nodeName)
  82.    {
  83.       var _loc1_ = 0;
  84.       while(_loc1_ < node.childNodes.length)
  85.       {
  86.          if(node.childNodes[_loc1_].nodeName == nodeName)
  87.          {
  88.             return node.childNodes[_loc1_].cloneNode(true);
  89.          }
  90.          _loc1_ = _loc1_ + 1;
  91.       }
  92.    }
  93.    function getNodeByAttribute(node, attribute, attributeValue)
  94.    {
  95.       this.tempNode = new XML();
  96.       this.recusiveGetNodesByAttribute(node,attribute,attributeValue);
  97.       if(this.tempNode == null)
  98.       {
  99.       }
  100.       return this.tempNode;
  101.    }
  102.    function getResourceById(attributeValue)
  103.    {
  104.       this.tempNode = new XML();
  105.       this.recusiveGetNodesByAttribute(this.returnNodeByPath("Resources"),"id",attributeValue);
  106.       if(this.tempNode == null)
  107.       {
  108.       }
  109.       return this.tempNode;
  110.    }
  111.    function recusiveGetNodesByAttribute(node, attribute, attributeValue)
  112.    {
  113.       var _loc2_ = 0;
  114.       while(_loc2_ < node.childNodes.length)
  115.       {
  116.          if(node.childNodes[_loc2_].attributes[attribute] == attributeValue)
  117.          {
  118.             this.tempNode.appendChild(node.childNodes[_loc2_].cloneNode(true));
  119.          }
  120.          if(node.childNodes[_loc2_].hasChildNodes())
  121.          {
  122.             this.recusiveGetNodesByAttribute(node.childNodes[_loc2_],attribute,attributeValue);
  123.          }
  124.          _loc2_ = _loc2_ + 1;
  125.       }
  126.    }
  127. }
  128.