Flex4学习笔记(二)--语法相关
1.数组的使用
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function application1_initializeHandler(event:FlexEvent):void
{
var array2:Array = new Array("1","22","333","4444");
var array3:Array = ["pp","qq"];
text1.text = array1[2];
text2.text = array2[3];
text3.text = array3[1];
}
]]>
</fx:Script>
<fx:Declarations>
<fx:Array id="array1">
<fx:String>aa</fx:String>
<fx:String>bb</fx:String>
<fx:String>cc</fx:String>
</fx:Array>
</fx:Declarations>
<s:TextInput id="text1" x="111" y="146"/>
<s:TextInput id="text2" x="111" y="192"/>
<s:TextInput id="text3" x="111" y="237"/>
2.定义方法中使用可变参数
<fx:Script>
<![CDATA[
protected function func1(...arg):void
{
for each(var str:String in arg)
{
text1.text += str + " ,";
}
}
protected function button1_clickHandler(event:MouseEvent):void
{
func1("aa","bb","cc","dd");
}
]]>
</fx:Script>
<s:Button x="539" y="132" label="按钮" click="button1_clickHandler(event)"/>
<s:TextInput id="text1" x="35" y="132" width="489"/>

浙公网安备 33010602011771号