日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Net与Flex入门

發布時間:2023/12/4 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Net与Flex入门 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
開源項目FluorineFx就是專門針對.NET平臺與Flex通信提供的AMF(ActionScript Message Format)協議通信網關,我們可以通過FluorineFx很方便的完成與.NET的通信。 另外還可以輕松的實現及時文字溝通、視頻語音通信等及時交互系統的開發。

?????FluorineFx官方提供了安裝包的下載和在線文檔,可以幫助我們有效的利用FluorineFx來開發。?

?????FluroineFx官方網站:http://www.fluorinefx.com/????

?????FluroineFx下載地址:http://www.fluorinefx.com/download.html

?????FluroineFx在線文檔:http://www.fluorinefx.com/docs/fluorine/index.html

?

一、服務端的開發

??? 1、通過Microsoft Visual Studio 2008 創建創建解決方案,并添加FluroineFx服務器庫

??????? ?路徑:E:\FlexDemo\FlexDemoTest1\ServiceLibrary1

??? 2、添加FluorineFx 網站到解決方案,添加成功后網站會自動引用FluorineFx服務庫的dll

???????? 路徑:E:\FlexDemo\FlexDemoTest1\WebSite1

????3、結構如下:??

?

?4、代碼如下:

?

namespace ServiceLibrary1
{
??? /// <summary>
??? /// Fluorine sample service.
??? /// </summary>
??? [RemotingService("Fluorine sample service")]
??? public class Sample
??? {
??????? public Sample()
??????? {
??????? }

??????? public string Echo(string text)
??????? {
??????????? return "Gateway echo: " + text;
??????? }
??????? public Contact GetContact()
??????? {
??????????? Contact c = new Contact { Name = "Fred", Email = "fred@example.com", Phone = "555-1212" };
??????????? return c;
??????? }
??????? public FluorineFx.AMF3.ArrayCollection GetContacts()
??????? {
??????????? FluorineFx.AMF3.ArrayCollection result =
??????????????? new FluorineFx.AMF3.ArrayCollection{
??????????????????? new Contact { Name = "Fred", Email = "fred@example.com", Phone = "555-1212" },
??????????????????? new Contact { Name = "Jane", Email = "jane@example.com", Phone = "555-1213" },
??????????????????? new Contact { Name = "Bob", Email = "bob@example.com", Phone = "555-1214" }};

??????????? return result;
??????? }
??????? /// <summary>

??????? /// 獲取服務端的系統時間

??????? /// </summary>

??????? /// <returns></returns>

??????? public string GetServerTime()
??????? {

??????????? return DateTime.Now.ToString();

??????? }

??????? public ArrayCollection GetBooks()
??????? {
??????????? ArrayCollection array = new ArrayCollection();
??????????? array.Add(new Book(1, "三國演義", "羅貫中", 100.00));
??????????? array.Add(new Book(2, "西游記", "吳承恩", 200.00));
??????????? array.Add(new Book(3, "水滸傳", "施耐庵", 300.00));
??????????? array.Add(new Book(4, "紅樓夢", "曹雪芹", 400.00));
??????????? return array;
??????? }
??? }

??? [FluorineFx.TransferObject]
??? public class Book
??? {
??????? public int ID { get; set; }
??????? public string Name { get; set; }
??????? public string Author { get; set; }
??????? public double Price { get; set; }
??????? public Book()
??????? { }
??????? public Book(int id, string name, string author, double price)
??????? {
??????????? this.ID = id;
??????????? this.Name = name;
??????????? this.Author = author;
??????????? this.Price = price;
??????? }

??? }


}

?

二、客戶端開發

?? 1、首先創建Flex項目

???????Project location? Floder設置為:E:\FlexDemo\FlexDemoTest1\WebSite1\flex4

???????Application type設置為:Web application,Application

???2、??? Flex項目創建完畢,下面在通過一些相應的配置就可以通過FluorineFx和.NET通信了。開發項目屬性設置面板,設置

????Flex?? Complier:? ?-locale en_US -services "..\..\WEB-INF\flex\services-config.xml"? -context-root "/WebSite1"

??? Flex Build Path:

???????????????? output folder url:http://localhost:7217/WebSite1/flex4/bin-debug(注意路徑大小寫)

?? 3、代碼如下

?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
?<mx:RemoteObject id="service" destination="fluorine"
???? source="ServiceLibrary1.Sample">
???????? <mx:method name="Echo" result="onResult1(event)">
???????? </mx:method>
?</mx:RemoteObject>

?????
????? <mx:Script>
???????? <![CDATA[
??????????? import mx.rpc.events.ResultEvent;
??????????? import mx.collections.ArrayCollection;
??????????? import mx.controls.List;
??????????? import mx.rpc.events.FaultEvent;
??????????? import mx.rpc.events.ResultEvent;
??????????? private var nc:NetConnection;
??????????? private var rs:Responder;
??????????? private var rs1:Responder;
??????????? private function init():void
??????????? {
??????????????? nc = new NetConnection();
??????????????? rs = new Responder(onResult,onStatus);
??????????????? rs1=new Responder(onResult1,onStatus);
??????????????? nc.objectEncoding = ObjectEncoding.AMF3;
??????????????? nc.connect("http://localhost:7217/WebSite1/Gateway.aspx");
??????????????? nc.client = this;
??????????? }
??????????? private function onResult(result:String):void
??????????? {
??????????????? this.lbServerTime.text = "服務端系統時間為:" + result;
??????????? }
??????????? private function onStatus(event:Object):void
??????????? {
??????????????? trace("Error");
??????????? }
??????????? private function getServerTime(event:MouseEvent):void
??????????? {
??????????????? //服務器端所提供的RemotingService的全限定名
??????????????? nc.call("ServiceLibrary1.Sample.GetServerTime",rs);
??????????? }

???????? internal function onClick():void
???????? {
???????????? service.Echo(txtInput.text);
??????????
???????? }
?????????
????????? internal function onResult1(evt:ResultEvent):void
???????? {
???????????? txtResult.text = evt.result.toString();
???????? }

???????? ]]>
???? </mx:Script>
????
???? <mx:Panel x="53" y="52" width="473" height="361" layout="absolute" title="FluorineFx" fontSize="12">
???????? <mx:TextInput x="35" y="21" id="txtInput"/>
???????? <mx:Button x="35" y="63" label="確 定" fontWeight="normal" click="onClick()"/>
???????? <mx:Label x="35" y="95" text="結 果:"/>
???????? <mx:TextInput x="35" y="123" width="160" id="txtResult"/>
???????? <mx:Button x="35" y="176" label="獲取服務器系統時間" click="getServerTime(event)"/>
???????? <mx:Label x="23" y="249" width="402" id="lbServerTime"/>
???????? <mx:Button x="237" y="125" label="Button"/>


???? </mx:Panel>
????
</mx:Application>

?

?

轉載于:https://www.cnblogs.com/yidianfeng/archive/2011/11/02/2233029.html

總結

以上是生活随笔為你收集整理的Net与Flex入门的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。