home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 145 / MOBICLIC145.ISO / pc / DATA / DSS145 / DSS145_12 / DSS145_12.swf / scripts / dss145_12 / Questions.as < prev    next >
Text File  |  2012-07-19  |  3KB  |  103 lines

  1. package dss145_12
  2. {
  3.    public class Questions
  4.    {
  5.        
  6.       
  7.       private var _originalQuestionsList:Vector.<Question>;
  8.       
  9.       private var _questions:Vector.<Question>;
  10.       
  11.       private var _tab_alea:Array;
  12.       
  13.       private var _index:int = -1;
  14.       
  15.       public function Questions()
  16.       {
  17.          this._originalQuestionsList = new Vector.<Question>();
  18.          this._questions = new Vector.<Question>();
  19.          super();
  20.       }
  21.       
  22.       public function addQuestion(param1:Question) : void
  23.       {
  24.          this._questions.push(param1);
  25.       }
  26.       
  27.       public function removeQuestion(param1:Question) : void
  28.       {
  29.          var _loc2_:int = this._questions.indexOf(param1);
  30.          if(_loc2_ != -1)
  31.          {
  32.             this._questions.splice(_loc2_,1);
  33.          }
  34.          this.next();
  35.       }
  36.       
  37.       public function melanger() : void
  38.       {
  39.          var tri:Function = null;
  40.          tri = function(param1:Number, param2:Number):Number
  41.          {
  42.             return Number(Math.round(Math.random() * 2) - 1);
  43.          };
  44.          this._tab_alea = [];
  45.          var i:int = 0;
  46.          while(i < this._questions.length)
  47.          {
  48.             this._tab_alea.push(i);
  49.             i++;
  50.          }
  51.          this._tab_alea.sort(tri);
  52.          var _questionsResult:Vector.<Question> = new Vector.<Question>();
  53.          var j:int = 0;
  54.          while(j < this._tab_alea.length)
  55.          {
  56.             _questionsResult.push(this._questions[this._tab_alea[j]]);
  57.             j++;
  58.          }
  59.          this._questions = _questionsResult;
  60.       }
  61.       
  62.       public function next() : Question
  63.       {
  64.          ++this._index;
  65.          if(this._index > this._questions.length - 1)
  66.          {
  67.             this._index = 0;
  68.          }
  69.          return this._questions[this._index];
  70.       }
  71.       
  72.       public function previous() : Question
  73.       {
  74.          --this._index;
  75.          if(this._index < 0)
  76.          {
  77.             this._index = this._questions.length - 1;
  78.          }
  79.          return this._questions[this._index];
  80.       }
  81.       
  82.       public function get question() : Question
  83.       {
  84.          return this._questions[this._index];
  85.       }
  86.       
  87.       public function get questions() : Vector.<Question>
  88.       {
  89.          return this._questions;
  90.       }
  91.       
  92.       public function set index(param1:int) : void
  93.       {
  94.          this._index = param1;
  95.       }
  96.       
  97.       public function set questions(param1:Vector.<Question>) : void
  98.       {
  99.          this._questions = param1;
  100.       }
  101.    }
  102. }
  103.