home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / mx / core / RSLItem.as < prev    next >
Encoding:
Text File  |  2010-06-23  |  3.6 KB  |  112 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.    import mx.utils.LoaderUtil;
  14.    
  15.    use namespace mx_internal;
  16.    
  17.    public class RSLItem
  18.    {
  19.       mx_internal static const VERSION:String = "3.5.0.12683";
  20.       
  21.       protected var chainedSecurityErrorHandler:Function;
  22.       
  23.       public var total:uint = 0;
  24.       
  25.       public var loaded:uint = 0;
  26.       
  27.       private var completed:Boolean = false;
  28.       
  29.       protected var chainedRSLErrorHandler:Function;
  30.       
  31.       protected var chainedIOErrorHandler:Function;
  32.       
  33.       protected var chainedCompleteHandler:Function;
  34.       
  35.       private var errorText:String;
  36.       
  37.       protected var chainedProgressHandler:Function;
  38.       
  39.       public var urlRequest:URLRequest;
  40.       
  41.       public var rootURL:String;
  42.       
  43.       protected var url:String;
  44.       
  45.       public function RSLItem(param1:String, param2:String = null)
  46.       {
  47.          super();
  48.          this.url = param1;
  49.          this.rootURL = param2;
  50.       }
  51.       
  52.       public function itemProgressHandler(param1:ProgressEvent) : void
  53.       {
  54.          loaded = param1.bytesLoaded;
  55.          total = param1.bytesTotal;
  56.          if(chainedProgressHandler != null)
  57.          {
  58.             chainedProgressHandler(param1);
  59.          }
  60.       }
  61.       
  62.       public function itemErrorHandler(param1:ErrorEvent) : void
  63.       {
  64.          errorText = decodeURI(param1.text);
  65.          completed = true;
  66.          loaded = 0;
  67.          total = 0;
  68.          trace(errorText);
  69.          if(param1.type == IOErrorEvent.IO_ERROR && chainedIOErrorHandler != null)
  70.          {
  71.             chainedIOErrorHandler(param1);
  72.          }
  73.          else if(param1.type == SecurityErrorEvent.SECURITY_ERROR && chainedSecurityErrorHandler != null)
  74.          {
  75.             chainedSecurityErrorHandler(param1);
  76.          }
  77.          else if(param1.type == RSLEvent.RSL_ERROR && chainedRSLErrorHandler != null)
  78.          {
  79.             chainedRSLErrorHandler(param1);
  80.          }
  81.       }
  82.       
  83.       public function load(param1:Function, param2:Function, param3:Function, param4:Function, param5:Function) : void
  84.       {
  85.          chainedProgressHandler = param1;
  86.          chainedCompleteHandler = param2;
  87.          chainedIOErrorHandler = param3;
  88.          chainedSecurityErrorHandler = param4;
  89.          chainedRSLErrorHandler = param5;
  90.          var _loc6_:Loader = new Loader();
  91.          var _loc7_:LoaderContext = new LoaderContext();
  92.          urlRequest = new URLRequest(LoaderUtil.createAbsoluteURL(rootURL,url));
  93.          _loc6_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,itemProgressHandler);
  94.          _loc6_.contentLoaderInfo.addEventListener(Event.COMPLETE,itemCompleteHandler);
  95.          _loc6_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,itemErrorHandler);
  96.          _loc6_.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,itemErrorHandler);
  97.          _loc7_.applicationDomain = ApplicationDomain.currentDomain;
  98.          _loc6_.load(urlRequest,_loc7_);
  99.       }
  100.       
  101.       public function itemCompleteHandler(param1:Event) : void
  102.       {
  103.          completed = true;
  104.          if(chainedCompleteHandler != null)
  105.          {
  106.             chainedCompleteHandler(param1);
  107.          }
  108.       }
  109.    }
  110. }
  111.  
  112.