Another good way to think of it is that a reference to an object is actually
an integer that holds the object's address in memory.  You'll see this in
the debugger as @3342fe334, etc.  So when you copy 'a' into 'b'  a la
'b=a;', you're making a copy of the address - not the object.  So when you
later say 'b = null;', it doesn't affect 'a' at all, because 'a' still holds
the address to the object.

You've probably heard of the garbage collector.  This special process is
basically running all the time and goes through all the objects and looks to
see if any variables hold their address, and if not, delete the object.  But
as long as some variable has that address, the object still exists.  So for
example:

a = new Book();
b = a;
a = null;
c = b;
b = null;

The same object exists all the way through.


On 9/4/07, williamkusumo <[EMAIL PROTECTED]> wrote:
>
>   Very stupid question which has been bugging me for a while and just
> might be the most basic question in this group.
>
> How does a object instance behave in Actionscript? Say if I have this:
>
> var a:Book = new Book();
> var b:Book = a;
> var c:Book = b;
>
> So does c actually point to the instance that a and b is pointing to
> or is it pointing to b?
>
> And if I do this:
>
> c = null;
>
> Does a and b get nulled too or does it act more like a pointer where
> it means c is now pointing to null, a and b still points to the object
> instance?
>
> Thanks!
>
> 
>

Reply via email to