- 浏览: 1045474 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (538)
- 奇文共赏 (36)
- spring (13)
- hibernate (10)
- AOP/Aspectj (9)
- spring security (7)
- lucence (5)
- compass (3)
- jbmp (2)
- jboss rule(drools) (0)
- birt (1)
- jasper (1)
- cxf (3)
- flex (98)
- webgis (6)
- 设计模式 (1)
- 代码重构 (2)
- log4j (1)
- tomcat (9)
- 神品音乐 (1)
- 工作计划 (2)
- appfuse (1)
- svn (4)
- 寻章摘句 (3)
- eclipse (10)
- arcgis api for flex (1)
- 算法 (5)
- opengis-cs (1)
- bug心得 (13)
- 图标 (1)
- software&key (14)
- java (17)
- 搞笑视频 (13)
- sqlserver (9)
- postgresql (1)
- postgis (0)
- geoserver (5)
- 日子 (50)
- 水晶报表 (1)
- 绝对电影 (3)
- Alternativa3D (1)
- 酷站大全 (10)
- c++ (5)
- oracle (17)
- oracle spatial (25)
- flashbuilder4 (3)
- TweenLite (1)
- DailyBuild (6)
- 华山论贱 (5)
- 系统性能 (5)
- 经典古文 (6)
- SOA/SCA/OSGI (6)
- jira (2)
- Hadoop生态圈(hadoop/hbase/pig/hive/zookeeper) (37)
- 风水 (1)
- linux操作基础 (17)
- 经济 (4)
- 茶 (3)
- JUnit (1)
- C# dotNet (1)
- netbeans (1)
- Java2D (1)
- QT4 (1)
- google Test/Mock/AutoTest (3)
- maven (1)
- 3d/OSG (1)
- Eclipse RCP (3)
- CUDA (1)
- Access control (0)
- http://linux.chinaunix.net/techdoc/beginner/2008/01/29/977725.shtml (1)
- redis (1)
最新评论
-
dove19900520:
朋友,你确定你的标题跟文章内容对应???
tomcat控制浏览器不缓存 -
wussrc:
我只想说牛逼,就我接触过的那点云计算的东西,仔细想想还真是这么 ...
别样解释云计算,太TM天才跨界了 -
hw_imxy:
endpoint="/Hello/messagebr ...
flex+java代码分两个工程 -
gaohejie:
rsrsdgrfdh坎坎坷坷
Flex 与 Spring 集成 -
李涤尘:
谢谢。不过说得有点太罗嗦了。
Oracle数据库数据的导入及导出(转)
http://joshblog.net/2007/05/08/methods-to-filter-data-with-e4x-in-flash-9/
ActionScript 3 in Flash 9 includes powerful support for reading and manipulating XML. It's called E4X, and it gives us developers some useful new syntax. Read on for a super quick introduction to E4X followed by some powerful ways to filter your data using this feature.
E4X is powered by the new XML and XMLList classes. The most common way to declare a variable of one of these types is to pass it and XML string. However, many developers might miss the fact that you can declare XML directly within your classes or ActionScript code. It's supported natively by the compiler.
SWITCH TO PLAIN TEXT
Actionscript:
E4X lets you drill down into the data to get the information you need without any excessive looping or strange calls to parent and child nodes. The following example gets a list of all the item names defined in the XML from the previous example. Notice that the name attribute is specified with the "@" symbol at the beginning.
SWITCH TO PLAIN TEXT
Actionscript:
To take it a step further, you can filter the same set of data to find items with "Amazon" defined as the source value. Place a statement within the parentheses to check for a specific value. In this case, we check to see if an item's source is equal to a string value.
SWITCH TO PLAIN TEXT
Actionscript:
Interestingly enough, you can place just about any ActionScript statement within the parentheses. In the following example, I've included a trace statement to display each item's name in the console. I find this particularly useful for debugging.
SWITCH TO PLAIN TEXT
Actionscript:
You can filter by multiple fields as well. This example filters items from Amazon with a price under $400.00.
SWITCH TO PLAIN TEXT
Actionscript:
Let's take it a step further. Say that your application filters items by source, like in the example where we only wanted items from Amazon. However, the filtering is controlled by the user through a ComboBox or another user interface component. E4X will let you compare attributes or children against a variable as well!
SWITCH TO PLAIN TEXT
Actionscript:
Please note that you must be sure the variable name is different than the name of the child. If I had named my variable source, instead of sourceName, the statement within the parentheses would never access the item's source value because it would always use the variable. In exact terms, (source == source) most definitely won't work!
Let's make things a little more interesting. What happens if the name of the value by which we're filtering should be dynamic as well? In the previous examples, we've accessed attributes directly, but you can call functions on the XML object too. Here, we call the attribute() to get an attribute's value by its name. This will also work for the child function.
SWITCH TO PLAIN TEXT
Actionscript:
Finally, let's finish with something a little complex. Say the application's interface allows the user to filter across multiple fields, but each field is optional. We can do that too, but not directly through E4X (as far as I know; please prove me wrong!). This example shows how to filter by items from Amazon that cost exactly $599.99, but the fields Array could contain any number of items with additional items to filter by.
SWITCH TO PLAIN TEXT
Actionscript:
I'm sure you can think of interesting ways to expand on that last example to create some very powerful filtering systems. In this particular case, I've only checked for equality, but with some simple changes to the logic, you could check for prices greater than or less than a certain value, or you could even search for substrings within a value. For instance, you might want to search for "PlayStation", and include results for PS2 and PS3 systems. E4X is very, very powerful.
Update: I've written two followup articles:
ActionScript 3 in Flash 9 includes powerful support for reading and manipulating XML. It's called E4X, and it gives us developers some useful new syntax. Read on for a super quick introduction to E4X followed by some powerful ways to filter your data using this feature.
E4X is powered by the new XML and XMLList classes. The most common way to declare a variable of one of these types is to pass it and XML string. However, many developers might miss the fact that you can declare XML directly within your classes or ActionScript code. It's supported natively by the compiler.
SWITCH TO PLAIN TEXT
Actionscript:
var data:XML = <items> <item name="Wii"> <source>Amazon</source> <price>364.00</price> </item> <item name="Wii"> <source>Target</source> <price>249.99</price> </item> <item name="X-Box 360"> <source>Amazon</source> <price>399.99</price> </item> <item name="PlayStation 3"> <source>Amazon</source> <price>599.99</price> </item> </items>;
E4X lets you drill down into the data to get the information you need without any excessive looping or strange calls to parent and child nodes. The following example gets a list of all the item names defined in the XML from the previous example. Notice that the name attribute is specified with the "@" symbol at the beginning.
SWITCH TO PLAIN TEXT
Actionscript:
var itemNames:XMLList = data.item.@name;
To take it a step further, you can filter the same set of data to find items with "Amazon" defined as the source value. Place a statement within the parentheses to check for a specific value. In this case, we check to see if an item's source is equal to a string value.
SWITCH TO PLAIN TEXT
Actionscript:
var amazonItems:XMLList = data.item.(source == "Amazon");
Interestingly enough, you can place just about any ActionScript statement within the parentheses. In the following example, I've included a trace statement to display each item's name in the console. I find this particularly useful for debugging.
SWITCH TO PLAIN TEXT
Actionscript:
data.item.(trace(@name));
You can filter by multiple fields as well. This example filters items from Amazon with a price under $400.00.
SWITCH TO PLAIN TEXT
Actionscript:
var items:XMLList = data.item.(source == "Amazon" && price <400);
Let's take it a step further. Say that your application filters items by source, like in the example where we only wanted items from Amazon. However, the filtering is controlled by the user through a ComboBox or another user interface component. E4X will let you compare attributes or children against a variable as well!
SWITCH TO PLAIN TEXT
Actionscript:
var sourceName:String = "Target"; var itemNames:XMLList = data.item.(source == sourceName);
Please note that you must be sure the variable name is different than the name of the child. If I had named my variable source, instead of sourceName, the statement within the parentheses would never access the item's source value because it would always use the variable. In exact terms, (source == source) most definitely won't work!
Let's make things a little more interesting. What happens if the name of the value by which we're filtering should be dynamic as well? In the previous examples, we've accessed attributes directly, but you can call functions on the XML object too. Here, we call the attribute() to get an attribute's value by its name. This will also work for the child function.
SWITCH TO PLAIN TEXT
Actionscript:
var filterBy:String = "name"; var filterValue:String = "Wii"; var items:XMLList = data.item.(attribute(filterBy) == filterValue);
Finally, let's finish with something a little complex. Say the application's interface allows the user to filter across multiple fields, but each field is optional. We can do that too, but not directly through E4X (as far as I know; please prove me wrong!). This example shows how to filter by items from Amazon that cost exactly $599.99, but the fields Array could contain any number of items with additional items to filter by.
SWITCH TO PLAIN TEXT
Actionscript:
var filtered:XMLList = data.item; var fields:Array = [{name: "source", value: "Amazon"}, {name: "price", value: "599.99"}]; var fieldCount:int = fields.length; for(var i:int = 0; i <fieldCount; i++) { var fieldName:String = fields[i].name; var fieldValue:String = fields[i].value; filtered = filtered.(child(fieldName) == fieldValue); }
I'm sure you can think of interesting ways to expand on that last example to create some very powerful filtering systems. In this particular case, I've only checked for equality, but with some simple changes to the logic, you could check for prices greater than or less than a certain value, or you could even search for substrings within a value. For instance, you might want to search for "PlayStation", and include results for PS2 and PS3 systems. E4X is very, very powerful.
Update: I've written two followup articles:
发表评论
-
ActionScript 3.0 性能优化小知识
2010-07-30 14:12 1032http://xinsync.xju.edu.cn/in ... -
Flex企业级UI权限控制
2010-07-28 16:14 1302http://www.pin5i.com/showtopic- ... -
flex4中PopUpManager在module中有问题
2010-06-24 11:10 3142flex4中module加载module后flex4中 a ... -
Flex 开发: 类的反射
2010-06-24 10:56 1269http://www.ibm.com/developerwor ... -
Problems with ByteArray.writeObject()
2010-05-19 21:47 1725http://www.actionscript.org/for ... -
利用 E4X解决 XML 处理的性能问题
2010-05-19 21:11 1752http://www.blogjava.net/rosen/a ... -
正在安装的adobe flash player版本不是最新的版本
2010-04-22 09:56 2457打开注册表编辑器,定位到HKEY_LOCAL_MACHINE\ ... -
AS3 优化 之 FOR内循环
2010-02-10 15:39 1564写游戏只要有思路,就能实现,但这也只是从功能角度出发,能不能有 ... -
flex模块切换时导致对象不正确序列化的解决办法
2009-12-02 09:08 1628http://lkfnn.iteye.com/blog/506 ... -
漂亮的登陆
2009-11-19 16:32 1160http://dougmccune.com/360Flex_A ... -
Download all 177 Flash Effects Source Files .fla
2009-11-13 09:27 1223http://www.jeffjoneslive.com/Fl ... -
flex如何接受其他页面Post过来的数据
2009-10-10 11:15 2558问题描述: 有个程序需要调用我的flex页面,需要给我传 ... -
Change font size in the whole app with Ctrl+/-
2009-10-09 10:06 1202http://feedproxy.google.com/~r/ ... -
flex delete关键词和类成员
2009-10-09 09:01 1409flash中delete关键词用来移除定义的变量,并不能从内存 ... -
Flex HTTPService如何给后台传递参数
2009-10-09 08:56 1525http://blog.csdn.net/joeyshi/ar ... -
FLEX Builder compiler arguments 的设置
2009-09-28 08:20 1656http://flash.9ria.com/thread-18 ... -
12 Best Adobe AIR Applications for Web Designers
2009-09-25 08:20 107812 Best Adobe AIR Applications ... -
做网页如何改变IE地址栏的显示IE图标
2009-09-23 16:55 2701这个问题的解决其实在flex之外 修改index.templa ... -
Flex设置html(页面标题)title问题
2009-09-23 15:31 3287如果你是一个整体系统用了同一个标题:可以修改模板页index. ... -
flex中文问题,访问中文路径问题
2009-09-23 14:36 1202本文最先发表在本人个 ...
相关推荐
To really harness the power of Flash though, you need to make use of ActionScript to provide dynamic effects, enable user interaction, and manipulate data. ActionScript 3.0, the latest version of ...
After learning how to install and becoming familiar with the basics of the Flex Builder 2 software, you will explore in depth how ActionScript 3.0 interacts with Flexs powerful XML-like design ...
在ActionScript 3.0中,加载外部资源是常见的需求,特别是加载图片,这对于创建动态内容、交互式应用或者富媒体展示来说至关重要。本篇文章将深入探讨如何在ActionScript 3.0中加载外部图像,即Loader类的使用。 1....
本书是国内第一本“面向原因式”(Why-Oriented Book)、全面系统介绍Flash ActionScript 3的书籍。全书共分为5个部分。第一部分:ActionScript 3语言基础;第二部分:ActionScript 3 面向对象编程;第三部分:...
After learning how to install and becoming familiar with the basics of the Flex Builder 2 software, you will explore in depth how ActionScript 3.0 interacts with Flexs powerful XML-like design ...
After learning how to install and becoming familiar with the basics of the Flex Builder 2 software, you will explore in depth how ActionScript 3.0 interacts with Flexs powerful XML-like design ...
ActionScript3是Adobe Flash平台的核心编程语言,用于创建交互式内容、富互联网应用程序(RIA)以及游戏。这个“ActionScript3中文手册”是为开发者提供的一份详细文档,旨在帮助他们理解和掌握ActionScript3的基本...
as3 pdf下载 ActionScript 3.0 是一种强大的面向对象编程语言,它标志着 Flash Player Runtime 演化过程中的一个重要阶段。设计 ActionScript 3.0 的意图是创建一种适合快速地构建效果丰富的互联网应用程序的语言,...
《深入学习ActionScript 2.0在Flash中的应用》 一、ActionScript 2.0概览 ActionScript 2.0是Adobe Flash平台的一种强大脚本语言,它为动画和交互式媒体提供了丰富的功能。在Flash软件中,ActionScript 2.0使...
AS3标签则表明内容将重点讨论ActionScript 3与XML的结合,包括E4X的使用。 **知识点概览:** 1. **XML基础**:书籍可能会介绍XML的基本语法,如元素、属性、命名空间、文档类型定义(DTD)和XML Schema。 2. **...
《ActionScript设计模式》是软件开发领域中针对ActionScript编程语言的一种实践指南,它深入探讨了如何在ActionScript项目中应用经典的设计模式。设计模式是软件工程中的宝贵经验总结,它们是解决常见问题的可复用...
《Flash ActionScript3殿堂之路》共分5个部分。第1部分:ActionScript 3语言基础;第2部分:ActionScript 3面向对象编程;第3部分:ActionScript 3 核心类;第4部分:ActionScript 3主要的Flash Player API;第5部分...
在深入探讨ActionScript 3类型转换的精妙之前,我们先来回顾一下ActionScript脚本语言,这是一种广泛应用于Adobe Flash平台的编程语言,主要用于创建动态交互式内容、游戏以及动画等。随着版本的演进,ActionScript...
ActionScript 3.0 是一种基于ECMAScript for XML (E4X) 的脚本语言,主要用于Adobe Flash Platform,包括Flash Player和Adobe AIR。它在2006年随着Flash Player 9一同发布,带来了显著的性能提升、类型检查以及面向...
```actionscript3 import flash.display.MovieClip; import flash.display.Stage; var popup:MovieClip = new PopupMC(); popup.x = stage.stageWidth / 2; popup.y = stage.stageHeight / 2; stage.addChild(popup...
- **E4X表达式**:E4X使得ActionScript可以直接操作XML数据,如同操作普通的JavaScript对象一样。通过简单的表达式就可以实现对XML数据的读取、修改等操作。 #### 三、在Flash和Flex中利用XML构建动态Web应用 ...
ActionScript 是针对 Adobe Flash Player 运行时环境的编程语言,它在 Flash 内容和应用 程序中实现了交互性、数据处理以及其它许多功能。 ActionScript 是由 Flash Player 中的 ActionScript 虚拟机 (AVM) 来执行的...
《Flex4声明在ActionScript中的应用》 Flex4框架是Adobe Flex的一个重要版本,它引入了许多新特性,尤其是在ActionScript编程中的声明式编程方式。这一技术显著提升了开发效率,使得开发者能够更直观地定义UI组件和...