linked(?) variables changing others
i'm not sure call this. tried create contrived example, won't work =/ (or rather does)
so here's setup. have document class, has member variable (call a) custom class. varable has public property (call b) array of arrays (contains 3). inside of document class, have function assigns 1 of arrays variable (call c), uses , later assigned b array of nulls. problem when assignment, modifies array inside of a.
example (but mentioned, couldnt create broken contrived example)
a.b = [[1,2,3],[4,5,6],[7,8,9]];
c = a.b[1];
trace(a.b, c); // 1,2,3,4,5,6,7,8,9 4,5,6
c = [null,null,null];
trace(a.b, c); // 1,2,3,null,null,null,7,8,9 null,null,null
no matter try, c seems "linked" array inside a.b. have tried both shortcut , full syntax of array(); solution could work create getb function on accepts index, loop on contents of a.b[i] assigning values new variable d returned. seems overkill.
i have been noticing similar behavior, general assistance helpfull well. knowing called can google helpful!
looping 1 way go. approach use of array methods return array. "slice" method one...
c = a.b[1].slice();
when assign directly, assigning reference array, other object assign var/name.
More discussions in ActionScript 3
adobe
Comments
Post a Comment