-1

Component という名前のクラスがあり、次のようなコードがあります

class Component {

var ID:String;
var typical:String;
var connection:String;
var temperature:String;
var voltage:String;

var visibility:Boolean = true;

public function Component(type:String, temperature:String, connection:String,        voltage:String) {


    this.typical = type;
    this.temperature = temperature;
    this.connection = connection;
    this.voltage = voltage;

}

public function setVisibility(b:Boolean):Void {

    visibility = b;

}

}

Java と同じように、このクラスの配列インスタンスを作成したいと思います (Component[] someComponent = new Component[10] など)。これを Actionscript と定義するにはどうすればよいですか?

4

2 に答える 2

0

Flash Player 10 では、アドビはVectorクラスを追加しました。探している型付き配列です。次のようなベクトルを作成できます。

private var vector:Vector.<SomeComponent> = new Vector.<SomeComponent>(10);
private var anotherOne:Vector.<Number> = new Vector.<Number>;
于 2012-08-25T18:54:34.127 に答える
0

答えてくれてありがとう。別の例かもしれないものを見つけました。のように配列を定義するだけです

var myArray:Array=new Array();

その後、配列の各要素を別のオブジェクトとして定義します。

myArray[0]=new Component(); //Here Component is the class which I defined and showed in my original question.
于 2012-09-03T12:49:05.953 に答える