home *** CD-ROM | disk | FTP | other *** search
/ csi.uticak12.org / csi.uticak12.org.tar / csi.uticak12.org / flashVideo / Handshake.swf / scripts / __Packages / mx / video / FPADManager.as < prev    next >
Text File  |  2010-12-15  |  5KB  |  141 lines

  1. class mx.video.FPADManager
  2. {
  3.    static var version = "1.0.2.7";
  4.    static var shortVersion = "1.0.2";
  5.    static var ELEMENT_NODE = 1;
  6.    static var TEXT_NODE = 3;
  7.    function FPADManager(owner)
  8.    {
  9.       this._owner = owner;
  10.    }
  11.    function connectXML(urlPrefix, uriParam, urlSuffix, uriParamParseResults)
  12.    {
  13.       this._uriParam = uriParam;
  14.       this._parseResults = uriParamParseResults;
  15.       this._url = urlPrefix + "uri=" + this._parseResults.protocol;
  16.       if(this._parseResults.serverName != undefined)
  17.       {
  18.          this._url += "/" + this._parseResults.serverName;
  19.       }
  20.       if(this._parseResults.portNumber != undefined)
  21.       {
  22.          this._url += ":" + this._parseResults.portNumber;
  23.       }
  24.       if(this._parseResults.wrappedURL != undefined)
  25.       {
  26.          this._url += "/?" + this._parseResults.wrappedURL;
  27.       }
  28.       this._url += "/" + this._parseResults.appName;
  29.       this._url += urlSuffix;
  30.       this.xml = new XML();
  31.       this.xml.onLoad = mx.utils.Delegate.create(this,this.xmlOnLoad);
  32.       this.xml.load(this._url);
  33.       return false;
  34.    }
  35.    function xmlOnLoad(success)
  36.    {
  37.       try
  38.       {
  39.          if(!success)
  40.          {
  41.             this._owner.helperDone(this,false);
  42.          }
  43.          else
  44.          {
  45.             var _loc5_ = this.xml.firstChild;
  46.             var _loc8_ = false;
  47.             while(_loc5_ != null)
  48.             {
  49.                if(_loc5_.nodeType == mx.video.FPADManager.ELEMENT_NODE)
  50.                {
  51.                   _loc8_ = true;
  52.                   if(_loc5_.nodeName.toLowerCase() == "fpad")
  53.                   {
  54.                      break;
  55.                   }
  56.                }
  57.                _loc5_ = _loc5_.nextSibling;
  58.             }
  59.             if(!_loc8_)
  60.             {
  61.                throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"URL: \"" + this._url + "\" No root node found; if url is for an flv it must have .flv extension and take no parameters");
  62.             }
  63.             else if(_loc5_ == null)
  64.             {
  65.                throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"URL: \"" + this._url + "\" Root node not fpad");
  66.             }
  67.             else
  68.             {
  69.                var _loc7_ = undefined;
  70.                var _loc6_ = 0;
  71.                while(_loc6_ < _loc5_.childNodes.length)
  72.                {
  73.                   var _loc3_ = _loc5_.childNodes[_loc6_];
  74.                   if(_loc3_.nodeType == mx.video.FPADManager.ELEMENT_NODE)
  75.                   {
  76.                      if(_loc3_.nodeName.toLowerCase() == "proxy")
  77.                      {
  78.                         var _loc2_ = 0;
  79.                         while(_loc2_ < _loc3_.childNodes.length)
  80.                         {
  81.                            var _loc4_ = _loc3_.childNodes[_loc2_];
  82.                            if(_loc4_.nodeType == mx.video.FPADManager.TEXT_NODE)
  83.                            {
  84.                               _loc7_ = this.trim(_loc4_.nodeValue);
  85.                               break;
  86.                            }
  87.                            _loc2_ = _loc2_ + 1;
  88.                         }
  89.                         break;
  90.                      }
  91.                   }
  92.                   _loc6_ = _loc6_ + 1;
  93.                }
  94.                if(_loc7_ == undefined || _loc7_ == "")
  95.                {
  96.                   throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"URL: \"" + this._url + "\" fpad xml requires proxy tag.");
  97.                }
  98.                else
  99.                {
  100.                   this.rtmpURL = this._parseResults.protocol + "/" + _loc7_ + "/?" + this._uriParam;
  101.                   this._owner.helperDone(this,true);
  102.                }
  103.             }
  104.          }
  105.       }
  106.       catch(err:Error)
  107.       {
  108.          this._owner.helperDone(this,false);
  109.          throw err;
  110.       }
  111.    }
  112.    function trim(str)
  113.    {
  114.       var _loc2_ = 0;
  115.       while(_loc2_ < str.length)
  116.       {
  117.          var _loc1_ = str.charAt(_loc2_);
  118.          if(_loc1_ != " " && _loc1_ != "\t" && _loc1_ != "\r" && _loc1_ != "\n")
  119.          {
  120.             break;
  121.          }
  122.          _loc2_ = _loc2_ + 1;
  123.       }
  124.       if(_loc2_ >= str.length)
  125.       {
  126.          return "";
  127.       }
  128.       var _loc4_ = str.length - 1;
  129.       while(_loc4_ > _loc2_)
  130.       {
  131.          _loc1_ = str.charAt(_loc4_);
  132.          if(_loc1_ != " " && _loc1_ != "\t" && _loc1_ != "\r" && _loc1_ != "\n")
  133.          {
  134.             break;
  135.          }
  136.          _loc4_ = _loc4_ - 1;
  137.       }
  138.       return str.slice(_loc2_,_loc4_ + 1);
  139.    }
  140. }
  141.