[as3]as3中forEach用法实例
对数组里的元素逐个进行操作,实际改变了数组(不同于map)
[as3]as3中forEach用法实例:对数组里的元素逐个进行操作,实际改变了数组(不同于map)
- public function Sample1008()
- {
- //在每个玩家名字前面加上公会名称
- var player1:Object = {name:"wayne",level:70,repute:100};
- var player2:Object = {name:"tom",level:70,repute:190};
- var player3:Object = {name:"jacky",level:70,repute:50};
- var player4:Object = {name:"andy",level:70,repute:230};
- var player5:Object = {name:"bill",level:70,repute:120};
- var playerList:Array = [player1,player2,player3,player4,player5];
- playerList.forEach(BuildName);
- for(var i:int=0; i<playerList.length; i++)
- {
- for(var attr:String in playerList[i])
- {
- trace(attr+":"+playerList[i][attr]);
- }
- }
- }
- private function BuildName(item:*,index:int,arr:Array):void
- {
- item.name = "Cuplayer.com暗界--"+item.name;
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...