Skip to main content
tom_kristianm31618599
Participant
November 25, 2015
Answered

acess array from function

  • November 25, 2015
  • 1 reply
  • 314 views

i'm trying to make a 2d game, i'm still pretty new in flash, but here's my solution to the colision detection.

stage.addEventListener (KeyboardEvent.KEY_DOWN, keypress);

var zone11:Array = new Array(20);


zone11[0]  = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];

zone11[1]  = [1,0,1,1,1,1,1,0,0,0,0,0,0,1,2,1,1,1,1,1];

zone11[2]  = [1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1];

zone11[3]  = [1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1];

zone11[4]  = [1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1];

zone11[5]  = [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1];

zone11[6]  = [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1];

zone11[7]  = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];

zone11[8]  = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];

zone11[9]  = [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];

zone11[10] = [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];

zone11[11] = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];

zone11[12] = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];

zone11[13] = [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1];

zone11[14] = [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1];

zone11[15] = [1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1];

zone11[16] = [1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1];

zone11[17] = [1,1,1,1,1,0,0,0,0,0,0,0,0,0,2,2,1,1,1,1];

zone11[18] = [1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1];

zone11[19] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];

trace (zone11[1][1]);

function keypress(){

  trace (zone11[1][1]);

}

However i keep getting "Error #1063: Argument count mismatch on spilltest_fla::MainTimeline/keypress(). Expected 0, got 1." on the second trace, but the first trace is fine. why?

This topic has been closed for replies.
Correct answer nezarov

Set the function argument:

function keypress(e:KeyboardEvent):void {

trace (zone11[1][1]);

}

1 reply

nezarovCorrect answer
Inspiring
November 25, 2015

Set the function argument:

function keypress(e:KeyboardEvent):void {

trace (zone11[1][1]);

}