home *** CD-ROM | disk | FTP | other *** search
/ Computer Active Guide 2009 June / CAG06.ISO / Programos / TwonkyMediaManagerSetupStandard.exe / MediaManager / English.swf / scripts / mx / core / RSLItem.as < prev    next >
Encoding:
Text File  |  2010-02-09  |  3.4 KB  |  108 lines

  1. package mx.core
  2. {
  3.    import flash.display.Loader;
  4.    import flash.events.ErrorEvent;
  5.    import flash.events.Event;
  6.    import flash.events.IOErrorEvent;
  7.    import flash.events.ProgressEvent;
  8.    import flash.events.SecurityErrorEvent;
  9.    import flash.net.URLRequest;
  10.    import flash.system.ApplicationDomain;
  11.    import flash.system.LoaderContext;
  12.    import mx.events.RSLEvent;
  13.    
  14.    use namespace mx_internal;
  15.    
  16.    public class RSLItem
  17.    {
  18.       mx_internal static const VERSION:String = "3.0.0.0";
  19.       
  20.       protected var chainedSecurityErrorHandler:Function;
  21.       
  22.       public var total:uint = 0;
  23.       
  24.       public var loaded:uint = 0;
  25.       
  26.       private var completed:Boolean = false;
  27.       
  28.       protected var chainedRSLErrorHandler:Function;
  29.       
  30.       protected var chainedIOErrorHandler:Function;
  31.       
  32.       protected var chainedCompleteHandler:Function;
  33.       
  34.       private var errorText:String;
  35.       
  36.       protected var chainedProgressHandler:Function;
  37.       
  38.       public var urlRequest:URLRequest;
  39.       
  40.       protected var url:String;
  41.       
  42.       public function RSLItem(param1:String)
  43.       {
  44.          super();
  45.          this.url = param1;
  46.       }
  47.       
  48.       public function itemProgressHandler(param1:ProgressEvent) : void
  49.       {
  50.          loaded = param1.bytesLoaded;
  51.          total = param1.bytesTotal;
  52.          if(chainedProgressHandler != null)
  53.          {
  54.             chainedProgressHandler(param1);
  55.          }
  56.       }
  57.       
  58.       public function itemErrorHandler(param1:ErrorEvent) : void
  59.       {
  60.          errorText = decodeURI(param1.text);
  61.          completed = true;
  62.          loaded = 0;
  63.          total = 0;
  64.          trace(errorText);
  65.          if(param1.type == IOErrorEvent.IO_ERROR && chainedIOErrorHandler != null)
  66.          {
  67.             chainedIOErrorHandler(param1);
  68.          }
  69.          else if(param1.type == SecurityErrorEvent.SECURITY_ERROR && chainedSecurityErrorHandler != null)
  70.          {
  71.             chainedSecurityErrorHandler(param1);
  72.          }
  73.          else if(param1.type == RSLEvent.RSL_ERROR && chainedRSLErrorHandler != null)
  74.          {
  75.             chainedRSLErrorHandler(param1);
  76.          }
  77.       }
  78.       
  79.       public function load(param1:Function, param2:Function, param3:Function, param4:Function, param5:Function) : void
  80.       {
  81.          chainedProgressHandler = param1;
  82.          chainedCompleteHandler = param2;
  83.          chainedIOErrorHandler = param3;
  84.          chainedSecurityErrorHandler = param4;
  85.          chainedRSLErrorHandler = param5;
  86.          var _loc6_:Loader = new Loader();
  87.          var _loc7_:LoaderContext = new LoaderContext();
  88.          urlRequest = new URLRequest(url);
  89.          _loc6_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,itemProgressHandler);
  90.          _loc6_.contentLoaderInfo.addEventListener(Event.COMPLETE,itemCompleteHandler);
  91.          _loc6_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,itemErrorHandler);
  92.          _loc6_.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,itemErrorHandler);
  93.          _loc7_.applicationDomain = ApplicationDomain.currentDomain;
  94.          _loc6_.load(urlRequest,_loc7_);
  95.       }
  96.       
  97.       public function itemCompleteHandler(param1:Event) : void
  98.       {
  99.          completed = true;
  100.          if(chainedCompleteHandler != null)
  101.          {
  102.             chainedCompleteHandler(param1);
  103.          }
  104.       }
  105.    }
  106. }
  107.  
  108.