Hi Mike
Actually what I want is the arrays to be private but flash is making
them static. 

But I just discovered that by initializing the array in the constructor
fixes the problem.



The code below makes the array static for all the instances. It
shouldn't so it is a bug.

class One(){
        private var arr:Array=[];
}



But doing this makes the array behaves as expected:

class One(){
        private var arr:Array;

        function One(){
                arr=new Array();
        }
}


Sebastian


> -----Original Message-----
> From: Mike Pearce [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, 21 July 2004 10:23 AM
> To: Flash Developers List
> Subject: [fugli] Re: Mysterious shared array
> 
> Hey Sebastian,
> 
> Mark them as static if you want the one array to be shared across all
> instances.
> 
> private static var myArray:Array = [1,2,3];
> 
> =) Mike
> 
> Mike Pearce
> [EMAIL PROTECTED]
> http://www.nectarine.com.au
> 
> 
> 
> ----- Original Message -----
> From: "Sebastian Porto" <[EMAIL PROTECTED]>
> To: "Flash Developers List" <[EMAIL PROTECTED]>
> Sent: Wednesday, July 21, 2004 9:09 AM
> Subject: [fugli] Mysterious shared array
> 
> 
> 
> Hi all
> I have a problem when using arrays in my classes
> I don't know why the arrays are being shared between multiple
instances
> of a class even if I declare them as private. Below is a simple
example.
> Any help is much appreciated.
> 
> Thanks
> Sebastian
> 
> //in One.as:
> class One{
> private var arr:Array=[0];
> 
> public function One(){
> arr[0]++;
> trace(arr[0]);
> }
> }
> 
> 
> 
> //In a fla file:
> o1=new One();
> o2=new One();
> o3=new One();
> 
> stop();
> 
> 
> //output:
> 1
> 2
> 3
> 
> 
> ---
> You are currently subscribed to fugli as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
[EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/
> 
> 
> 
> ---
> You are currently subscribed to fugli as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
[EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/



---
You are currently subscribed to fugli as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to