home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Diversos / painter_madness.swf / scripts / __Packages / CXML.as < prev   
Encoding:
Text File  |  2006-06-13  |  1.7 KB  |  59 lines

  1. class CXML extends XML
  2. {
  3.    var oResult;
  4.    var cbfunc;
  5.    function CXML()
  6.    {
  7.       super();
  8.    }
  9.    function onLoad(bSuccess)
  10.    {
  11.       if(bSuccess)
  12.       {
  13.          this.parse(this,this.oResult = new Object());
  14.       }
  15.       return this.cbfunc(bSuccess);
  16.    }
  17.    function parse(node, oRes)
  18.    {
  19.       node.ignoreWhite = true;
  20.       var _loc2_ = 0;
  21.       while(_loc2_ < node.childNodes.length)
  22.       {
  23.          if(node.childNodes[_loc2_].childNodes.length > 1)
  24.          {
  25.             this.parse(node.childNodes[_loc2_],oRes[node.childNodes[_loc2_].nodeName] = new Object());
  26.          }
  27.          else if(node.childNodes[_loc2_].hasChildNodes())
  28.          {
  29.             switch(node.childNodes[_loc2_].attributes.type)
  30.             {
  31.                case "Number":
  32.                   var _loc4_ = Number(node.childNodes[_loc2_].firstChild.nodeValue);
  33.                   break;
  34.                case "nArray":
  35.                   _loc4_ = this.conv2NumAr(node.childNodes[_loc2_].firstChild.nodeValue.split(node.childNodes[_loc2_].attributes.separator));
  36.                   break;
  37.                case "sArray":
  38.                   _loc4_ = node.childNodes[_loc2_].firstChild.nodeValue.split(node.childNodes[_loc2_].attributes.separator);
  39.                   break;
  40.                default:
  41.                   _loc4_ = node.childNodes[_loc2_].firstChild.nodeValue;
  42.             }
  43.             oRes[node.childNodes[_loc2_].nodeName] = _loc4_;
  44.          }
  45.          _loc2_ = _loc2_ + 1;
  46.       }
  47.    }
  48.    function conv2NumAr(ar)
  49.    {
  50.       var _loc1_ = 0;
  51.       while(_loc1_ < ar.length)
  52.       {
  53.          ar[_loc1_] = Number(ar[_loc1_]);
  54.          _loc1_ = _loc1_ + 1;
  55.       }
  56.       return ar;
  57.    }
  58. }
  59.