home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2011 May / ME_2011_05.iso / Galileo-Video-Tutorial / system / player.swf / scripts / com / je / data / Queue.as next >
Encoding:
Text File  |  2010-11-30  |  2.6 KB  |  100 lines

  1. package com.je.data
  2. {
  3.    import com.je.utils.FileUtils;
  4.    
  5.    public class Queue
  6.    {
  7.       private var _queue:Vector.<QueueItem>;
  8.       
  9.       private var _currentIndex:int;
  10.       
  11.       private var _completeEvent:String;
  12.       
  13.       public function Queue(param1:String = null)
  14.       {
  15.          super();
  16.          if(param1)
  17.          {
  18.             this._completeEvent = param1;
  19.          }
  20.          this.clearQueue();
  21.       }
  22.       
  23.       public function clearQueue() : void
  24.       {
  25.          this._queue = new Vector.<QueueItem>();
  26.          this._currentIndex = 0;
  27.       }
  28.       
  29.       public function add(param1:String, param2:String, param3:String = null) : void
  30.       {
  31.          if(param1 == null || param2 == null || param2.length == 0 || !FileUtils.hasFileExtension(param2))
  32.          {
  33.             return;
  34.          }
  35.          if(this._queue.length > 0)
  36.          {
  37.             if(!this.alreadyExistis(param1,param2))
  38.             {
  39.                this._queue.push(this.generateValueObject(param1,param2,param3));
  40.             }
  41.          }
  42.          else
  43.          {
  44.             this._queue.push(this.generateValueObject(param1,param2,param3));
  45.          }
  46.       }
  47.       
  48.       private function alreadyExistis(param1:String, param2:String) : Boolean
  49.       {
  50.          var _loc3_:Boolean = false;
  51.          var _loc4_:int = 0;
  52.          while(_loc4_ < this._queue.length)
  53.          {
  54.             if(this._queue[_loc4_].linkedId == param1 || this._queue[_loc4_].path == param2)
  55.             {
  56.                _loc3_ = true;
  57.             }
  58.             _loc4_++;
  59.          }
  60.          return _loc3_;
  61.       }
  62.       
  63.       private function generateValueObject(param1:String, param2:String, param3:String = null) : QueueItem
  64.       {
  65.          var _loc4_:QueueItem = new QueueItem();
  66.          _loc4_.linkedId = param1;
  67.          _loc4_.path = param2;
  68.          _loc4_.itemLoadedEvent = param3;
  69.          return _loc4_;
  70.       }
  71.       
  72.       public function getItemAt(param1:int) : QueueItem
  73.       {
  74.          return this._queue[param1];
  75.       }
  76.       
  77.       public function getNextItem() : QueueItem
  78.       {
  79.          var _loc1_:QueueItem = null;
  80.          if(this._currentIndex < this._queue.length)
  81.          {
  82.             ++this._currentIndex;
  83.             _loc1_ = this._queue[this._currentIndex];
  84.          }
  85.          return _loc1_;
  86.       }
  87.       
  88.       public function getQueueLenght() : int
  89.       {
  90.          return this._queue.length;
  91.       }
  92.       
  93.       public function get commpleteEvent() : String
  94.       {
  95.          return this._completeEvent;
  96.       }
  97.    }
  98. }
  99.  
  100.