A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Multidimensinal array toString?

  1. #1
    Bob (the singing sock)
    Join Date
    Aug 2000
    Location
    Århus, Denmark
    Posts
    472

    Multidimensinal array toString?

    I have a Multidimensinal array 'moods'.

    red = ["fire","warm"];
    blue = ["water","cold"];
    black = ["night",dark"];

    moods = [red,blue,black];

    how do I get the seperate names in moods?

    ( a function that returns the literal "red" when i ask for *something* moods[0])

    regards
    Podenphant

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Location
    UK
    Posts
    493
    var temp=moods[0][1] -- will return fire

    hope thats waht your after

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Location
    UK
    Posts
    493
    sorry it will of course return warm!

  4. #4
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    moods doesnt know red blue or black. As soon as you create moods and include those arrays, moods stores a reference to the arrays given and not the variable name itself. Just as the variable red points to the place of ["fire","warm"] in memory, so then does moods[0], bypassing the variable red all together.

    What you could do is include the actually color in with the string arrays

    red = ["red","fire","warm"]

    or try something weird like

    red = ["fire","warm"];
    blue = ["water","cold"];
    black = ["night",dark"];
    moods = ["red","blue","black"];

    moods[0] // "red"
    this[moods[0]][0] // "fire"

  5. #5
    Bob (the singing sock)
    Join Date
    Aug 2000
    Location
    Århus, Denmark
    Posts
    472
    thanks senocular, leaves me with ½ an hour of copy->paste

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