i'm trying to make a question game with 30 question divided into 3 dificulties, so i'm using arrays to have my questions randomized but not repetitive.
I made the code use the first parameter of the array (array[0]) then remove it from the array.
So, my array will have no more elements after a time. But, when my array have only 1 element, i cant play this element, and i need to use the representation of the empty array to get it to play.
I'm new on AS3, so this may seem very confusing. Here is the code I used.
btn_1.addEventListener(MouseEvent.CLICK,retor);
function retor(e:MouseEvent):void{
trace(vaitemp);
gotoAndStop(1,vaitemp[0]);
vaitemp.splice(0,1);
if(vaitemp.length==0){
trace ("acabou")
gotoAndStop(1,vai2temp[0]);
vai2temp.splice(0,1);
trace(vai2temp)
}
}
I need to represent the "vaitemp" Array as an empty array at the "if"function, so it will play the last element and THEN go to the next array (the "medium dificulty group").
Well, the question is preety messy, i hope any of you can understand what I want.
.length == 0is a check for empty array.