So now onto Proxy. A proxy is different as it is an object that actually points
to another object. When references are assigned to a proxy, they are assigned to
the proxy not the target object. If the object behind the proxy changes, the
existing reference points to the new value. Normally, older references remain
glued to the older value as follows:
//create a new array A = [1,2,3]
//create a
reference to A B = A
//create a new array A =
[20,30,40]
trace(B[0]) //1 trace(A[0]) //20
When A was
overwritten with a new value, the B reference maintained the link to memory
originally allocated to A.
Let use a Proxy:
http://www.powersdk.com/sample/proxy.zip
//create a Proxy with a value of [1,2,3] A = new
Proxy( [1,2,3] )
//create a reference to the Proxy B =
A
//trace the value through the proxy references trace(A[0])
//1 trace(B[0]) //1
// change the Proxy value Proxy.setValue( A ,
{name:23} )
//trace the value through the proxy references trace(
A['name'] ) //23 trace( B['name'] ) //23
//obtain the true Proxy
value myProxyValue = Proxy.getValue( A )
|