Copying Objects : copy « Array « Flash / Flex / ActionScript






Copying Objects

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var arrayA:Array = new Array("a", "b", "c", "d");
        var arrayB:Array = arrayA;
        arrayB.push("e", "f", "g", "h");
        trace(arrayA.length); // Outputs 8

    }
  }
}

        








Related examples in the same category

1.If you want to create a copy of the array, you can create a new array and use a for statement to copy each item from arrayA to arrayB