宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > Flex技术

[Flex]Flex数组的使用及定义方法中使用可变参数代码示例

2016-10-13 00:16:48 点击量:10 标签: 收藏本文

1.数组的使用

  1. <fx:Script> 
  2.     <![CDATA[ 
  3.         import mx.events.FlexEvent; 
  4.   
  5.         protected function application1_initializeHandler(event:FlexEvent):void 
  6.         { 
  7.             var array2:Array = new Array("1","22","333","4444"); 
  8.             var array3:Array = ["pp","qq"]; 
  9.               
  10.             text1.text = array1[2]; 
  11.             text2.text = array2[3]; 
  12.             text3.text = array3[1]; 
  13.         } 
  14.   
  15.     ]]> 
  16. </fx:Script> 
  17. <fx:Declarations> 
  18.     <fx:Array id="array1"> 
  19.         <fx:String>aa</fx:String> 
  20.         <fx:String>bb</fx:String> 
  21.         <fx:String>cc</fx:String> 
  22.     </fx:Array> 
  23. </fx:Declarations> 
  24. <s:TextInput id="text1" x="111" y="146"/> 
  25. <s:TextInput id="text2" x="111" y="192"/> 
  26. <s:TextInput id="text3" x="111" y="237"/> 

2.定义方法中使用可变参数

  1. <fx:Script> 
  2.     <![CDATA[ 
  3.         protected function func1(...arg):void 
  4.         { 
  5.             for each(var str:String in arg) 
  6.             { 
  7.                 text1.text += str + " ,"; 
  8.             } 
  9.         } 
  10.   
  11.         protected function button1_clickHandler(event:MouseEvent):void 
  12.         { 
  13.             func1("aa","bb","cc","dd"); 
  14.         } 
  15.   
  16.     ]]> 
  17. </fx:Script> 
  18.   
  19. <s:Button x="539" y="132" label="按钮" click="button1_clickHandler(event)"/> 
  20. <s:TextInput id="text1" x="35" y="132" width="489"/> 

 

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室