home *** CD-ROM | disk | FTP | other *** search
- package com.je.data
- {
- import com.je.utils.FileUtils;
-
- public class Queue
- {
- private var _queue:Vector.<QueueItem>;
-
- private var _currentIndex:int;
-
- private var _completeEvent:String;
-
- public function Queue(param1:String = null)
- {
- super();
- if(param1)
- {
- this._completeEvent = param1;
- }
- this.clearQueue();
- }
-
- public function clearQueue() : void
- {
- this._queue = new Vector.<QueueItem>();
- this._currentIndex = 0;
- }
-
- public function add(param1:String, param2:String, param3:String = null) : void
- {
- if(param1 == null || param2 == null || param2.length == 0 || !FileUtils.hasFileExtension(param2))
- {
- return;
- }
- if(this._queue.length > 0)
- {
- if(!this.alreadyExistis(param1,param2))
- {
- this._queue.push(this.generateValueObject(param1,param2,param3));
- }
- }
- else
- {
- this._queue.push(this.generateValueObject(param1,param2,param3));
- }
- }
-
- private function alreadyExistis(param1:String, param2:String) : Boolean
- {
- var _loc3_:Boolean = false;
- var _loc4_:int = 0;
- while(_loc4_ < this._queue.length)
- {
- if(this._queue[_loc4_].linkedId == param1 || this._queue[_loc4_].path == param2)
- {
- _loc3_ = true;
- }
- _loc4_++;
- }
- return _loc3_;
- }
-
- private function generateValueObject(param1:String, param2:String, param3:String = null) : QueueItem
- {
- var _loc4_:QueueItem = new QueueItem();
- _loc4_.linkedId = param1;
- _loc4_.path = param2;
- _loc4_.itemLoadedEvent = param3;
- return _loc4_;
- }
-
- public function getItemAt(param1:int) : QueueItem
- {
- return this._queue[param1];
- }
-
- public function getNextItem() : QueueItem
- {
- var _loc1_:QueueItem = null;
- if(this._currentIndex < this._queue.length)
- {
- ++this._currentIndex;
- _loc1_ = this._queue[this._currentIndex];
- }
- return _loc1_;
- }
-
- public function getQueueLenght() : int
- {
- return this._queue.length;
- }
-
- public function get commpleteEvent() : String
- {
- return this._completeEvent;
- }
- }
- }
-
-