学习真就那么难吗

我是一只小小鸟!

2008年3月23日 #

解决使用FluorineFx实现Remoting通讯时 报 "Channel definition, mx.messaging.channels.RTMPChannel, can not be found" 错的问题

最新版的FluorinFx在services-config.xml中新增了RTMP Channel,主要是用来配置Flex Messaging,编译时需要FDS.swc支持,当然如果不需要此功能可以注释掉channel-definition这个节点

posted @ 2008-03-23 14:24 幸福★星 阅读(149) | 评论 (0)编辑

2008年1月10日 #

[转载]Flex 2.0 实现SWF全屏

要求:FlashPlayer版本为version 9,0,28,0或更高

1:在flex中拖一个Button到场景, 设置: id="mybtn" click="fullScreen(event)"

2:定义fullScreen方法:
import flash.display.StageDisplayState; 
private function fullScreen(event:MouseEvent):void{    
       
if (stage.displayState == StageDisplayState.FULL_SCREEN)  
       {  
           mybtn.label 
= "全屏模式";  
           stage.displayState 
= StageDisplayState.NORMAL;  
       }  
       
else  
       {  
           mybtn.label 
= "返回全屏";  
           stage.displayState 
= StageDisplayState.FULL_SCREEN; 
       }      
  }
3:如果使用原html模板装载,修改html-template文件夹下的index.template.html
a:在下面三处地方增加:
AC_FL_RunContent(  "allowFullScreen", "true",  ) 
<param name="allowFullScreen" value="true" /> 
          
  
<embed src="fullScreen.swf" allowFullScreen="true"  > 
b:在下面三处地方删除:
AC_FL_RunContent(  "allowscrīptAccess", "sameDomain",  ) 
<param name="allowscrīptAccess" value="sameDomain" /> 
         
  
<embed src="fullScreen.swf" allowscrīptAccess="sameDomain"  >


作者:猫大哥   类型:闪吧BBS   来源:闪吧论坛


posted @ 2008-01-10 13:38 幸福★星 阅读(136) | 评论 (0)编辑

2007年12月14日 #

[原创]Flex 与 Asp.Net 通过 Remoting 方式进行通讯 (四)

     摘要: 版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月14日六、自定义实体对象的传递(http://xingfustar.cnblogs.com/)本节是Remoting通讯的最后一节,主要讲述自定义实体对象的传递,并简单了解下Flex中类的声明及DataGrid的使用方法。我们仍分两个部分来讲。1、.NET服务器端程序(ht...  阅读全文

posted @ 2007-12-14 16:54 幸福★星 阅读(233) | 评论 (0)编辑

[原创]Flex 与 Asp.Net 通过 Remoting 方式进行通讯 (三)

     摘要: 版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月14日五、复杂数据类型的通讯(http://xingfustar.cnblogs.com/)Remoting支持传送数组、List、HashTable、Dictionary等多种复杂数据类型,本文以数组,Dictionary,HashTable为例,讲解复杂数据类型的通讯。...  阅读全文

posted @ 2007-12-14 13:34 幸福★星 阅读(241) | 评论 (0)编辑

2007年12月10日 #

[原创]Flex 与 Asp.Net 通过 Remoting 方式进行通讯 (二)

版权由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日

posted @ 2007-12-10 17:01 幸福★星 阅读(244) | 评论 (0)编辑

2007年12月7日 #

[原创]Flex 与 Asp.Net 通过 Remoting 方式进行通讯 (一)

版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月10日

一、准备工作 (http://xingfustar.cnblogs.com/)
  
  Flex开发平台:Adobe Flex Builder 2.0.1
  .Net开发平台:Visual Studio.Net 2005
  Remoting网关:Fluorine (下载 Part1 Part2

二、创建项目 (http://xingfustar.cnblogs.com/)


1、创建.NET项目 (http://xingfustar.cnblogs.com/)

    分别安装以上三个软件,在安装好Fluorine之后,自动在.Net 2005新建网站中增加一个模板:Fluorine ASP.NET Web Application。
    
    选择该模板,创建一个.NET网站
    
    a)打开Visual Studio 2005,分别选择 文件 -> 新建 -> 网站
    b)选择已安装模板“Fluorine ASP.NET Web Application”,为了便于演式,位置选择文件系统,指定项目文件夹,单击 确定
        .NET Project
    c)运行项目,获取.NET自带服务器生成的端口,及网址,本项目中是 http://localhost:1884/RemotingSample/

2、创建Flex项目 (http://xingfustar.cnblogs.com/)

    a)打开Flex Builder,分别选择 File -> New -> Flex Project
    b)在打开的“New Flex Project”界面中,选择“ColdFusion Flash Remotion Service”,单击 Next
            Create a Flex Project


    c)新的界面中“Root folder”指向.Net项目所在的文件夹;“Root URL”这里与.NET创建项目相关,运行.NET项目时的网址是什么,这里就写什么,在本例中,网址为:http://localhost:1884/RemotingSample/ 因此,Root URL就填写该网址,设置完成单击 Next
        Create a Flex Project
    d)在新的界面中填写“Project Name”,“Folder”可以使用默认或自己指定,单击 Next
        Create a Flex Project
    e)在新的界面中需要修改“Output Folder”项, 将其指向.Net项目所在的文件夹下的“Flex”文件夹(如果不存在,创建它),单击 Finish 
        

    到此所有的准备工作全部结束,接下来我们将开始Remoting之旅

FAQ:(http://xingfustar.cnblogs.com/)

    一、安装完Fluorine之后,只能创建Web网站,如何创建Web Application项目?
        
首先必须安装.NET 2005 SP1,创建一个新的ASP.NET Web应用程序,将用Fluorine创建的Web网站中的:Bin文件夹、WEB-INF文件夹、log文件夹、log4net.configWeb.config、Console.aspxConsole.aspx.csGateway.aspxGateway.aspx.cs拷贝到项目文件夹下,添加com.TheSilentGroup.Fluorine.dllcom.TheSilentGroup.Fluorine.ServiceBrowser.dlllog4net.dll的引用即可  

    二、使用.NET文件系统,如果运行端口改变,或者.NET项目位置、Flex项目位置改变,Flex中该如何处理

        选择 Project -> Properties , 在弹出的界面中左侧选择 “Flex Server” 修改右边的Root folder 和Root URL, 左侧选择 “Flex Build Path” 修改右边的 Output folder

版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月10日

posted @ 2007-12-07 09:17 幸福★星 阅读(413) | 评论 (2)编辑

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

posted @ 2007-09-14 12:43 幸福★星 阅读(78) | 评论 (0)编辑

2007年9月13日 #

[原创]C#不调用API读写INI文件类

     摘要: 刚写完读XML配置的类,突发奇想,想写一个不调用API来读INI文件的类,经过一点点努力,终于实现了,现将代码帖出。http://xingfustar.cnblogs.com/*----------------------------------------------------------------*版权:http://XingFuStar.cnblogs.com**文件名:IniConfi...  阅读全文

posted @ 2007-09-13 16:57 幸福★星 阅读(213) | 评论 (0)编辑

[原创]简单的XML配置文件读写类

以前读写配置都用INI文件,现在写一个读写XML的类,功能比较简单

http://xingfustar.cnblogs.com

我的问题是如何能得到根节点的名字,而不是像现在这样写死为“Configuration"。希望大家多多讨论,提出宝贵意见

/*----------------------------------------------------------------
 * 版权:
http://XingFuStar.cnblogs.com
 * 
 * 文件名: XmlConfig
 * 文件功能描述: 简单的XML配置文件读写类
 * 
 * 作者:XingFuStar
 * 日期:2007年9月13日
 * 
 * 当前版本:V1.0.0
 * 
 * 修改日期:
 * 修改内容:
 *---------------------------------------------------------------
*/


/*----------------------------------------------------------------
 * 相关的XML文件模版

<?xml version="1.0" encoding="utf-8"?>
<Configuration>
    <Section1>
        <Key1>Value</Key1>
        
        <KeyN>Value</KeyN>
    </Section1>
    
    <SectionN>
        <Key1>Value</Key1>
        
        <KeyN>Value</KeyN>
    </SectionN>
</Configuration>
 *----------------------------------------------------------------
*/


using System;
using System.Xml;
using System.Diagnostics;


namespace XingFuStudio.Config
{
    
class XmlConfig
    {
        
private string xmlPath;
        
private bool isConfig;
        
private XmlDocument xmlDocument;

        
        
/// <summary>
        
/// 构造函数:装载配置文件
        
/// </summary>
        
/// <param name="xmlPath">配置文件的路径</param>
        public XmlConfig(string xmlPath)
        {
            
//请不要删除以下信息
            
//版权:http://XingFuStar.cnblogs.com

            
this.xmlDocument = new XmlDocument();
            
this.XmlPath = xmlPath;
        }

        
/// <summary>
        
/// Xml配置文件的路径
        
/// </summary>
        public string XmlPath
        {
            
set
            {
                xmlPath 
= value;
                isConfig 
= OnXmlPathChange();
            }
        }

        
/// <summary>
        
/// 读取配置
        
/// </summary>
        
/// <param name="section">节点</param>
        
/// <param name="key"></param>
        
/// <param name="value">返回的键值</param>
        
/// <returns>键值</returns>
        
/// <returns>是否读取成功</returns>
        public bool ReadConfig(string section, string key, ref string value)
        {
            
bool isRead = false;
            
try
            {
                
if (isConfig)
                {
                    value 
= xmlDocument.SelectSingleNode("Configuration").SelectSingleNode(section).SelectSingleNode(key).InnerText;
                    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 isWrited = false;
            
try
            {
                
if (isConfig)
                {
                    xmlDocument.SelectSingleNode(
"Configuration").SelectSingleNode(section).SelectSingleNode(key).InnerText = value;
                    xmlDocument.Save(xmlPath);
                    isWrited 
= true;
                }
            }
            
catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
            
return isWrited;
        }

        
#region 私有方法
        
private bool OnXmlPathChange()
        {
            
bool isLoaded = false;
            
try
            {
                xmlDocument.Load(xmlPath);
                isLoaded 
= true;
            }
            
catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
            
return isLoaded;
        }
        
#endregion
    }

}

posted @ 2007-09-13 13:32 幸福★星 阅读(305) | 评论 (0)编辑

2007年9月10日 #

VB 6.0 利用CopyMemory实现 指针功能

工作需要,要用VB写一个接口程序,其中要把浮点型转成Byte数组,用到了一个API,先记录下来,以后C#中可能会用到同样的功能。

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As LongByVal Source As LongByVal Length As Long)

浮点转换Byte函数

Private Function FloatToBytes(value As SingleAs Byte()
    
Dim returnByte(4As 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 ByteAs 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

posted @ 2007-09-10 13:44 幸福★星 阅读(369) | 评论 (1)编辑