FluorineFx Sample (blogMp3)

FluorineFx实现remotion ,messaging 和data services, ,

FluorineFx要注意的是net 和as3之间的数据交互.

as3的 array 对应的net 是IList

as3的 object 对应的net是hashtable

还有就是可以把as3的一个类传到net中,也会转成net的一个类,你需要在net里的web.config里增加一个classmap节点.

<classMappings>
   <classMapping>
    <type>SampleClassNet</type>
    <customClass>SampleClassAS</customClass>
   </classMapping>
  </classMappings>

做了个例子,管理音乐数据的,flash + net + access

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Data.OleDb;
using FluorineFx;
using System.Collections;
using System.Diagnostics; 

namespace MP3Library
{
    /// <summary></summary>
    /// Fluorine sample service.
    /// 
    [RemotingService("Mp3DataManager")]
    public class Mp3DataManager
    {
        public Mp3DataManager()
        {
        }

        public string Echo(string text)
        {
            return "Gateway echo: " + text;
        }

        private string strconn = "Provider=Microsoft.Jet.OleDb.4.0;Data source="+System.Web.HttpContext.Current.Server.MapPath("database/data.mdb");
        private OleDbConnection conn;

        public IList getData()
        {
            checkConn();
            string sql = "select * from mp3";
            OleDbCommand mycommand = new OleDbCommand(sql, conn);
            OleDbDataReader myread = mycommand.ExecuteReader();
            ArrayList list = new ArrayList();
            while (myread.Read())
            {
                Hashtable tb = new Hashtable();
                tb.Add("id",myread["id"]);
                tb.Add("author",myread["author"]);
                tb.Add("name", myread["name"]);
                tb.Add("url", myread["url"]);
                list.Add( tb ) ;
            }
            myread.Close();
            return list.ToArray();
        }

        public int addItem(Hashtable tb)
        {
            checkConn();
            string sql = "Insert into mp3(author,name,url) Values('" + tb["author"] + "','" + tb["name"] + "','" + tb["url"] + "')";
            OleDbCommand mycommand = new OleDbCommand(sql, conn);
            //返回增加的行数
            return mycommand.ExecuteNonQuery();
        }

        public int editItem(Hashtable tb)
        {
            checkConn();
            string sql = "UPDATE mp3 SET author='" + tb["author"] + "', name='" + tb["name"] + "', url='" + tb["url"] + "' WHERE id=" + Convert.ToInt32(tb["id"]) + "";
            Debug.WriteLine(sql);
            OleDbCommand mycommand = new OleDbCommand(sql, conn);
            //返回增加的行数
            return mycommand.ExecuteNonQuery();
        }

        public int delItem(String i)
        {
            checkConn();
            string sql = "DELETE FROM mp3 WHERE id=" + i + "";
            OleDbCommand mycommand = new OleDbCommand(sql, conn);
            //返回增加的行数
            return mycommand.ExecuteNonQuery();
        }


        private void checkConn()
        {
            if (conn == null)
            {
                conn = new OleDbConnection(strconn);
                conn.Open();
            }
        }
    }
}
flash端只要
nc.call('MP3Library.Mp3DataManager.getData',new Responder(getDataResult,getDataFault));
server 下载
client 下载
阅读更多
上一篇Haxe学习(1)
下一篇Windows XP 正版验证补丁V3
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭