Tim Walters .NET Blog

Microsoft .NET, along with XML, XSL, XSD, SQL and other cool stuff

Embedding Flash in a Windows Forms .NET app

Mark G. Patterson asked:
"What's the best way to embed flash animations in .NET Windows Forms apps?"
Well, here's how I do it...
  1. First you want to add the "Flash" control to the Toolbox:
    1. Right-click on the Toolbox, choose "Add/Remove items..."
    2. Select the "COM Components" tab
    3. Scroll down to "Shockwave Flash Object" and make sure it's ticked
    4. Click OK
  2. Drag the "Shockwave Flash Object" from the toolbox onto the Form (just like any other control)
  3. Righ-click on the new object and select "Properties" to show the custom properties panel
Some things to keep in mind...
  • You probably don't want to hard-code the URL for the move in the properties dialog, so try setting the "Movie" property to something like Application.StartupPath + "\\MyMovie.swf"
  • If you want to talk to the Flash movie from C# (or VB.NET or whatever) then you need to use the "SetVariable" method
  • If you want to talk to the host Windows Forms app from Flash, use FSCommand... you'll need to add an event handler in your Windows Forms app
  • Debugging is a real pain, if someone out there knows of a nice way to debug this combo, please let me know!
For communication, I prefer to use XML, as I can have any simple/complex data I like going back and forth. The C# to Flash communication is done via a Queue, Flash tells the C# host when it's ready for another message by using a FSCommand, at which point C# sends the next message on the queue. When a new message is added to the Queue, it checks if Flash is ready and if so sends it straight away, otherwise it's added to the queue ready for the next "I'm ready" command from Flash.

I can post some sample code if needed, but I'm sure most of you get the idea.

Posted: Dec 29 2003, 11:18 AM by XMLEvangelist | with 40 comment(s) |
Filed under: ,


Abdul Qabiz said:

I dont have MS VS.Net, i use open source SharpDevelop for all my .Net Development.

Any idea how to embed Flash ActiveX in SharpDevelop development environment.

# December 29, 2003 6:38 AM

Laura said:

Hi, I was wondering how I could implement playing a swf on a OpenGL texture?

# January 15, 2004 10:06 PM

Dorin said:

I have two questions:

1. It is any method to incorporate the *.swf file in *.exe file (in C#)? Or in a *.dll file?

2. Does anybody have a little code where c# and flash communicate by xml? For example, flash make a query and c# replay by an xml file.

# May 22, 2004 4:05 PM

Tommy said:

Although ActiveX controls can be hosted in Windows Forms, there are some significant performance drawbacks to doing so. You should use ActiveX controls only when a .NET control with the same functionality is not available.
# July 25, 2004 6:46 PM

Narayanan Ramanathan said:

I have been trying to execute methods inside Flash from a VB.NEt windows forms application and also trying to capture Flash events in VB.NET . Something that this article is talking about. I will highly appreciate if you can provide a sample application to highlight the same. I have been encountering errors when trying to do so.

My email address is nram@mncebiz.com

Thanks in advance


# May 21, 2007 12:11 AM

GEORGE said:

hi i want to add flash to asp.net,  buti tryed to add the dll didnt work =(, do u know what can i do?

# June 21, 2007 7:09 PM

Jeeva said:

Hi ........................

Advance Thanks .....

I need some clarification for upload .swf file in asp.net using <embed> . in that how to redirect another page by clicking the flash file.

# July 26, 2007 11:19 PM

Naresh Khokhaneshiya said:


Can you please specify in more deeply or give an example of fscommand() and .net  communication ??

Thanks in advance. :)

Best Regards,


# August 6, 2007 3:05 PM

JamesC said:

Ok. I'm a 16 yr old VB.NET programmer with 2 yrs exp of trial-and-error lessons, so cut me some slack. I've added a reference to the control (for me - flash9c.ocx) and in the code I have created a new instance (fcMain) and initialized the settings (LoadMovie()). Then I realized.... this isn't showing on the form. I need to know how to display the control on the form. I've tried adding it to the toolbox, however, when I try to use it, it says "Failed to import the ActiveX control. Please ensure it is properly registered." ... whatever that means. Any Help? Thanks.

# August 7, 2007 1:35 AM

Ulhas said:

i want to use .swf in the .NET Compact Framework. How can can i do that?

any help is appriciated.

# August 29, 2007 7:59 AM

youssef said:

je ve code de flash avec vb2005

# October 9, 2007 6:26 PM

Anu said:

I want to run a flash file and  a mediaplayes file in VB.NET windows application. Pls tell me    the way.

Thank u

# December 7, 2007 1:36 AM

Syed Tabish said:

whenever i am going to Drag the "Shockwave Flash Object" from the toolbox onto the Form (just like any other control) an error prompt "fail to import the ActiveX Control. please insure it is properly registered "

if any one who have solution for it, kindly inform me

@ tabishghaz@yahoo.com

# April 6, 2008 10:39 AM

Lance said:

This does not work as written up and as advertised (VS 2005 Enterprise C# .Net forms app.)

Adding the reference to the COM DLL and then adding it to the form generates the "fail to import the ActiveX Control. please insure it is properly registered " nonsense.

I tried generating an AxImp (interop) dll using the flash DLL and all that did is give me a malformed interop DLL.

Why am I not surprised, Flash is not an open spec and Adobe does nothing to support hard client developers.

They just want to get everyone's content wrapped up in their proprietary format so that they hold the keys to the kingdom. I'm no M$ fan, but I hope that SilverLight crushes this POS...

# May 2, 2008 12:16 PM

Yousef said:

Thanks alot...

This article was so helpful...

Thanks again

# June 18, 2008 8:34 AM

Vj said:

Hey I have a problem also with dragging the shockwave flash object into the form it says that "Failed to import the ActiveX control. Please ensure it is properly registered".. what might be the cause of this problem? i cant do the following steps that you said because of that error.. i need it so badly.. :D thanks by the way. i really have to use flash with my C# application..

# July 27, 2008 11:50 AM

Sharjeel said:

Hey, I have successfully used this ocx control but I have faced some limitations in it. I jumped to any specific frame no by using gotoframe() method given in this control, It do jumped also but the problem arise when I try to jump on frame which is greater than 12,500 i.e: It only understands starting 12,500 frames of the movie although it do play frame grater than 12,500 but the problem is to jump. Do anyone has idea about this problem.

Plus I also want to play the movie at 1/2X,2X,4X speed, Is it possible using this control or I should look for another and what should that ANOTHER(remember I need it on windows form).


# September 3, 2008 12:00 AM

Argy said:

I'm using shoxkwave flash control in vb.net.

the system's function in my computer is very good BUT when I put it in the pc where this will be, the flash is moved and it looks bad. I put all Debug folder whit all references and it don't have solution.

The resolution is the same in the both computers.

Do you know the way to do it?

# December 24, 2008 1:30 PM

naveen said:

how can i bind xml data to axShockwave control

can anybody help me out

# March 23, 2009 4:40 AM

Andrija said:

Just for the record, flash10b.ocx (and earlier versions) have hardcoded powerpnt,word, excel, iexplorer process names, and it forbids CallFunction to be called from any dll's loaded with this processes, so if you want to create AddIn for Office, CallFunction call to flash ActiveX is not an options :(. If any one find how to make this call work ( exept editing flash.ocx. I changed one byte in powerpnt hardcoded string anf my AddIn is  working now :) ) pleaseeee send me info at ender357 at gmail.com

# April 10, 2009 6:08 AM

Swindon Cars said:

So does this embed a basic flash animation 100% into a form (i.e no external files required)?

# August 29, 2010 5:56 PM

shaike said:

Failed to import the ActiveX Control

Visit adobe and download shockwave, work for me.

# November 12, 2010 6:30 AM

Muhammad said:

Dear Friends,

I have a asp.net page with dorpdown menu and when i add flash files the drop down menu goes behind the swf file... could anybody help me with this.....

# November 21, 2010 6:52 AM

Tushar Gupta said:

Is there any way to embed a swf file in window application. with play, pause and forward buttons?

# January 6, 2011 3:33 AM

Mary said:

hi every body

i added a shokware flash object to my toolbox buttons but it's inactive and i can't Drag the "Shockwave Flash Object" from the toolbox onto the Form.

Why is it inactive ?

Any help would be appreciated...

# May 25, 2011 4:27 AM

Aleksey said:

Keep in mind that to play flash movie you need initialize property "Movie" with a FULL path and a file name of flash file.

# August 21, 2011 8:23 AM


Thanks! It works! I just embedded worldkit, flash control on c# windows forms. It works great.

# August 25, 2011 4:47 AM

Hemang thakkar said:

I have successfully added Shockwave Flash object to my Windows form application. I added an installer class to package my application. If i install the application from the package in the Debug folder it runs fine. However, if i install the package from the Release folder it doesn't launch and complains about the Flash object. I have include the Flash dll in the installer. Does anyone know what is going wrong here.

# September 28, 2011 1:10 PM

Growan Technologies said:

Thanks............ a lot.....

this is something new i learned in my last 3 years of exp.

G8t Post............

# December 8, 2011 12:47 PM

Clouse said:

It's very easy to find out any matter on net as compared to textbooks, as I found this piece of writing at this web page.

# January 25, 2013 10:00 PM

Guido said:

I really like it when people come together and share opinions.

Great website, continue the good work!

# April 14, 2013 1:39 PM

jckmrcovrd said:

irish colleenskimpy shaverbe predisposed to tocheck in nigheulogisticrep

# April 29, 2013 11:21 PM