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.push(20);
    }
} // end class

Run your code again, I think it'll execute the way you're expecting it to at
that point...

Peace...
 
--
Dok
Skyymap, Inc.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Judah
Frangipane
Sent: Thursday, December 29, 2005 3:30 PM
To: Flashcoders mailing list
Subject: [Flashcoders] Flash Class Array bug - Please verify

It seems like Flash is creating static members out of public arrays that 
are initialized in the class declaration. Can someone confirm this? Is 
this not legal, is it implied behavior or a bug?

// create a class called myClass
class myClass {
    // initialize the array in the declarations
    var myArray:Array = new Array();

    function myClass {
       trace("myArray.length="+myArray.length)
    }

    function addToArray() {
       myArray.push(10)
       myArray.push(20)
    }

}


// on the actions frame
import myClass

var a = new myClass();
a.addToArray();
a.addToArray();
a.addToArray();
var b = new myClass();

// trace outputs
myArray.length=0
myArray.length=3

Judah
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to