Actionscript 2 wasn't that bad after all, but a few things drove some developers crazy. For example if you initialized a member variable with an Object, this member magically behaved like a static classmember, due to the storage of the member in the prototype. In ActionScript 3 this works just like expected, as you can see here.
//////////
在AS2中的老問題,在AS3中得到解決了。以內聯方式初始化數組和對象,屬性可能變成靜態成員。(可以參看LUAR的書《ACTIONSCRIPT 2.0與RIA應用程式開發》80頁)
在AS2裡面
Test1.as
import Test2;
class Test1 extends MovieClip
{
public function Test1 ()
{
var t1:Test2 = new Test2 ();
var t2:Test2 = new Test2 ();
}
}
Test2.as
class Test2
{
private var a:Array = new Array ();
function Test2 ()
{
a.push (a.length);
trace (a);
}
}