8 Replies Latest reply on May 13, 2009 7:10 AM by buenodelima

    Creating a dynamic array in Actionscript

    Cr99 Level 1

      I am wondering how I would create a dynamic array in Acionscript, i.e. one that utilizes fields for mapping data like this:

       

       

      public var SMITH:Array = [

                 {date:"29-Aug-05", close:45.87, profit:52},

                 {date:"23-Aug-05", close:45.74, profit:32},

                 {date:"21-Aug-05", close:45.77, profit:22},

                 {date:"25-Aug-05", close:46.06, profit:51},

              ];

       

       

      but where you would just be reading in data without knowing what your data looks like.  In other words, I'd like to take something like a database table with X number of columns and have Actionsctipt map each row to an item in my array.  Something like this:

       

      for each row in table

      add {col1:value, col2:value, col3:value, ... colX:value} to Array

       

      So I won't know "date" or "close" or whatever at runtime, I'll just have X number of items for each element in the array. How would this be done?

       

      The reason I need this mapping feature is because I then want to map the table-like array as the data provider to charts, datagrids, etc.

       

      Thanks.