国产黄色免费网站,人人干人人干人人干,免费大黄网站在线看,国产情侣一区二区三区,99精品国产福利免费一区二区,国产亚洲成归v人片在线观看,伊人88

2023信創(chuàng)獨角獸企業(yè)100強
全世界各行各業(yè)聯(lián)合起來,internet一定要實現(xiàn)!

Flash MX 2004新特性實例學習四

2004-02-12 eNet&Ciweek

  實例五、News Reader

  一、涉及特性

  本實例主要涉及數(shù)據(jù)綁定和組件的編程。數(shù)據(jù)綁定是在Flash MX 2004中才有的新功能,據(jù)稱不用編程,只需設(shè)置幾個組件的屬性,就可以實現(xiàn)與服務(wù)器端的數(shù)據(jù)交互功能,也算是一大突破了。另外,由于在實例中沒有提供相應(yīng)的xml文件,所有字段都要手工輸入,所以本實例的制作過程顯得有些繁瑣,請在制作過程中仔細檢查每一個字段。

  二、制作過程

  1、從組件面板中拖一個List組件到場景中,命名為“articles”,設(shè)置“multipleSelection”為false,“rowHight”為20。

  2、從組件面板中拖一個TextArea組件到場景中,命名為“title”,各種參數(shù)設(shè)置不變。

  3、從組件面板中拖一個Label組件到場景中,命名為“author”,設(shè)置“text”為空。

  4、從組件面板中拖兩個TextArea組件到場景中,分別命名為“desc”和“l(fā)ink”,都設(shè)置“text”為空。

  5、從組件面板中拖一個XMLConnector組件到場景中,命名為“feed”,設(shè)置參數(shù)如下:“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”,設(shè)置“formatter”為“Rearrange Field”,設(shè)置“formatter option”為“l(fā)abel='< creator>: < title>'”。

  13、同樣在“feed”的Bingdings面板,點擊“Add Bindings”按鈕,添加一個“results.RDF.item.[n].title”字段,點擊“Bound to”按鈕,在彈出的對話框中選取“Text Area< title>”,設(shè)置“Index of item”為articles : selected Index。

  14、點擊“Add Bindings”按鈕,添加一個“results.RDF.item.[n].link”字段,點擊“Bound to”按鈕,在彈出的對話框中選取“Text Area< link>”,設(shè)置“Index of item”為articles : selected Index。

  15、點擊“Add Bindings”按鈕,添加一個“results.RDF.item.[n].creator”字段,點擊“Bound to”按鈕,在彈出的對話框中選取“Text< author>”,設(shè)置“Index of item”為articles : selected Index。

  16、點擊“Add Bindings”按鈕,添加一個“results.RDF.item.[n].description”字段,點擊“Bound to”按鈕,在彈出的對話框中選取“Text Area< desc>”,設(shè)置“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開始通訊。

  三、實際用途

  本實例主要涉及的是數(shù)據(jù)綁定功能,用途相當廣泛,主要用來與服務(wù)器端的數(shù)據(jù)交互。以前相對繁瑣的編程實現(xiàn),現(xiàn)在只要設(shè)定幾個組件的屬性即可實現(xiàn)相應(yīng)的功能。注意本實例中只涉及在Flash端的實現(xiàn),沒有涉及在服務(wù)器端的實現(xiàn)。

  另外,7-11步可以通過導(dǎo)入一個xml文件來實現(xiàn),但系統(tǒng)提供的幫助文件中沒有相應(yīng)的xml文件,只能手工輸入,因此顯得有點復(fù)雜。

  

相關(guān)頻道: eNews

您對本文或本站有任何意見,請在下方提交,謝謝!

投稿信箱:tougao@enet16.com