如何更改不同类的数组值? 我在一个名为creation
的类中进行了数组所有数组都是全局变量
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);
}
}
,第二个类是addClass 我想通过它来改变数组的值
定义代码
var MyArrays:creation = new creation
var first1:Array = creation.first1;
creation.first1 = first1;
答案 0 :(得分:1)
你可以专门为你的阵列设一个课程
public class MyArrays { private var _first1:Array = []; public function set first1(value:Array ):void { _first1 = value; } public function get first1():Array { return _first1; } //etc.... }
当您需要在任何类中编辑数组时,您可以执行此操作
var myArrays:MyArrays = new MyArrays var first1:Array = myArrays.first1; //edit your array , then update the value in your external class myArrays.first1 = first1;
答案 1 :(得分:0)
我无法理解你在问什么,但是......
为什么不创建一个包含四个属性的类first
op
second
和res
,并创建它的四个实例?