Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2008
    Posts
    235
    Thanks
    6
    Thanked 21 Times in 20 Posts

    Resolved: Array assignment error in AS2 - Simple bug

    Hi guys,

    Here is the piece of code which doesn't seem to work:

    Code:
    lang_array[i]['eng'] = english;
    lang_array[i]['pol'] = polski;
    lang_array[i]['de'] = deutsch;
    trace(english);
    trace(i);
    trace(lang_array[i]['eng']);
    the trace from this (it loops through 3 times)

    Code:
    This is a transcript..
    0
    undefined
    This is a transcript2..
    1
    undefined
    This is a transcript3..
    2
    undefined
    further up in the code is this:
    Code:
    //added in to support multilingual transcripts
    var lang_array:Array = [];
    Any ideas why this is failing and the final trace doesn't output anything? I'm fairly new to AS so if you need more than what i've given let me know.

    hope someone can help!
    Andrew Sharman
    Web designer, developer and programmer.

    If you found my post helpful, why not give thanks! :)

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Assuming that english polski und deutsch are variables with data associated with them, that shouldn't be the problem. I feel like multidimensional arrays like their keys to be index with numbers, have you tried this?

    Code:
    lang_array[i][0] = 'english';
    lang_array[i][1] = 'polski';
    lang_array[i][2] = 'deutsch';
    trace(english);
    trace(i);
    trace(lang_array[i][0]);
    Also it might make more sense to establish your array like this

    Code:
    //added in to support multilingual transcripts
    var lang_array:Array = new Array();
    There are several ways to setup your arrays, depending on how you want to store the data.

    http://livedocs.adobe.com/flash/9.0/...=00000091.html
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Posting Permissions

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