4 Replies Latest reply on Sep 13, 2006 3:18 PM by CogDev

    Trouble with referencing.

    CogDev
      Here's my issue. In flash, when you say:

      var myArray:Array = ["one","two","three"];

      you make a new array. But when you do this:

      var newArray:Array = myArray

      you dont make a new copy, you get an alias. In other words, "newArray" is a shortcut to "myArray"
      so if I were to change one:

      myArray[0] = "ten"

      then trace(newArray) would return "ten, two, three" because both names point to the same array.

      This is killing me when I try to save arrays into a shared object. The shared object is getting aliases instead of data, so when I reload my file, the data is lost. Is there a way to force flash to assign the data instead of an alias when creating a new variable?