c#显示swf文件的方法? 我想在aspx网页中显示swf动画,在网上查了一下,大家一般都是在Dreamweaver中编辑一下,然后把脚本加入aspx中,这样的方法的确简单,但有没有别的方法呀???我用的swf要显示txt文件中文字,单独运行swf是能显示,可在网页中却显示不出来了,怎么解决??谢谢各位!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接嵌入Dreamweaver脚本不适合你的情况。你需要和Flash进行交互。这样的东西Java做起来简单,有Flex相关的接口。就是不知道这样的接口C#之类的.NET语言内不能访问。 试试这个,winform中可以的flash内嵌于C#程序中的应用c#中注册flash控件在VS2005工具箱中“选择项”->“COM”中首先选择“Microsoft Multimedia Control 6.0”如果没有这个“Microsoft Multimedia Control 6.0”,请先注册“ MCI32.OCX”,然后在添加“Shockwave Flash Object”flash player是以一个com+组件的形式插入到C#应用程序中的. 加入的方法和普通com+控件一样.这是我今年2月做的一个小试验。事实上我上半年做的项目一直跟这方面有关,所以对这方面还是有一些经验的。现在由于公司项目的启动,所以要对这个熟悉一下,然后整以成熟的方法,使它们之间的接口更有通用性。这方面有一个开源项目flashCsharp做得还不错。但他只是对文件控制不错,扩展性不是很强。这个小试验是一个媒体播放器,由flash来控制,先熟悉一下。 using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace mediaplay{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1; private AxShockwaveFlashObjects.AxShockwaveFlash axShockwaveFlash1; /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // axShockwaveFlash1.Movie=Application.StartupPath+"\\videoControlButtons.swf"; axWindowsMediaPlayer1.URL=Application.StartupPath+"\\movie.avi"; } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer(); this.axShockwaveFlash1 = new AxShockwaveFlashObjects.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 += new AxShockwaveFlashObjects._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] static void Main() { Application.Run(new Form1()); } private void axShockwaveFlash1_FSCommand(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEvent e) { 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; } } private void axWindowsMediaPlayer1_Enter(object sender, System.EventArgs e) { } }}flash是通过fscommand命令来控制的, fscommand在flash中的格式是fscommand(commandname,arg)。使用了这个命令就会在C#应用程序中产生一个fscommand事件.通过一个EventHandler来处理。this.axShockwaveFlash1.FSCommand += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEventHandler(this.axShockwaveFlash1_FSCommand);而C#中也可以向flash设置参数,如:string flashData = "一二三四五六七"; axShockwaveFlash1.SetVariable("data",flashData);这样的话可以在flash中通过Obejct.watch()得到变化。 你把swf文件对应的.fla用flash工具打开后,,(fla文件里面写和txt文件交互代码)测试影片,如果可以的话,你点导出后存与和你的aspx页面同一个路经下,然后发布会自动生成一个.html的网页(和flash同名),你把里边那段(object的代码拷贝到aspx页想显示的地方,ok! 1. flash 如何得到传来的参数 flash传参数我使用的是 标签传递法<embed width="108" height="84" type="application/x-shockwave-flash" src="pingjianWang.swf" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars="vfuwu=4&vshouhou=5"/> 其中 flashvars="vfuwu=4&vshouhou=5" 这行的意思是传递两个参数进去. src为flash 的位置 2.在flash中读取参数 在flash中直接使用 参数名就可以使用 这个传进来的参数 但是注意一点!如果你要使用参数的是数字类型子的,需要用Number(str)这个函数转换成数字型再使用,否则会出现些难以预料的错误 太感谢各位啦!paulyjin的方法比较好,省了还要用Dreamweaver再编辑网页,这种方式虽然能显示swf,但里面的txt的文字还是没显示出来!heavencloud的方法可以显示里面的文字,可是显示的是乱码,郁闷! 水晶报表如何设定长宽高及使用格式。。 ajax和My97DatePicker冲突 计时器问题 请问C#2010中Sqlconnection中定义连接的String代码是什么 我做了一个程序,更新数据库,出现问题,请教 关于C#中的接口 c#中如何根据datagrid中绑定的不同数据,使datagrid显示不同颜色 用.net的项目多码?是哪类项目呢?工作好找吗?(详细回答者有分) 在C#中如何过滤掉ASCII的软回车与硬回车 系统成许位置问题,名称问题! 奇怪了,VS2005下窗体的资源文件被编译,却没有嵌入到可执行程序中 multiview 几个页面之间的数据如何进行传递
flash内嵌于C#程序中的应用
c#中注册flash控件
在VS2005工具箱中“选择项”->“COM”中首先选择“Microsoft Multimedia Control 6.0”如果没有这个“Microsoft Multimedia Control 6.0”,请先注册“ MCI32.OCX”,然后在添加“Shockwave Flash Object”
flash player是以一个com+组件的形式插入到C#应用程序中的. 加入的方法和普通com+控件一样.这是我今年2月做的一个小试验。事实上我上半年做的项目一直跟这方面有关,所以对这方面还是有一些经验的。现在由于公司项目的启动,所以要对这个熟悉一下,然后整以成熟的方法,使它们之间的接口更有通用性。这方面有一个开源项目flashCsharp做得还不错。但他只是对文件控制不错,扩展性不是很强。这个小试验是一个媒体播放器,由flash来控制,先熟悉一下。 using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace mediaplay
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1;
private AxShockwaveFlashObjects.AxShockwaveFlash axShockwaveFlash1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
axShockwaveFlash1.Movie=Application.StartupPath+"\\videoControlButtons.swf";
axWindowsMediaPlayer1.URL=Application.StartupPath+"\\movie.avi";
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();
this.axShockwaveFlash1 = new AxShockwaveFlashObjects.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 += new AxShockwaveFlashObjects._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]
static void Main()
{
Application.Run(new Form1());
} private void axShockwaveFlash1_FSCommand(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEvent e)
{
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;
}
}
private void axWindowsMediaPlayer1_Enter(object sender, System.EventArgs e)
{
}
}
}flash是通过fscommand命令来控制的, fscommand在flash中的格式是fscommand(commandname,arg)。使用了这个命令就会在C#应用程序中产生一个fscommand事件.通过一个EventHandler来处理。
this.axShockwaveFlash1.FSCommand += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEventHandler(this.axShockwaveFlash1_FSCommand);而C#中也可以向flash设置参数,如:string flashData = "一二三四五六七";
axShockwaveFlash1.SetVariable("data",flashData);这样的话可以在flash中通过Obejct.watch()得到变化。
会自动生成一个.html的网页(和flash同名),你把里边那段(object的代码拷贝到aspx页想显示的地方,ok!
flash传参数我使用的是 标签传递法
<embed width="108" height="84" type="application/x-shockwave-flash" src="pingjianWang.swf" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars="vfuwu=4&vshouhou=5"/>
其中
flashvars="vfuwu=4&vshouhou=5"
这行的意思是传递两个参数进去.
src为flash 的位置
2.在flash中读取参数
在flash中直接使用 参数名就可以使用 这个传进来的参数 但是注意一点!如果你要使用参数的是数字类型子的,需要用Number(str)这个函数转换成数字型再使用,否则会出现些难以预料的错误
paulyjin的方法比较好,省了还要用Dreamweaver再编辑网页,这种方式虽然能显示swf,但里面的txt的文字还是没显示出来!
heavencloud的方法可以显示里面的文字,可是显示的是乱码,郁闷!