home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 136 / MOBICLIC136.ISO / pc / DATA / BLA136 / BLA136_00 / BLA136_00.swf / scripts / __Packages / prod / moteur_v1_0 / V000_ChargementXML.as next >
Text File  |  2011-07-20  |  4KB  |  116 lines

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