2

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.

1
  • You are doing right: .length == 0 is a check for empty array. Commented Jan 5, 2012 at 19:22

1 Answer 1

4

The literal for an empty array is just []. As in var emptyArray:Array = [];

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.