views:

24

answers:

2

How do I change the values of arrays from different classes? i've array in one class called creation

all the array are global variable

 import addClass;

                    public var first1:Array = new Array();
        public var op:Array = new Array();
        public var second:Array = new Array();
        public var res:Array = new Array();
       public function creation() {
       for (i= 0 ; i<= 4; i++)
        {       first1[i]= createCustomTextField(100,(i*40),50,30);
                op[i]= createCustomTextField(160,(i*40),50,30);
                second[i]= createCustomTextField(220,(i*40),50,30);
                res[i]= createCustomTextField(280,(i*40),50,30);
                        }
        }

and the second class is addClass and i want to change the value of the arrays thru it

the definition code

                    var MyArrays:creation = new creation
        var first1:Array = creation.first1;
        creation.first1 = first1;
A: 

I can't really understand what you are asking, but...

Why not create a class with four properties, first op second and res, and create four instances of it?

spender
please check the edited post again
Maged
+1  A: 

You could have a class specifically for your Arrays

public class MyArrays
{

    private var _first1:Array = [];

    public function set first1(value:Array ):void
    {
        _first1 = value;
    }

    public function get first1():Array
    {
        return _first1;
     }

    //etc....
}

When you need to edit an Array , in any class , you would do this


var myArrays:MyArrays = new MyArrays
var first1:Array = myArrays.first1;

//edit your array , then update the value in your external class
myArrays.first1 = first1;

PatrickS
thanks for reply ,but how can i change the arrays value from another class ????
Maged
check the edited answer
PatrickS
thanks it's work now
Maged