A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Multidimensional array in external AS file

  1. #1
    Member
    Join Date
    May 2007
    Posts
    55

    Multidimensional array in external AS file

    Hi there..

    Gotta problem with a multidimensional array. It works when included in the actionscript but not when included in an external .as file accessed through #include

    the actionscript (in the actual flash doc of course)
    Code:
    #include "as/datafiles.as"

    Code:
    var elms = new Array();
    for (var i = 0; i<=14; i++) {
    	elms.push(new Array());
    }
    elms[0] = new Array('hydrogen', 'H', 1, 1.01, 1, 'Humphrey Davy', 1702);
    elms[1] = new Array('helium', 'He', 2, 4.01, 2, 'Helios', 1835);
    Using a trace statement
    Code:
    trace(elms[0][1]);
    brings up 'undefined' when the code is placed in an external ("as/datafiles.as") actionscript file, but works OK in the actionscript.

    Any ideas?

  2. #2
    Member
    Join Date
    May 2007
    Posts
    55
    solved - the array needed to be set as a _global variable

    _global.elms=new Array();

Tags for this Thread

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