A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Duplicating variables, how?

  1. #1
    Member
    Join Date
    Dec 2005
    Posts
    70

    Duplicating variables, how?

    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

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    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/a.../t-113072.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center