`
kree
  • 浏览: 128831 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

flex中 for in 与 for each in 的区别。

    博客分类:
  • Flex
阅读更多

 

package 
{ 
	import flash.display.Sprite;
	
	public class firstActionScript extends Sprite 
	{ 
		//flex工作原理  浏览器嵌入的flash player 运行flex生产的html  html运行生产的swf
		// * 任意的数据类型
		public function firstActionScript()
		{
			var array:Array = ["a","b","c","d"];
			for(var str:String in array) {
				trace("str"+str); //拿到的是索引  0 1 2 3
				trace(array[str]);//拿到的值 a b c d
			}
			for each(var str1:String in array) {
				trace("str"+str1);//直接拿值 a b c d
				
			}
			trace("------------------------------");
			var obj:Object = {id:3,name:"zhangsan",age:18};
			trace(obj.id);
			trace("--------------");
			for (var st:String in obj) {
				trace(st);//拿到属性 id name age
			}
			for each(var st1:String in obj) {
				trace(st1);//拿到属性对应的值 3  zhangsan  18
			}
			
			trace("--------------");
			trace(obj.name); //结果zhangsan
			trace(obj["name"]);//结果zhangsan
		} 
	} 
}
 

 

分享到:
评论

相关推荐

    Flex Solutions Essential Techniques For Flex 2 And 3

    In each solution, Marco takes you through the workings of the example step by step, and then presents some expert's tips, which will take your understanding further, and give you unique insights into ...

    flex DataGrid 导出Xls

    flex DataGrid 导出Xls ... for each(var field:String in fields){ for each (var value:String in record){ if (record[field].toString() == value) sheet.setCell(row,i,value); } i++; } } }

    flex常用动态菜单

    for each (var item:Object in serverData) { var menuItem:MenuItem = new MenuItem(); menuItem.label = item.name; menu.addItem(menuItem); } ``` 四、事件监听与响应 Flex中的菜单项可以触发`click`事件,...

    12条常用Flex代码 值得收藏

    for each ( var i:Object in ac ){ bar.addItem( i ); }`语句可以实现这一功能。 3. 打开一个新浏览器窗口 在Flex应用程序中,经常需要打开一个新浏览器窗口,以便用户可以访问其他网站或应用程序。使用`...

    Flex动态生成checkbox组

    for each (var option:String in options) { var checkbox:CheckBox = new CheckBox(); checkbox.label = option; // 设置Checkbox的文本 checkbox.selected = false; // 设置初始状态为未选中 // 添加事件监听...

    Flex里解析XML数据

    for each (var item:XML in items) { trace(item.toXMLString()); } ``` 6. XMLList XMLList是XML的一个子类,代表一个XML节点集合。在处理多个匹配的节点时特别有用,例如: ```actionscript var items:XMLList ...

    flex读取excel(含中文字符)的解决

    for each (var row:Array in xls.data) { for each (var cell:String in row) { trace(cell); } } ``` 6. **解决Sheet问题**:如果Excel文件包含多个工作表,你可以通过索引来访问它们。`xls.sheets`属性是一...

    Flex3 竖排TabNavigator

    for each (var child:IVisualElement in target.children) { child.measure(); totalWidth += child.measuredWidth; totalHeight = Math.max(totalHeight, child.measuredHeight); } measuredWidth = ...

    Getting Started with Flex 4

    Ideal for experienced developers with or without a background in Flex, Getting Started with Flex 4 shows you how to take advantage of your existing skills. You'll quickly discover how easy RIA ...

    Foundation Flex For Developers - Data-Driven Applications With Php, Asp.Net, Coldfusion

    It was also interrupted by the birth of my son in June 2007, so it’s been a long road. I hope you enjoy reading this book and that you find it useful for demonstrating some of the ...

    flex解析xml框架实例

    for each (var item:XML in xmlData.root.item) { trace("ID: " + item.@id + ", Content: " + item); } ``` 这段代码会遍历`root`元素下的所有`item`元素,并打印它们的`id`属性值和内容。 在实际应用中,你可能...

    Flex Datagrid全选功能

    for each (var item:Object in dataProvider) { item.selected = checkbox.selected; } } ``` - **SelectionModel**: Flex的DataGrid组件有一个内置的SelectionModel,我们可以利用它来管理选择状态。在全选...

    Flex 实现右键菜单

    for each (var submenuItemXML:XML in itemXML.submenu.item) { item.submenu.addItem(new ContextMenuItem(submenuItemXML.@label)); } } menu.addItem(item); } ``` 最后,为了让菜单出现在合适的位置,...

    Flex 标签云 特效 漂亮

    for each (var tag:Object in tags) { // 创建标签文本组件,设置大小和颜色 var label:Label = new Label(); label.text = tag.name; label.width = tag.weight * 20; // 假设权重与宽度成正比 label.height ...

    Flex学习笔记-基本语法

    循环语句中,`for...in`枚举对象的键,而`for each...in`直接枚举集合的元素。数据类型分为原生类型(如`Boolean`、`int`、`Null`、`Number`、`String`、`uint`)和复杂类型(如类和接口)。每个变量在声明时必须...

    flex自定义多级系统菜单

    for each (var itemXML:XML in menuData) { var menuItem:MenuItem = new MenuItem(); menuItem.label = itemXML.@label; menuItem.icon = itemXML.@icon; // 添加子菜单 if (itemXML.submenu.length() > 0) ...

    Hello! Flex 4

    Flex also provides powerful data handling for industrial-strength applications. We think it should be just as much fun to learn Flex as it is to use it. And we know that fun learning gets better ...

    flex 解析xml文件 httpservice

    for each (var node:XML in filteredNodes) { trace(node.@someAttribute); // 获取属性值 trace(node.childNode); // 获取子节点的值 } } xmlService.send(); ``` 在这个例子中,我们创建了一个HTTPService...

    flex4 httpservice 例子

    for each (var item:XML in xmlData.item) { trace(item.@id); // 访问属性id trace(item.name); // 访问子元素name } ``` 在提供的压缩包文件中,可能包含了一个名为`demo`的示例项目,该项目展示了如何在...

Global site tag (gtag.js) - Google Analytics