1 Reply Latest reply on Jul 8, 2010 5:32 PM by UbuntuPenguin

    Arrays and LineChart




      I am new to Flex and I am stuck on a specific task I need to complete.


      I would like to generate an array of values based on user input and plot those values out on a line chart. For example, I would like to generate a sine wave over T seconds with a spacing of dT, where dT is a constant and T is given by the user. I would like each of the values to be stored in an array (whose size depends on T and must therefore be generated during execution of the application) and then plotted out using the LineChart control.


      I am thinking of using ArrayLists instead of ArrayCollections since I will only be using numbers. I have created a function which populates the array:



                     import mx.collections.ArrayList;
                     private function generateArray():ArrayList {
                          var myArrayList:ArrayList;
                          var T:Number = time.text;
                          var dT:Number = 0.1;
                          var freq:Number = 1;
                          for (var i:int = 0;  i < T/dT; i++) {
                          myArrayList.addItem(Math.sin(dT * i * 2 * Math.PI *freq));
                          return myArrayList;


      However, once I have done that, I am unaware of how to continue.



      Any help is greatly appreciated. Thanks