Skip to main content
Participant
June 20, 2014
Question

Calling the next number in an array through a function?

  • June 20, 2014
  • 1 reply
  • 224 views

ow do I request the next number in an array?

For example - currently being used for a loop:

for (i=0; i = levelSettings[0]; i++)

But when the function (named - NextLevel() ) is called I would like that loop to call the next number in that array.

Example:

(i=0; i = levelSettings[1]; i++) //Not the change in the levelSettings

I would like this to work for all subsequent numbers in that particular array - so it can continue through to levelSettings[10] and so on.

Cheers!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 20, 2014

use:

for(var k:Number=0;k<levelSettings.length;k++){

for(var i:Number=0;i<levelSettings;i++){

.

.

}

}

p.s. please mark correct responses.

KilzarAuthor
Participant
June 20, 2014

I will attempt to apply to use this in my code in just a minute.

Could you explain to me how the code works?

kglad
Community Expert
Community Expert
June 20, 2014

in the outter for-loop, k is varying from 0 to the last index in levelSettings.

in the inner for-loop i varies from 0 to levelSettings.

ie,

0 to levelSettings[0]

0 to levelSettings[1]

.

.

.

0 to levelSettings[last_index]