这一段时间工作太慢了, 都快半年没更新了,

最近一至在做一个Flex的项目, 用到了图片的幻灯片效果, 在网上搜了好久, 也没有找到一个有帮助的结果,

于是只好自己研究了 --!

经过两个多小时的试验,终于小有成就, 现将阶段性代码发表出来, 方便有同样需求的人借鉴(不要再像我一样,浪费N多时间用于搜索)

 

 

 

<?xml version="1.0" encoding="utf-8"?>  
<!-- ************************************************************
* 版权:XingFuStudio
*
* 文件名:ImageEffect
* 文件功能描述:图片的幻灯片播放效果
*
* 作者:XingFuStar
* 网站:Http://XingFuStar.cnblogs.com
* 日期:2009年2月20日
*
* 当前版本:V1.0.0

* 修改人:
* 修改日期:
* 修改内容:
************************************************************* 
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" 
    creationComplete
="InitApp()">
    
    
<mx:Script>
        
<![CDATA[
            import mx.controls.Alert;
            import mx.events.FlexEvent;
            import mx.effects.*;
            import mx.collections.ArrayCollection;
            
            //效果集合,用来绑定Image
            [Bindable]
            private var effects:ArrayCollection = new ArrayCollection();
            //应用效果的索引
            [Bindable]
            private var effectIndex:int = 0;
            //图片集合
            private var pictures:ArrayCollection = new ArrayCollection();
            //时间控件
            private var timer:Timer;
            //这个变量用来配合时间控件
            private var tempInt:int = 0;
            
            /**
             * 初始化
             */
            private function InitApp():void
            {
                //初始化效果集合
                this.effects.addItem(new WipeDown());
                this.effects.addItem(new WipeLeft());
                this.effects.addItem(new WipeRight());
                this.effects.addItem(new WipeUp());
                //this.Effects.addItem(new Blur()); //这个一般,效果不明显
                this.effects.addItem(new Dissolve());
                this.effects.addItem(new Fade());
                //this.Effects.addItem(new Glow()); //只默认的情况下,没有较果
                this.effects.addItem(new Iris());
                //this.Effects.addItem(new Move()); //只默认的情况下,没有较果
                //this.Effects.addItem(new Resize()); //只默认的情况下,没有较果
                //this.Effects.addItem(new Rotate()); //旋转的,效果不是很好
                this.effects.addItem(new Zoom());
                
                //初始化图片集合
                this.pictures.addItem("../images/1.jpg");
                this.pictures.addItem("../images/2.jpg");
                this.pictures.addItem("../images/3.jpg");
                this.pictures.addItem("../images/4.jpg");
                this.pictures.addItem("../images/5.jpg");
                this.pictures.addItem("../images/6.jpg");
                this.pictures.addItem("../images/7.jpg");
                this.pictures.addItem("../images/8.jpg");
                
                //初始化时间控件
                this.timer = new Timer(2 * 1000 , 0.0);
                //添加时间控件的计时事件
                this.timer.addEventListener(TimerEvent.TIMER, OnTimerTick);
                //启动时间控件
                this.timer.start();
                
                //this.imageUp.addEventListener(Event.COMPLETE
            }
            
            /**
             * 时间控件事件方法
             */
            private function OnTimerTick(event:TimerEvent):void
            {
                
                if(this.tempInt == 0)
                {
                    //当TempInt为0时
                    //随机生成一个图片索引, 更新上层的图片
                    var ramdomNumber:Number=GetRandNumber(0, this.pictures.length - 1);
                    this.imageUp.source = this.pictures.getItemAt(ramdomNumber);
                }
                else
                {
                    //计算下一张图应用的效果, 同时更新下层的图片与上层的图片相同
                    //这里为什么用两个Image原因是: 当用一个Image时,更新图片的过程中, 会出现闪烁
                    //两个Image,其中一个用来更新显示,另一个用来缓存上一次加载的图片
                    this.effectIndex = GetRandNumber(0, this.effects.length - 1);
                    this.imageDown.source = this.imageUp.source;
                }    
                
                //计算下次时间控件循环时,tempInt的值, tempInt值为 0 或 1
                this.tempInt = (this.tempInt + 1) % 2;            
            }
            
            /**
             * 获取指定范围内的随机数(包括最大值最小值)
             * 
             * @param min 最小值
             * @param max 最大值
             */
            private function GetRandNumber(min:Number, max:Number):Number 
            {
                var randNumber:Number = Math.floor(Math.random() * (max - min + 1)) + min;
                
                return randNumber;
            }
        
]]>
    
</mx:Script>
    
    
    
    
<mx:Image id="imageDown" width="640" height="480" source="../images/1.jpg"/>
    
<mx:Image id="imageUp" width="640" height="480" source="../images/1.jpg"
        completeEffect
="{this.effects.getItemAt(effectIndex)}"/>
</mx:Application>
        

 

版权:htpp://xingfustar.cnblogs.com 

 

这里使用了两个Image, 其中ImageUp用来显示带效果的图片, IamgeDown作用是用来缓存上一张图片, 目的是防止用单一Image时图片更换时闪烁一下

posted @ 2009-02-21 21:10 幸福★星 阅读(364) | 评论 (0)编辑

看了好多Flex的Message相关的例子, 基本上都要用到FDS.SWC, 在网上找了N久, 费尽力气,好不容易找到了一个100多M的包, 从中找出FDS.SWC现提供下载

FDS.SWC 下载

posted @ 2008-08-15 11:52 幸福★星 阅读(379) | 评论 (1)编辑
最新版的FluorinFx在services-config.xml中新增了RTMP Channel,主要是用来配置Flex Messaging,编译时需要FDS.swc支持,当然如果不需要此功能可以注释掉channel-definition这个节点

posted @ 2008-03-23 14:24 幸福★星 阅读(625) | 评论 (0)编辑
要求: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 幸福★星 阅读(287) | 评论 (0)编辑
     摘要: 版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月14日六、自定义实体对象的传递(http://xingfustar.cnblogs.com/)本节是Remoting通讯的最后一节,主要讲述自定义实体对象的传递,并简单了解下Flex中类的声明及DataGrid的使用方法。我们仍分两个部分来讲。1、.NET服务器端程序(ht... 阅读全文
posted @ 2007-12-14 16:54 幸福★星 阅读(726) | 评论 (2)编辑
     摘要: 版权由http://xingfustar.cnblogs.com/所有,转载请注明出处,XingFuStar 2007年12月14日五、复杂数据类型的通讯(http://xingfustar.cnblogs.com/)Remoting支持传送数组、List、HashTable、Dictionary等多种复杂数据类型,本文以数组,Dictionary,HashTable为例,讲解复杂数据类型的通讯。... 阅读全文
posted @ 2007-12-14 13:34 幸福★星 阅读(601) | 评论 (0)编辑

版权由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 幸福★星 阅读(732) | 评论 (1)编辑

版权由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 幸福★星 阅读(1381) | 评论 (4)编辑
第三个读写配置类,使用的是注册表,由于以前没使用过注册表做为配置文件来读写,所以该类比较初级,只是按自己想法所写,有何不足请批评指教

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 幸福★星 阅读(126) | 评论 (0)编辑
     摘要: 刚写完读XML配置的类,突发奇想,想写一个不调用API来读INI文件的类,经过一点点努力,终于实现了,现将代码帖出。http://xingfustar.cnblogs.com/*----------------------------------------------------------------*版权:http://XingFuStar.cnblogs.com**文件名:IniConfi... 阅读全文
posted @ 2007-09-13 16:57 幸福★星 阅读(411) | 评论 (0)编辑