A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Storing arrays

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    171

    Storing arrays

    Hi all,
    I am having a tough time finding a solution for this.
    Lets say i have a randomly generated number.
    eg.
    Code:
    q = Number(random(50))+1;
    On another frame i have a loop.
    eg.
    Code:
    loop = Number(loop)+1;
    score = score-0;
    gotoAndPlay(1);
    Within this frame i want to store the values of "q" in an array, for example:
    Code:
    new_q = 2,23,12,14,8 etc.
    The loop only lasts 10 times so i would need to store just 10.
    Any ideas on how i should do this?
    Regards,
    Suzy

  2. #2
    Senior Member
    Join Date
    Jul 2003
    Location
    Brighton,UK
    Posts
    249
    //frame 1 code>>

    if (not myArray){
    myArray = new Array();
    }
    // makes a new array
    q = Number(random(50))+1;
    myArray.push(q);
    //adds the q Var to the end of the array

    //frame 2 code>>

    if (MyArray.length==10) {
    trace(MyArray);
    stop();
    } else {
    gotoAndPlay(_currentframe-1);
    }

    //after it has run ten times the movie will stop and display the array

    //hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center