🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.livemotion.actionscript
3 messages
3 total messages Started by Doug_Calli Mon, 30 Aug 2004 17:34
multi-dimensional arrays
#4
Author: Doug_Calli
Date: Mon, 30 Aug 2004 17:34
11 lines
1066 bytes
I'd like to create a multi-dimensional array to hold mc names and labels but so far I haven't found the correct syntax.

This is what I'd expect the format to be,...
_root.DirectorArray = new Array();

_root.DirectorArray[1][1] = "dir_1"; // mc name //
_root.DirectorArray[1][2] = "D_1"; // mc timeline label //

but it and several other attempts have failed.

Thanks, DC
Re: multi-dimensional arrays
#6
Author: Doug_Calli
Date: Mon, 30 Aug 2004 18:08
2 lines
823 bytes
sorry, I only meant to post this once, I had forgotten to set the check box for an email response.
DC
Re: multi-dimensional arrays
#7
Author: Bo_Hjort_Nielsen
Date: Tue, 31 Aug 2004 20:40
106 lines
1934 bytes
If you have a short multi dimensional array, you could simply type it out...like this (indented for clarity)

_root.DirectorArray =
   [
      ["dir_1", "D_1"],
      ["dir_2", "D_2"],
      ["dir_3", "D_3"],
      ["dir_4", "D_4"]
   ];

now

      _root.DirectorArray[2][0];




would return

      "dir_3"




But if the content of your array is fairly large and as structured as your example imply, you might safe some typing and perhaps gain some flexibility by using a series of anonymous objects in a "regular" array for ease of access?

      _root.DirectorArray = new Array ();





      var maxNum = 20; // number of objects in array





      for (i=0; i<maxNum; i++) {





      var temp = new Object();





      temp.mcName = "dir_" + i;





      temp.mcLabel = "D_" + i;





      _root.DirectorArray.push(temp)





      }




Now

      _root.DirectoryArray[3].mcName;




would return

      "dir_3"




and similar

      _root.DirectoryArray[3].mcLabel;




would return

      "D_3"




I haven't actually tested any of this, so no guarantees it will work exactly as typed here. Let me know if I messed it up somewhere.

Hope it helps...

-Bo
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads