A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Pointers

  1. #1
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393

    Pointers

    Say I create 2 sprites.

    var s1:Sprite = new Sprite();
    var s2:Sprite;

    Then I set s2 = s1. Now, when I alter any properties of either s1 or s2, the property of both instances changes.

    So what is s2? s1 is a sprite instance, is s2 also a sprite instance or simply a pointer to the sprite instance s1?

    Thanks!
    ninjakannon

    - My Website -

  2. #2
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    this is how I think it works,- somewhere a sprite class gets adressed (in your ram, in the CPU in the logic- dunno where exactly). Booth s1 and s2 are in your case pointers to that class that is stored somewhere.

    once you null booth variables (e.g s1 = null) the garbage collector will at some point sweep and delete the original sprite class from your ram,logic ect.

    However pointers only are used with advanced types such as objects, classes and arrays. Numbers and integers are a acception. Or something like that- there should be a adobe documentation about this.

  3. #3
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    That would actually be a good way of doing it - minimising the RAM used. So perhaps you're right; good thinking!

    I would expect there is some documentation about this somewhere, although I can't find any. Would be nice if someone knew where that was, or what happens for sure.
    ninjakannon

    - My Website -

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Yes, that's how it works. It's very like Java in that respect where everything other than primitives (Number, int, etc) are handled as references.

    I don't have a link to specific documentation, but I'm 99.9999% certain that's how things work.

  5. #5
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    Awesome, that's brilliant. Thanks for the info guys!
    ninjakannon

    - My Website -

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