;

PDA

Click to See Complete Forum and Search --> : Duplicating variables, how?


Sid1120
09-03-2007, 03:47 PM
Hi,

I'm trying to make copies of something, but all I manage to do is make a reference (which is most annoying).

For example, with the following code:

var sprite1:Sprite = new Sprite();
var sprite2:Sprite = sprite1;
var sprite3:Sprite = sprite1;

As you all know, since it only makes references rather then make copies, fiddling with sprite2 will chance sprite1 & 3... so how can I make new instances of an existing variable and not mere references? So that when I change something to sprite2, it doesn't affect sprite1&3?

Thanks in advance, Sid1120

joshstrike
09-03-2007, 04:17 PM
The short answer is there's no easy way. You really have to invoke whatever drawing function you're using every time you create a new Sprite. See this thread for more details:
http://www.actionscript.org/forums/archive/index.php3/t-113072.html