先讲个例子:
a有个朋友,b说:a的朋友就是我的朋友,c说:b的朋友就是我的朋友,d说:c的朋友就是我的朋友….一直到f.
过了阵子d说:我有了新的朋友。请问e,f的朋友有没有变呢?

再贴上下面的代码;

<code>var a:Array=[0,1,2];
var b:Array=a;
var c:Array=b;
var d:Array=c;
var e:Array=d;
var f:Array=e;
trace(a);
trace(b);
trace(c);
trace(d);
trace(e);
trace(f);
trace("---------------");
d =[3,2,1];
trace(a);
trace(b);
trace(c);
trace(d);
trace(e);
trace(f);</code>

执行结果:
<code>
0,1,2
0,1,2
0,1,2
0,1,2
0,1,2
0,1,2
---------------
0,1,2
0,1,2
0,1,2
3,2,1
0,1,2
0,1,2
</code>

很有意思,但也很讨厌,对于帧处理来说这个事情就要让e f 再让他们表态一下。
var a:Array=[0,1,2];
var b:Array=a;
var c:Array=b;
var d:Array=c;
var e:Array=d;
var f:Array=e;
trace(a);
trace(b);
trace(c);
trace(d);
trace(e);
trace(f);
trace("---------------");
d =[3,2,1];
trace(a);
trace(b);
trace(c);
trace(d);
trace(e);
trace(f);
trace("---------------");
e=d;
f=e;
trace(a);
trace(b);
trace(c);
trace(d);
trace(e);
trace(f);

执行结果:
0,1,2
0,1,2
0,1,2
0,1,2
0,1,2
0,1,2
---------------
0,1,2
0,1,2
0,1,2
3,2,1
0,1,2
0,1,2
---------------
0,1,2
0,1,2
0,1,2
3,2,1
3,2,1
3,2,1

Leave a Reply

You must be logged in to post a comment.