1.8在MXML中创建数组或对象

1,MXML中创建一维数组:

<mx:Array>
	<String>kevin</String>
	<String>paul</String>
	<String>simon</String>
</mx:Array>

2,MXML 中也可创建二维数组:

<mx:Array>
	<mx:Array>
		<mx:String>boy</mx:String>
		<mx:String>girl</mx:String>
	</mx:Array>
	<mx:Array>
		<mx:String>kevin</mx:String>
	</mx:Array>
</mx:Array>

3,MXML中创建对象(Object)

 可以使用<mx:Object>标签,并添加所有对象的属性及值
<mx:Object id="person" firstName="Kevin" lastName="too" age="24" socialSecurity="123-45-6789"/>

4,同样,在AS中也可以创建这两种类型的数据,并且可以创建更为复杂的object类型:

var
person:Object = {name:"John Smith"
, age:22,
position:{department:"Accounting"
,
salary:50000, title:"Junior
Accountant"
}, id:303};
 

5, AS中两种创建array的方法:

var arr:Array = new Array(”red”, “blue”, “white”, “black”, “green”, “yellow”);
var noConstructorArray:Array = [2, 4, 6, 8, 10, 12, 14, 16];

内容导航

发表评论

:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!: