|
-
Senior Member
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!
-
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.
-
Senior Member
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.
-
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.
-
Senior Member
Awesome, that's brilliant. Thanks for the info guys!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|