Click here to Skip to main content
12,761,078 members (31,715 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


19 bookmarked
Posted 10 Aug 2013

Playing Flash Files (SWF) in C# Form

, 10 Aug 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
In this tip for beginners, we will review how to play a shockwave file (.SWF) in our form in the easiest and fastest way by using Shockwave flash object component.


Maybe sometimes you want to play a shockwave flash file (.swf format) in your C# or VB Visual Studio form. There are many ways to do it, but the easiest way is using its component which is available for use. In this tip for beginners, we will review how to play a shockwave file (.SWF) in our Visual Studio form with the easiest and fastest way by using Shockwave flash object component.

This component is located at %systemroot%\system32\macromed\flash9c.ocx and if you can't find it, you must install the latest version of Adobe Macromedia Flash Player. With this component, you can play all .swf files in order to show them in your projects and not reference which kind of flash file you use (a flash game, a flash banner or something else).

Using the Code

So for doing what we want, we must follow the steps given below:

  1. Add Shockwave flash object to Toolbox (with brief explanation): At first, we need to add Shockwave flash object component to our Toolbox. Generally, for adding a component to toolbox, we can right-click on Toolbox window and then click on choose items.

    Next in Choose toolbox items window, we can find and add each component we want and in this tip, we must go to Com components tab and add Shockwave flash object from there to toolbox. Now, you can see that component in your toolbox.

  2. Add to form: Now you must Drag & Drop the component to your form.

    Tip: One of the famous errors which you can be forced into is error in importing your component to your Visual Studio form. If you are forced to “Failed to import the ActiveX control. Please ensure it is properly registered” error, rebuilding project can help you. This error usually happens when you drag and drop the ActiveX component to a form and rebuilding the project will help you to remove this error. But, I found a solution here for solving this problem forever. Also, if you need a way for registering it manually, this link which I found can help you.

  3. Setting address of swf file to your object: Now you can set your swf file address to your object in any way you want. For example, in C#, you can use this code for playing sample.swf flash file:
    axShockwaveFlash1.Movie = Application.StartupPath + @"\sample.swf";  

    Some simple commands of this component are:

    Playing Flash: AxShockwaveFlash.Play()
    Pausing Flash: AxShockwaveFlash.Stop()
    URL Source of Flash file: AxShockwaveFlash.Movie = FilePath & "\FileName.swf" 

    Other commands properties of this component are:

    1. Loop: which in "True" mode helps to playing flash file continuously
    2. Quality: which in default value shows your flash file in its best quality
    3. Menu: which you can disable right click menu of flash object (settings) by it
    4. Framenum: by this, you can choose your start frame of your swf file
    5. EmbedMovie: make your flash file source embed to your solution
    6. BGColor: background color of your file when it starts to play
    7. AlignMode, AllowFullscreen, CTLScale, SAlign, WMode are used for positioning and setting view mode

In Other Languages

Originally, this beginner tip was published in Persian language on my website, then I translated it to English because I thought it might be helpful for people who have just started coding in C#!

Iranian friends can find the original article in Persian on Sourcenevis.

Sample Solution

A project of this tip can be downloaded here.

In this sample, I added a Shockwave flash object to the form and then created play, stop commands for them. Also, I link URL of flash file into debug folder which is contained with the main EXE file.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Amir Mohammad Nasrollahi
Founder Artificial Intelligence Developers - (AID)
Iran (Islamic Republic of) Iran (Islamic Republic of)
- Founder & CEO at Artificial Intelligence Developers - (AID)
- CSM Technology Founder
- Research and Development in the field of "Cloud Computing" and various topics of cloud science, artificial intelligence, speech and image processing, any platform projects design and construction.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Member 1045090310-Jun-16 22:49
professionalMember 1045090310-Jun-16 22:49 
QuestionPlaying movie from memorystream Pin
Member 217646727-Aug-14 0:02
memberMember 217646727-Aug-14 0:02 
Questionتشکر Pin
saeed_smco5-Aug-14 8:20
membersaeed_smco5-Aug-14 8:20 
AnswerRe: تشکر Pin
Amir Nasrollahi5-Aug-14 20:47
professionalAmir Nasrollahi5-Aug-14 20:47 
Questionfrom code? Pin
Chris Anders5-Aug-14 0:36
memberChris Anders5-Aug-14 0:36 
GeneralMy vote of 5 Pin
ketan italiya12-Aug-13 22:46
professionalketan italiya12-Aug-13 22:46 
GeneralRe: My vote of 5 Pin
Amir Mohammad Nasrollahi13-Aug-13 0:06
professionalAmir Mohammad Nasrollahi13-Aug-13 0:06 
QuestionImage missing Pin
Maimonides11-Aug-13 2:31
professionalMaimonides11-Aug-13 2:31 
AnswerRe: Image missing Pin
Amir Mohammad Nasrollahi11-Aug-13 2:56
professionalAmir Mohammad Nasrollahi11-Aug-13 2:56 
GeneralMy vote of 5 Pin
Ehsan Azami10-Aug-13 9:43
professionalEhsan Azami10-Aug-13 9:43 
AnswerRe: My vote of 5 Pin
Amir Mohammad Nasrollahi10-Aug-13 9:44
professionalAmir Mohammad Nasrollahi10-Aug-13 9:44 
GeneralMy vote of 5 Pin
Reza Khan Mohammad10-Aug-13 9:36
professionalReza Khan Mohammad10-Aug-13 9:36 
AnswerRe: My vote of 5 Pin
Amir Mohammad Nasrollahi10-Aug-13 9:37
professionalAmir Mohammad Nasrollahi10-Aug-13 9:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 10 Aug 2013
Article Copyright 2013 by Amir Mohammad Nasrollahi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid