As3 - dumping Associated arrays
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: As3 - dumping Associated arrays

  1. #1
    Junior Member
    Join Date
    Sep 2017
    Posts
    2

    As3 - dumping Associated arrays

    A bit of a stupid question maybe, but i'm trying to work on a saving file system (a basic one) using fileReference cause I wasn't happy with just using Sharedobjects (they are tempory files after all).. anyway,

    I have a an associated array (one which uses strings for keys) and I need to convert it into a string which has the key then the value.. well, when dealing with this kind of array, you can't just cycle it like a normal number based one, nor use things like Array Length.. and since values and even keys can be added at run time, it's a bit tricky to figure this out..

    The best option I can think is to store all the keys in another array and use that.. but i'm not sure if there is another way. I like to keep my options open when I can ^_^

    any ideas would be helpful.

    Thanks

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,745
    You're discounting the "for each in" loop.
    Code:
    for ( var key:String in array ) trace("key is: " + key + " and value " + array[key]);
    This should probably get you started.
    .

  3. #3
    Junior Member
    Join Date
    Sep 2017
    Posts
    2
    damn... your right.. I completely forgot about for each in loops... That allows dumping of most of the arrays contents.. in fact, that should do the job apart from nested arrays I think (when the nested array also is an associated array) but they are known at design time and can be dealt with.

    Thanks ^_^

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

Poll by Flashkit.com