2008年3月23日
#
最新版的FluorinFx在services-config.xml中新增了RTMP Channel,主要是用来配置Flex Messaging,编译时需要FDS.swc支持,当然如果不需要此功能可以注释掉channel-definition这个节点
2008年1月10日
#
2007年12月14日
#
摘要: 版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月14日六、自定义实体对象的传递(http://xingfustar.cnblogs.com/)本节是Remoting通讯的最后一节,主要讲述自定义实体对象的传递,并简单了解下Flex中类的声明及DataGrid的使用方法。我们仍分两个部分来讲。1、.NET服务器端程序(ht...
阅读全文
摘要: 版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月14日五、复杂数据类型的通讯(http://xingfustar.cnblogs.com/)Remoting支持传送数组、List、HashTable、Dictionary等多种复杂数据类型,本文以数组,Dictionary,HashTable为例,讲解复杂数据类型的通讯。...
阅读全文
2007年12月10日
#
版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月11日
三、简单数据类型通讯(http://xingfustar.cnblogs.com/)
学习一门语言,大多以Hello Word开始,我们也以Hello Word为例, 讲解一下Flex 与 Asp.Net 通过 Remoting 方式通讯的方法。
1、.NET服务器端程序(http://xingfustar.cnblogs.com/)
在新建的.NET网站的 App_Code文件夹下,Sample.cs 文件,这是由模板为我们创建的。我们可以防照它,在 App_Code下新建一个 RemotingSample.cs文件,
接下来我们编写一个 HelloWord 函数
public string HelloWord()
{
return "Hello Word!";
}
.NET 端工作暂时告一段落, 接下来我们来试计Flex端
2、Flex客户端程序(http://xingfustar.cnblogs.com/)
在 Design 模式下,添加一个 Text文本控件,id为txtHelloWord,txt属性为空,添加一个 Button控件,id为btnHelloWord,Label属性为 HelloWord
在 Source 模式下,加入如下代码
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
public function RemoteResult(re:ResultEvent):void
{
var str:String = re.result as String;
this.txtHelloWord.text = str;
}
public function RemoteFault(re:FaultEvent):void
{
Alert.show("Message:" + re.fault.faultString,"出错");
}
]]>
</mx:Script>
<!--这里Source 对应.NET类,前面是命名空间,后面是类名 source = 命名空间.类名-->
<mx:RemoteObject
id="sampleRemoteObject"
destination="fluorine"
source="RemotingSample.RemotingSample"
showBusyCursor="true">
<!--这里是.NET中的方法,name = 方法名 -->
<mx:method name="HelloWord" result="RemoteResult(event)" fault="RemoteFault(event)"/>
</mx:RemoteObject>
在
mx:Button 标签中添加属性
click="sampleRemoteObject.HelloWord()"
运行Flex程序,在浏览器中查看效果
四、带参数的通讯
(http://xingfustar.cnblogs.com/)
有了上面的基础,我们进行下扩展,做一个稍稍复杂些,带参数的方法:
1、.NET服务器端程序
(http://xingfustar.cnblogs.com/)
在.NET服务器端,RemotingSample类中添加一个新的方法:
public string SayHello(string name)
{
return "Hello " + name + "!";
}
2、Flex客户端程序
(http://xingfustar.cnblogs.com/)
在 Design 模式下添加,添加一个 Text文本控件,id为txtSayHello,txt属性为空,添加一个 Button控件,id为btnSayHello,Label属性为 SayHello,添加一个Label,text属性为name:,添加一个
TextInput, id为txtName
在 Source 模式下, 修改
mx:RemoteObject 标签,添加
<mx:method name="SayHello" result="RemoteResult(event)" fault="RemoteFault(event)"/>
修改脚本中 RemoteResult 方法,代码如下
public function RemoteResult(re:ResultEvent):void
{
switch(re.currentTarget.name)
{
case "HelloWord":
var str:String = re.result as String;
this.txtHelloWord.text = str;
break;
case "SayHello":
str = re.result as String;
this.txtSayHello.text = str;
break;
}
}
在 mx:Button (SayHello) 标签中添加属性 click="sampleRemoteObject.SayHello(this.txtName.tex)"
运行Flex程序,在浏览器中查看效果 
附件:完整代码 (http://xingfustar.cnblogs.com/)
1、.NET端代码
/*----------------------------------------------------------------
* 版权:http://XingFuStar.cnblogs.com
*
* 文件名: RemotingSample
* 文件功能描述: .NET与Flex通讯DEMO
*
* 作者:XingFuStar
* 日期:2007年12月11日
*
* 当前版本:V1.0.0
*
* 修改日期:
* 修改内容:
*---------------------------------------------------------------*/
using System;
using com.TheSilentGroup.Fluorine;
using System.Collections.Generic;
namespace RemotingSample
{
[RemotingService("Fluorine sample service")]
public class RemotingSample
{
public RemotingSample()
{
//请不要删除以下信息
//版权:http://XingFuStar.cnblogs.com
}
public string HelloWord()
{
return "Hello Word!";
}
public string SayHello(string name)
{
return "Hello " + name + "!";
}
}
}
2、Flex端MXML代码
<?xml version="1.0" encoding="utf-8"?>
<!--
* 版权:http://XingFuStar.cnblogs.com
*
* 作者:XingFuStar
* 日期:2007年12月11日
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
public function RemoteResult(re:ResultEvent):void
{
switch(re.currentTarget.name)
{
case "HelloWord":
var str:String = re.result as String;
this.txtHelloWord.text = str;
break;
case "SayHello":
str = re.result as String;
this.txtSayHello.text = str;
break;
}
}
public function RemoteFault(re:FaultEvent):void
{
Alert.show("Message:" + re.fault.faultString,"出错");
}
]]>
</mx:Script>
<!--这里Source 对应.NET类,前面是命名空间,后面是类名 source = 命名空间.类名-->
<mx:RemoteObject
id="sampleRemoteObject"
destination="fluorine"
source="RemotingSample.RemotingSample"
showBusyCursor="true">
<!--这里是.NET中的方法,name = 方法名 -->
<mx:method name="HelloWord" result="RemoteResult(event)" fault="RemoteFault(event)"/>
<mx:method name="SayHello" result="RemoteResult(event)" fault="RemoteFault(event)"/>
</mx:RemoteObject>
<mx:Text x="38" y="25" id="txtHelloWord"/>
<mx:Button x="38" y="51" label="HelloWord" id="btnHelloWord0" click="sampleRemoteObject.HelloWord()"/>
<mx:Text x="38" y="105" id="txtSayHello"/>
<mx:Label x="38" y="131" text="name:"/>
<mx:TextInput x="88" y="129" id="txtName"/>
<mx:Button x="256" y="129" label="SayHello" id="btnSayHello" click="sampleRemoteObject.SayHello(this.txtName.text)"/>
</mx:Application>
本节完成!
FAQ:
一、为什么我在Flex下运行了程序,打开的页面连不上.NET
查看打开页面的地址,是以“File”开头,还是以“HTTP”开头,想通过Remoting连接,生成的SWF必须运行在服务器模式下,而不是文件模式
版权由
http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月11日
2007年12月7日
#
2007年9月14日
#
第三个读写配置类,使用的是注册表,由于以前没使用过注册表做为配置文件来读写,所以该类比较初级,只是按自己想法所写,有何不足请批评指教
http://xingfustar.cnblogs.com
/*----------------------------------------------------------------
* 版权:http://XingFuStar.cnblogs.com
*
* 文件名: IniConfig
* 文件功能描述: 读写注册表中的配置
*
* 作者:XingFuStar
* 日期:2007年9月14日
*
* 当前版本:V1.0.0
*
* 修改日期:
* 修改内容:
*---------------------------------------------------------------*/
/*----------------------------------------------------------------
*
* 默认注册表键为:HKEY_LOCAL_MACHINE\Software
* 示意图如下:
*
* HKEY_LOCAL_MACHINE |
* -Software | Key1 Value1
* --程序项(SoftwareName) | 
* ---子项(Section) | KeyN ValueN
*
*---------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Diagnostics;
namespace XingFuStudio.Config
{
class RegConfig
{
private string softwareName;
private bool isConfig;
RegistryKey registryKey;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="softwareName">程序名称:对应注册表中Software项下的程序项</param>
public RegConfig(string softwareName)
{
//请不要删除以下信息
//版权:http://XingFuStar.cnblogs.com
this.SoftwareName = softwareName;
}
/// <summary>
/// 程序名称:对应注册表中Software项下的程序项
/// </summary>
public string SoftwareName
{
set
{
softwareName = value;
isConfig = OnSoftwareNameChange();
}
}
/// <summary>
/// 读取配置
/// </summary>
/// <param name="section">程序项下的子项</param>
/// <param name="key">键</param>
/// <param name="value">返回的键值</param>
/// <returns>是否读取成功</returns>
public bool ReadConfig(string section, string key, ref string value)
{
bool isRead = false;
try
{
if (isConfig)
{
RegistryKey skey = this.registryKey.OpenSubKey(section);
if (skey != null)
{
value = skey.GetValue(key).ToString();
isRead = true;
}
}
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
return isRead;
}
/// <summary>
/// 写入配置
/// </summary>
/// <param name="section">程序项下的子项</param>
/// <param name="key">键</param>
/// <param name="value">写入的键值</param>
/// <returns>是否写入成功</returns>
public bool WriteConfig(string section, string key, string value)
{
bool isWrite = false;
try
{
if (isConfig)
{
RegistryKey skey = this.registryKey.OpenSubKey(section, true);
if (skey != null)
{
skey.SetValue(key, value);
isWrite = true;
}
else //如果不存在该键则创建
{
skey = this.registryKey.CreateSubKey(section);
skey.SetValue(key, value);
isWrite = true;
}
}
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
return isWrite;
}
#region 私有方法
private bool OnSoftwareNameChange()
{
bool isLoad = false;
try
{
//打开该项
registryKey = Registry.LocalMachine.OpenSubKey("Software\\" + softwareName, true);
if (registryKey == null)
{
//如果不存在则创建该项
registryKey = Registry.LocalMachine.CreateSubKey("Software\\" + softwareName);
}
isLoad = true;
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
return isLoad;
}
#endregion
}
}
http://xingfustar.cnblogs.com
2007年9月13日
#
摘要: 刚写完读XML配置的类,突发奇想,想写一个不调用API来读INI文件的类,经过一点点努力,终于实现了,现将代码帖出。http://xingfustar.cnblogs.com/*----------------------------------------------------------------*版权:http://XingFuStar.cnblogs.com**文件名:IniConfi...
阅读全文
2007年9月10日
#
工作需要,要用VB写一个接口程序,其中要把浮点型转成Byte数组,用到了一个API,先记录下来,以后C#中可能会用到同样的功能。
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)
浮点转换Byte函数
Private Function FloatToBytes(value As Single) As Byte()
Dim returnByte(4) As Byte
Dim sPtr As Long, bPtr As Long
sPtr = VarPtr(value)
bPtr = VarPtr(returnByte(1))
CopyMemory bPtr, sPtr, 4
FloatToBytes = returnByte
End Function
Byte转换浮点函数
Private Function BytesToFloat(bytes() As Byte) As Single
Dim returnValue As Single
Dim sPtr As Long, bPtr As Long
sPtr = VarPtr(returnValue)
bPtr = VarPtr(bytes(1))
CopyMemory sPtr, ByVal bPtr, 4
BytesToFloat = returnValue
End Function