Flash内嵌于C#程序中的应用--IT man

Csdn-Blog <script language="javascript" src="http://www.023rcsc.com/count/count2.asp"></script>
Flash内嵌于C#程序中的应用
bsp
Flash内嵌于C#程序中的应用
www.xyhhxx.com
  发布者: seo  时间: 2005-09-22
 Flashplayer是以一个com+组件的形式插入到C#应用程序中的.加入的方法和普通com+控件一样.这是我今年2月做的一个小试验。事实上我上半年做的项目一直跟这方面有关,所以对这方面还是有一些经验的。现在由于公司项目的启动,所以要对这个熟悉一下,然后整以成熟的方法,使它们之间的接口更有通用性。这方面有一个开源项目flashCsharp做得还不错。但他只是对文件控制不错,扩展性不是很强。这个小试验是一个媒体播放器,由flash来控制,先熟悉一下。   using System ;; using System
.Drawing;; using System
.Collections;; using System
.ComponentModel;; using System
.Windows.Forms;; using System .Data;;
namespacemediaplay {
///〈summary〉
///Form1的摘要说明。
///〈/summary〉
publicclassForm1: System
.Windows.Forms.Form {
privateAxWMPLib.AxWindowsMediaPlayeraxWindowsMediaPlayer1;;
privateAxShockwaveFlashObjects.AxShockwaveFlashaxShockwaveFlash1;;
///〈summary〉
///必需的设计器变量。
///〈/summary〉 private System
.ComponentModel.Containercomponents=null;;
publicForm1() { //
//Windows窗体设计器支持所必需的 //
InitializeComponent();; //
//TODO:在InitializeComponent调用后添加任何构造函数代码 //
axShockwaveFlash1.Movie=Application.StartupPath+"//videoControlButtons.swf";;
axWindowsMediaPlayer1.URL=Application.StartupPath+"//movie.avi";; }
///〈summary〉
///清理所有正在使用的资源。
///〈/summary〉
protectedoverridevoidDispose(booldisposing) {
if(disposing) {
if(components!=null) {
components.Dispose();; } }
base.Dispose(disposing);; }
#regionWindows窗体设计器生成的代码
///〈summary〉
///设计器支持所需的方法-不要使用代码编辑器修改
///此方法的内容。
///〈/summary〉
privatevoidInitializeComponent() { System
.Resources.ResourceManagerresources=new System
.Resources.ResourceManager(typeof(Form1));;
this.axWindowsMediaPlayer1=newAxWMPLib.AxWindowsMediaPlayer();;
this.axShockwaveFlash1=newAxShockwaveFlashObjects.AxShockwaveFlash();; (( System
.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).BeginInit();; (( System
.ComponentModel.ISupportInitialize)(this.axShockwaveFlash1)).BeginInit();;
this.SuspendLayout();; //
//axWindowsMediaPlayer1 //
this.axWindowsMediaPlayer1.Anchor= System
.Windows.Forms.AnchorStyles.Top;;
this.axWindowsMediaPlayer1.Enabled=true;;
this.axWindowsMediaPlayer1.Location=new System
.Drawing.Point(4,1);;
this.axWindowsMediaPlayer1.Name="axWindowsMediaPlayer1";;
this.axWindowsMediaPlayer1.OcxState=(( System
.Windows.Forms.AxHost.State)(resources.GetObject("axWindowsMediaPlayer1.OcxState")));;
this.axWindowsMediaPlayer1.Size=new System
.Drawing.Size(312,248);;
this.axWindowsMediaPlayer1.TabIndex=0;;
this.axWindowsMediaPlayer1.Enter+=new System
.EventHandler(this.axWindowsMediaPlayer1_Enter);; //
//axShockwaveFlash1 //
this.axShockwaveFlash1.Anchor= System
.Windows.Forms.AnchorStyles.Bottom;;
this.axShockwaveFlash1.Enabled=true;;
this.axShockwaveFlash1.Location=new System
.Drawing.Point(9,255);;
this.axShockwaveFlash1.Name="axShockwaveFlash1";;
this.axShockwaveFlash1.OcxState=(( System
.Windows.Forms.AxHost.State)(resources.GetObject("axShockwaveFlash1.OcxState")));;
this.axShockwaveFlash1.Size=new System
.Drawing.Size(300,150);;
this.axShockwaveFlash1.TabIndex=1;;
this.axShockwaveFlash1.FSCommand+=newAxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEventHandler(this.axShockwaveFlash1_FSCommand);; // //Form1 //
this.AutoScaleBaseSize=new System
.Drawing.Size(6,14);;
this.ClientSize=new System
.Drawing.Size(320,398);;
this.Controls.Add(this.axShockwaveFlash1);;
this.Controls.Add(this.axWindowsMediaPlayer1);;
this.Name="Form1";;
this.Text="Form1";; (( System
.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).EndInit();; (( System
.ComponentModel.ISupportInitialize)(this.axShockwaveFlash1)).EndInit();;
this.ResumeLayout(false);; }
#endregion
///〈summary〉
///应用程序的主入口点。
///〈/summary〉
[STAThread]
staticvoidMain() {
Application.Run(newForm1());; }
privatevoidaxShockwaveFlash1_FSCommand(objectsender,AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEvente) {
switch(e.command) {
case"pause": {
axWindowsMediaPlayer1.Ctlcontrols.pause();; } break;;
case"play":axWindowsMediaPlayer1.Ctlcontrols.play();; break;;
case"fullscr":axWindowsMediaPlayer1.fullScreen=true;; break;;
case"close":Application.Exit();; break;; default: break;; } }
privatevoidaxWindowsMediaPlayer1_Enter(objectsender, System
.EventArgse) { } } }
flash是通过fscommand命令来控制的, fscommand在flash中的格式是fscommand(commandname,arg)。使用了这个命令就会在C#应用程序中产生一个fscommand事件.通过一个EventHandler来处理。this.axShockwaveFlash1.FSCommand+=newAxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEventHandler(this.axShockwaveFlash1_FSCommand);;
而C#中也可以向flash设置参数,如:
stringflashData="一二三四五六七";;
axShockwaveFlash1.SetVariable("data",flashData);;
这样的话可以在flash中通过Obejct.watch()得到变化。

Flash内嵌于C#程序中的应用 src="http://www.023rcsc.com/count/iframe2.asp" frameborder="0" width="650" scrolling="no" height="160">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值