The thing that bothers me is that no one seems to care if this is a bug or
not.
It shouldn't, it's been discussed at least a hundred times here already,
and it's not a bug. Don't initialize class variables in the class
defenition, it adds them to the prototype. Initialize them in the
const
s in your class, and initialize in your constructor or
init functions, and you'll never have problems.
- Original Message -
From: "Judah Frangipane" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list"
Sent: Thursday, December 29, 2005 5:56 PM
Subject: Re: [Flashcod
type_array.push("foo_d");
trace(foo.prototype_array); // b, foo_d
trace(bar.prototype_array); // b, foo_d
- Original Message -
From: "JesterXL" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list"
Sent: Thursday, December 29, 2005 3:39 PM
Subject: Re: [Flashcoder
OTECTED]>
> To: "Flashcoders mailing list"
> Sent: Thursday, December 29, 2005 3:39 PM
> Subject: Re: [Flashcoders] Flash Class Array bug - Please verify
>
>
> Nope, they are prototype scoped arrays, not static.
>
> AS1:
> function MyClass(){}
>
> AS2:
&
Flash is still treating the array as a static member.
It isn't static, but it is being assigned the array object in the
prototype, which acts sort of like a static member. You need to assign
(initialize) it in the constructor, rather than in the member defenition.
ryanm
ot;
Sent: Thursday, December 29, 2005 3:39 PM
Subject: Re: [Flashcoders] Flash Class Array bug - Please verify
Nope, they are prototype scoped arrays, not static.
AS1:
function MyClass(){}
AS2:
class MyClass{}
AS1 - static:
MyClass.my_array = [];
AS2 - static:
class MyClass
{
stat
Yes, when you assign an initial value to a property, it is basically
like a static assignment. Do the initialization in the constructor
instead. This works for me:
class myClass
{
// initialize the array in the declarations
var myArray:Array;
function myClass()
{
myArray =
oint to it
foo.prototype_array.push("foo_d");
trace(foo.prototype_array); // b, foo_d
trace(bar.prototype_array); // b, foo_d
- Original Message -
From: "JesterXL" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list"
Sent: Thursday, December 29, 2005
Hi Glenn,
Flash is still treating the array as a static member.
// treated as an instance variable
var myArray1:Array;
// treated as a static variable
var myArray2:Array = new Array();
Test this code:
// in actions frame 1
import myClass
trace("Creating instance a")
var a = new myClass();
a.a
Nope, they are prototype scoped arrays, not static.
AS1:
function MyClass(){}
AS2:
class MyClass{}
AS1 - static:
MyClass.my_array = [];
AS2 - static:
class MyClass
{
static var my_array:Array = [];
}
AS1 - prototype:
MyClass.protoytpe.my_array = [];
AS2 - prototype:
Same as above, or:
cla
Yeah... that's a good point too... LOL
Peace...
--
Dok
Skyymap, Inc.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Nathan
Derksen
Sent: Thursday, December 29, 2005 3:33 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Flash Class Arra
ay.push(10);
this.myArray.push(20);
}
}
Peace...
--
Dok
Skyymap, Inc.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Glenn J.
Miller
Sent: Thursday, December 29, 2005 3:33 PM
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoder
I think you are missing the () in the constructor statement:
function myClass {
trace("myArray.length="+myArray.length)
}
Should be:
function myClass() {
trace("myArray.length="+myArray.length)
}
Nathan
http://www.nathanderksen.com
On Dec 29, 2005, at 12:30 PM, Judah Frangipane w
Hey Judah,
Try this:
class myClass {
// initialize the array in the declarations
private var myArray:Array = new Array();
function myClass {
trace("myArray.length="+this.myArray.length)
}
public function addToArray() {
this.myArray.push(10);
this.myArray
14 matches
Mail list logo