A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Cant assign value to MD array...??

  1. #1
    Senior Member
    Join Date
    Aug 2002
    Location
    Texas, USA, Earth
    Posts
    124

    Cant assign value to MD array...??

    Ive done this a thousands times, and for some reason its just not working for me this time.

    In the first line of the root timeline, I define a new array as such:

    Code:
    _global.movieSpecs = new Array();
    In a function (also in root) I have a for loop as such:

    Code:
    for (i=0;i<=result.fileName.length;i++) {
      fileName = result.fileName[i];
      fileSize = result.fileSize[i];
      movieSpecs[i][0] = fileName;
      movieSpecs[i][1] = fileSize;
    
      trace(i);
      trace(fileName);
      trace(movieSpecs[i][0]);
    }
    But, the trace on movieSpecs[i][1] comes back undefined.

    i traces fine (0..1..2..3..etc) as well as fileName and fileSize.

    No matter how I change the array name, placement, order, etc...the whole array comes back undefined.

    What the heck am I missing here? :0

    Thanks,

    Ahhhk!

  2. #2
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    You need to create the nested arrays...

    Code:
    for (i=0;i<=result.fileName.length;i++) {
      fileName = result.fileName[i];
      fileSize = result.fileSize[i];
    
      movieSpecs[i] = new Array();
    
      movieSpecs[i][0] = fileName;
      movieSpecs[i][1] = fileSize;
    
      trace(i);
      trace(fileName);
      trace(movieSpecs[i][0]);
    }
    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  3. #3
    Senior Member
    Join Date
    Aug 2002
    Location
    Texas, USA, Earth
    Posts
    124
    Get out!

    hehe...ok...now it all makes sense. In the past, I always defined some sort of defaults for the array before actually assigning values to the indexes in a function/for loop.

    Duh.

    Thanks Lexicon!

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