Flash MX 2004新特性实例学习四
时间:2009-6-2 11:44:36 作者: 来源:
 

    实例五、news reader

  一、涉及特性

  本实例主要涉及数据绑定和组件的编程。数据绑定是在flash mx 2004中才有的新功能,据称不用编程,只需设置几个组件的属性,就可以实现与服务器端的数据交互功能,也算是一大突破了。另外,由于在实例中没有提供相应的xml文件,所有字段都要手工输入,所以本实例的制作过程显得有些繁琐,请在制作过程中仔细检查每一个字段。

  二、制作过程

  1、从组件面板中拖一个list组件到场景中,命名为“articles”,设置“multipleselection”为false,“rowhight”为20。

  2、从组件面板中拖一个textarea组件到场景中,命名为“title”,各种参数设置不变。

  3、从组件面板中拖一个label组件到场景中,命名为“author”,设置“text”为空。

  4、从组件面板中拖两个textarea组件到场景中,分别命名为“desc”和“link”,都设置“text”为空。

  5、从组件面板中拖一个xmlconnector组件到场景中,命名为“feed”,设置参数如下:“url”为“http://www.macromedia.com/go/devnet_rss”,“direction”为receive。

  6、用文本工具在场景中输入几处文字,此时的效果如图1所示。

  7、选取“feed”组件,选取“component inspector”中的schema面板,在results字段下面增加如下的子字段:field name为rdf,data type为object,storage type为complex。

  8、在rdf字段下面增加如下的子字段:a、field name为xmlns,data type为string,storage type为attribute;b、field name为dc,data type为string,storage type为attribute;c、field name为rdf,data type为string,storage type为attribute;d、fieldname为channel,data type为object,storage type为complex;e、field name为item,data type为array,storage type为array。

  9、在channel字段下面增加如下的子字段:a、field name为about,data type为string,storage type为attribute;b、field name为title,data type为string,storage type为simple;c、field name为link,data type为string,storage type为simple;d、field name为description,data type为string,storage type为simple;e、field name为date,data type为string,storage type为simple;f、field name为language,data type为string,storage type为simple;g、field name为items,data type为object,storage type为complex。

  10、在channel字段的items子字段下面增加子字段:field name为seq,data type为object,storage type为complex;在seq字段下面增加子字段:field name为li,data type为array,storage type为array;在li字段下面增加子字段:field name为[n],data type为int,storage type为simple;在[n]字段下面增加子字段:field name为resource,data type为string,storage type为attribute。

  11、回到rdf字段下面,在item字段下面增加如下子字段:field name为[n],data type为object,storage type为complex;在[n]字段下面增加如下的子字段:a、field name为about,data type为string,storage type为attribute;b、field name为title,data type为string,storage type为simple;c、field name为link,data type为string,storage type为simple;d、field name为description,data type为string,storage type为simple;e、field name为creator,data type为string,storage type为simple;f、field name为subject,data type为string,storage type为simple;g、field name为date,data type为string,storage type为simple;h、field name为type,data type为string,storage type为simple。此时的schema面板如图2所示。

  12、选取“feed”组件,选取“component inspector”中的bindings面板,点击“add bindings”按钮,添加一个“results.rdf.item”字段,点击“bound to”按钮,在弹出的对话框中选取“list”,设置“formatter”为“rearrange field”,设置“formatter option”为“label='< creator>: < title>'”。

  13、同样在“feed”的bingdings面板,点击“add bindings”按钮,添加一个“results.rdf.item.[n].title”字段,点击“bound to”按钮,在弹出的对话框中选取“text area< title>”,设置“index of item”为articles : selected index。

  14、点击“add bindings”按钮,添加一个“results.rdf.item.[n].link”字段,点击“bound to”按钮,在弹出的对话框中选取“text area< link>”,设置“index of item”为articles : selected index。

  15、点击“add bindings”按钮,添加一个“results.rdf.item.[n].creator”字段,点击“bound to”按钮,在弹出的对话框中选取“text< author>”,设置“index of item”为articles : selected index。

  16、点击“add bindings”按钮,添加一个“results.rdf.item.[n].description”字段,点击“bound to”按钮,在弹出的对话框中选取“text area< desc>”,设置“index of item”为articles : selected index。此时的bindings面板如图3所示。

  17、在time line中增加一层,命名为action,在此层的action面板上增加下面的语句:   

  /* copyright 2003 macromedia, inc. all rights reserved.

  the following is sample code and is subject to all restrictions

  on such code as contained in the end user license agreement

  accompanying this product.

  */

  function bindingexecuted() {

  articles.selectedindex = 0;

  articles.refreshdestinations();

  }

  articles.addeventlistener("bindingexecuted", this);

  feed.trigger();

  上面这些语句是为articles组件增加侦听鼠标动作的语句,让feed开始通讯。

  三、实际用途

  本实例主要涉及的是数据绑定功能,用途相当广泛,主要用来与服务器端的数据交互。以前相对繁琐的编程实现,现在只要设定几个组件的属性即可实现相应的功能。注意本实例中只涉及在flash端的实现,没有涉及在服务器端的实现。

  另外,7-11步可以通过导入一个xml文件来实现,但系统提供的帮助文件中没有相应的xml文件,只能手工输入,因此显得有点复杂。
 

上一篇:
下一篇:
 
网页模板 网站模板 网站建设 网页设计 网页设计师兼职 自助建站 ...
网站魔坊,网页模板,网站模板,免费网页模板,在线模板设计,免费建站,门户网站搭建,建站,企业网站,奇思网络,奇思,智能建站,自助建站,拖动建站,网站建设,网页设计,在线设计模板
www.wzmof.com/ 47K 2009-5-21
 
商巢...
商巢是一个真实的商业交友社区、为用户提供交友、贸易、社区、建站等服务;临渊慕鱼,不如退而结网!商巢结网行动
www.ncooo.com/ 47K 2009-5-21
 
商巢创业 门户创业 商人网络家园 魔坊建站 商业交友
商巢下的门户,门户又一独立实体与商巢合作,由商巢负责技术的更新以及硬件的支持,门户负责自己领域的市场推广以及相应的售后服务即可。 打破以往门户需要源源不断的技术、硬件投入模式,盈利模式清晰 行业门户以及门户下企业网站由网站魔坊...
mhcy.ncooo.com/ 36K 2009-5-14
 
奇思网络技术 网站建设 深圳网站建设
中小外贸企业做电子商务,需要从两点技术突围 08-01 企业网站建设 提供网站策划、网站建设、数据库开发至网络营销全套解决方案。能针对客户所处行业,结合营销特征量身订做高质量网站建设方案。 网站推广 怎样使网站的投资得到回报?这需要经验...
www.qsnet.com.cn/ 48K 2009-4-2
 
深圳艺术网
深圳艺术网,中国艺术网,中国当代艺术网,广东当代艺术网,广东艺术网,南方当代艺术网,深圳美术网,深港美术网,深港艺术网,深港当代艺术网,杜应红,深圳当代艺术创作库,深圳创库,深圳美术,深圳艺术,深圳收藏,深圳艺术收藏,深圳音乐网,深圳舞蹈...
www.szarts.cn/ 119K 2009-6-9
 
网页设计也通过人脉赚钱-技术传播
 
网页设计114 -打造中国网页设计、网站建设技术信息学习、交流、互动平台
                         打造网页设计师兼职创业平台中心