This blog is subject the DISCLAIMER below.

Saturday, June 30, 2007

How to Play Flash (SWF) inside C#

Playing Flash (*.SWF) inside C# program with the ability to play ,pause and forward the movie :

All what you should to do in the first is to import the this two reference in the project as in this figure .
In the InitializeComponent function from Form.Designer.cs define your flash object as this :

this.AxShockwaveFlash1 = new AxShockwaveFlashObjects.AxShockwaveFlash();
// AxShockwaveFlash1
this.AxShockwaveFlash1.Enabled = true;
this.AxShockwaveFlash1.Location = new System.Drawing.Point(12, 12);
this.AxShockwaveFlash1.Name = "AxShockwaveFlash1";
this.AxShockwaveFlash1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("AxShockwaveFlash1.OcxState")));
this.AxShockwaveFlash1.Size = new System.Drawing.Size(525, 266);

To fill your Flash Object by SWF file:
AxShockwaveFlash1.Movie = “c:\ahmed.swf”;

To forward or pause the flash object :

To Play the flash object :


Ramy Mahrous said...

Nice post, Essawy
You may got this error
Cannot initilize the component...

So Start->Run->

regsvr32 C:\Windows\system32\Macromed\Flash\flash7.ocx
regsvr32 C:\Windows\system32\Macromed\Flash\flash8.ocx
regsvr32 C:\Windows\system32\Macromed\Flash\flash9c.ocx

Just see your OCX version.

Anonymous said...

The download link is broken.
I also found this link useful

Ahmed said...

Hello, where do you get those two dlls from. Thank You.

Ahmed said...
This comment has been removed by the author.
Ahmed Essawy said...

here are the links to the DLLs :

Interop.ShockwaveFlashObjects.dll :

AxInterop.ShockwaveFlashObjects.dll :

Hossam said...

what is this resource??
it gives me error

lavanya said...


This code is really good,but i am getting error at resource.getobject()... what is this resources. Please give reply


Ahmed Essawy said...

Dear Hossam and lavanya :

1- here is the resource file

2-I lost my project but here a code use the same dlls

Aritz R said...


friend4u said...

alternative solution is:
first add the flash object in tool box by right click -> com object-> flash object
then try this
private void button1_Click(object sender, EventArgs e)
openFileDialog1.Filter = "swf File|*.swf";
openFileDialog1.FilterIndex = 2;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
axShockwaveFlash1.Movie = openFileDialog1.FileName;

myncs said...

Hi, can you please tell me if it is possible to display a transparent swf in flash player in a WPF application. Any feedback would be greatly appreciated.

Ahmed Essawy said...

yes, it is possible to open SWF Flash in your WPF application but keep in mind that
#Adobe does not officially support embedding the Macromedia Flash Player ActiveX control within a Windows application. This means that future versions of the player may not work with your application.

#It requires users to install the Adobe Flash Player ActiveX control on their computers. This can be done by installing the player within Microsoft Internet Explorer. Although it is technically possible to distribute the player, that is restricted by the player's end-user license agreement. If you need to distribute the Adobe Flash Player ActiveX control, contact Adobe for permission.

here is a great post by Janiv Ratso
to do that step by step and source code is also available :)

Muthu said...

I have embedded flash control to my C# app and am able to load swf files dynamically. I would like to send information to the swf (for example, my swf file picks data from an external text file) i want to be able to give the name of the text file to the swf file. how can i do this?

Ahmed Essawy said...

@Muthu I didn't try that before but it is applicable and can be done very easy.
you can google for that use key words like
"how to pass parameter from C# to flash swf".

and here two result that I think may help you :)

Anonymous said...

I try to add flash object in vs2008
it gives a exception
in designer.cs

Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

if anyone know a solution Please reply

Anonymous said...

Re: Class not registered (Exception from HRESULT:

you must change project property - bulid - platworm x86 in other words ocx won't work when x64 or any cpu is selected

Anonymous said...

is this possible in c# 2005 ?

Ahmed Essawy said...

yes just write the same code in VS 2005. :)

pconnoll said...

Essawy, The DLL download link is broken. Will you provide another link or explain further in how I may be able to obtain the Interop.ShockwaveFlashObjects.dll and AxInterop.ShockwaveFlashObjects.dll.


Ahmed Essawy said...

Dear pconnoll,
try this link :)

pconnoll said...


Thank you for the updated link.


Anonymous said...

How to play exe flash files ?