6 Replies Latest reply on May 15, 2012 1:26 PM by XELAD111

    Reverse an array issue

    peak_balu
      I have any array source say 'sourceArray' in an particular order, i need another array named 'targetArray' which need to be reverse of source array.

      Please find the code i have used for this,

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      var sourceArray: Array = new Array('SC', 'RX', 'LX', 'LS', 'IS', 'GX', 'GS','ES');
      var targetArray: Array;


      function reverseArray():void {
      Alert.show('Original Array is : ' + sourceArray);
      targetArray = sourceArray;
      Alert.show('Target Array before reversing is : ' + targetArray);
      targetArray.reverse();
      Alert.show('Target Array after reversing is : ' + targetArray);
      }
      ]]>
      </mx:Script>
      <mx:Button click="reverseArray()" label="Push Me !!!" />
      </mx:Application>