home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 145
/
MOBICLIC145.ISO
/
pc
/
DATA
/
DSS145
/
DSS145_10
/
DSS145_10.swf
/
scripts
/
dss145_10
/
Questions.as
< prev
Wrap
Text File
|
2012-07-18
|
3KB
|
103 lines
package dss145_10
{
public class Questions
{
private var _originalQuestionsList:Vector.<Question>;
private var _questions:Vector.<Question>;
private var _tab_alea:Array;
private var _index:int = -1;
public function Questions()
{
this._originalQuestionsList = new Vector.<Question>();
this._questions = new Vector.<Question>();
super();
}
public function addQuestion(param1:Question) : void
{
this._questions.push(param1);
}
public function removeQuestion(param1:Question) : void
{
var _loc2_:int = this._questions.indexOf(param1);
if(_loc2_ != -1)
{
this._questions.splice(_loc2_,1);
}
this.next();
}
public function melanger() : void
{
var tri:Function = null;
tri = function(param1:Number, param2:Number):Number
{
return Number(Math.round(Math.random() * 2) - 1);
};
this._tab_alea = [];
var i:int = 0;
while(i < this._questions.length)
{
this._tab_alea.push(i);
i++;
}
this._tab_alea.sort(tri);
var _questionsResult:Vector.<Question> = new Vector.<Question>();
var j:int = 0;
while(j < this._tab_alea.length)
{
_questionsResult.push(this._questions[this._tab_alea[j]]);
j++;
}
this._questions = _questionsResult;
}
public function next() : Question
{
++this._index;
if(this._index > this._questions.length - 1)
{
this._index = 0;
}
return this._questions[this._index];
}
public function previous() : Question
{
--this._index;
if(this._index < 0)
{
this._index = this._questions.length - 1;
}
return this._questions[this._index];
}
public function get question() : Question
{
return this._questions[this._index];
}
public function get questions() : Vector.<Question>
{
return this._questions;
}
public function set index(param1:int) : void
{
this._index = param1;
}
public function set questions(param1:Vector.<Question>) : void
{
this._questions = param1;
}
}
}