AS2 class instance properties behaves like static
Can anyone explain why a.arr and b.arr in the below example references to the same variable???The conclusion seems to be that that if you don't initialize object properties in the constructor, some weird sideeffects may happen.
Kind regards,
P.
PS: Svar er ok på dansk
-------------
Testclass.as:
class Testclass {
public var arr = new Array();
function Testclass() {
arr.push("asd");
}
}
-------------
Frame 1:
var a = new Testclass();
var b = new Testclass();
b.arr.push("test");
trace( a.arr );
trace( b.arr )
--------------
output:
asd,asd,test
asd,asd,test
--------------