Click here to Skip to main content
13,247,649 members (62,086 online)
Click here to Skip to main content
Add your own
alternative version


76 bookmarked
Posted 30 Sep 2005

Sending Data from a Flash Movie to the Hosting C# Application

, 30 Sep 2005
Rate this:
Please Sign up or sign in to vote.
An article showing how to send data from a Flash Movie to the hosting C# application, using FSCommand.


In this article, we will see how we can send data from a Flash movie to the hosting C# application. I'll start by mentioning the requirements of creating this application.


You will need the Macromedia Flash plug-in installed in your system, and you will also need Macromedia Flash software if you are required to create the Flash movie. Now we will move to the steps for creating the application.

Inside Macromedia Flash

Sending data to and from a Macromedia Flash movie to any hosting application will require a call to the FSCommand function. The FSCommand function takes two optional parameters which are the command and the parameters.

In this sample, I created three buttons and three circles inside the Macromedia Flash movie and converted them to symbols (will not dig in to details of creating the Flash movie).

In the on (press) event of all these six movie clip symbols, I inserted this code which differs according to the object. For example, I inserted the following code in the on(press) action script event of the blue button:

 on (press) {

and for the green circle, I used this code:

 on (press) {

However, you can use the FSCommand at any event inside the Flash movie, or even in the frame actions. To sum it up, you can use the FSCommand where you can write an action script :).

Inside VS.NET

As mentioned before, you should have the Macromedia Flash Player (the OCX files registered in your system). So, now create a new C# Windows Forms project, and right click on the Toolbox while you are in the design view of the main form. Choose:

Choose Add/Remove Items, and you will get a window. Choose the COM Components tab and then check Shockwave Flash Object:

Now you will find the Shockwave Flash object added to your tool box. Drag and drop it in your form and resize it to match your Flash movie size. To choose the Flash movie, set the property Movie, and to choose whether to have it embedded inside your application or to reload it externally each time you run the application, set the property EmbedMovie. I prefer that you choose to set it to true, because not embedding it will require that you preserve the original path of the movie all the time (you may just put it next to the exe).

Now we are a step ahead to our destination. We now need to collect the data sent from the Flash movie. Select the Flash movie inside the form, and then in the property pane choose the events. You will find the event FSCommand, double click on it to create the needed event handler.

When the Flash movie sends its data via the FSCommand function, the C# program collects this data inside the AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEvent object which is defined in the event handler parameter e. So, to collect the sent command from the FSCommand Flash function, you will just need to use the e.command, and for the parameters, use e.args. However, before we write anything inside this function, drag a Label to the form and resize it to an appropriate size and name it lbl_Result. Now, moving back to the event handler of the FSCommand event, we want to tell the C# form which button or circle was clicked. So, we will need to add this code:

//code inside the event handeler of the fscommand
lbl_Result.Text="The "+e.args.ToString()+" "+e.command.ToString()+" was clicked";

and finally you will get the information that you clicked on the blue circle, for example:

You can use this simple interaction for more complex data transfer. I hope it was useful.;)

Using the code

There is almost no code in this project :D, it's simple and small. You will just need to follow the above step by step explanation.


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


About the Author

Product Manager
Egypt Egypt
Agile Evangelist, Change Embracer and Success Facilitator. Project Manager and IT professional with 8+ years of leadership experience -

You may also be interested in...


Comments and Discussions

Questiondrag and drop a flash control in c# windows application. Pin
Tricube3-Jun-13 2:42
groupTricube3-Jun-13 2:42 
Questionsending data from c# to swf flash file. Pin
BahramLavi13-May-13 13:06
memberBahramLavi13-May-13 13:06 
QuestionNot working on certain machines Pin
Tanmay_D3-Oct-11 6:42
memberTanmay_D3-Oct-11 6:42 
GeneralMy vote of 5 Pin
miladfozooni6-Feb-11 7:06
membermiladfozooni6-Feb-11 7:06 
GeneralAdd same functionality in window mobile Pin
mohitisavailable13-Dec-10 0:45
membermohitisavailable13-Dec-10 0:45 
GeneralLoading a new form in vb from a swf file Pin
Vulcanriders18-Oct-09 8:54
memberVulcanriders18-Oct-09 8:54 
QuestionSending Data from a Hosting C# Application to the Flash Movie??? Pin
ffrancoz11-Aug-09 8:14
memberffrancoz11-Aug-09 8:14 
Jokethanks for all Pin
wikett28-Jul-09 6:57
memberwikett28-Jul-09 6:57 
Questionhow can disable context menu of shockwave flash object? Pin
mahdi_znt2-Jul-09 2:09
membermahdi_znt2-Jul-09 2:09 
QuestionFLA Pin
fagliaro30-Apr-09 2:23
memberfagliaro30-Apr-09 2:23 
AnswerRe: FLA Pin
wusideng26-Jul-11 18:18
memberwusideng26-Jul-11 18:18 
GeneralSetVariable Pin
fagliaro30-Apr-09 1:52
memberfagliaro30-Apr-09 1:52 
GeneralRE: Flash Pin
jberenguer1-Apr-09 12:45
memberjberenguer1-Apr-09 12:45 
GeneralaxShockwaveFlash1.GetVariable does not work Pin
creep2374-Mar-09 16:55
membercreep2374-Mar-09 16:55 
GeneralProperty does not shown Pin
wellage23-Sep-08 1:11
memberwellage23-Sep-08 1:11 
QuestionInformation Pin
Member 333319720-Jun-08 6:42
memberMember 333319720-Jun-08 6:42 
AnswerRe: Information Pin
John Simmons / outlaw programmer3-Jul-08 5:41
mvpJohn Simmons / outlaw programmer3-Jul-08 5:41 
GeneralRe: Information Pin
Member 33331973-Jul-08 5:49
memberMember 33331973-Jul-08 5:49 
GeneralRe: Information Pin
athor_a8-Sep-08 1:56
memberathor_a8-Sep-08 1:56 
GeneralThe movie dosen't work!!! Pin
amrhilmy24-Feb-08 13:19
memberamrhilmy24-Feb-08 13:19 
GeneralHelp Movie doesn't display Pin
laura131617-May-07 14:46
memberlaura131617-May-07 14:46 
GeneralRe: Help Movie doesn't display Pin
amrhilmy24-Feb-08 13:21
memberamrhilmy24-Feb-08 13:21 
Questionshock wave flash object control dosenot work Pin
MEDO_20082-Apr-07 11:11
memberMEDO_20082-Apr-07 11:11 
AnswerRe: shock wave flash object control dosenot work Pin
Hossam Aldin2-Apr-07 12:44
memberHossam Aldin2-Apr-07 12:44 
GeneralRe: shock wave flash object control dosenot work Pin
MEDO_20083-Apr-07 11:48
memberMEDO_20083-Apr-07 11:48 
GeneralRe: shock wave flash object control dosenot work Pin
RayBeeze11-Apr-07 6:46
memberRayBeeze11-Apr-07 6:46 
GeneralRe: shock wave flash object control dosenot work Pin
andrew cheong30-Jul-07 6:56
memberandrew cheong30-Jul-07 6:56 
Generaldo you think this works ? [modified] Pin
zillion427-Jun-06 15:16
memberzillion427-Jun-06 15:16 
Generalsimple easy good tutorial that can save time and money Pin
zillion427-Jun-06 15:07
memberzillion427-Jun-06 15:07 
GeneralCrossplatform Pin
michbex27-Apr-06 10:09
membermichbex27-Apr-06 10:09 
GeneralRe: Crossplatform Pin
Hossam Aldin27-Apr-06 12:07
memberHossam Aldin27-Apr-06 12:07 
GeneralGreat and simple ! Pin
MaIron-cool24-Apr-06 23:06
memberMaIron-cool24-Apr-06 23:06 
Questionhow do I do the opposite? Pin
Green Fuze20-Apr-06 6:26
memberGreen Fuze20-Apr-06 6:26 
AnswerRe: how do I do the opposite? Pin
michbex27-Apr-06 10:07
membermichbex27-Apr-06 10:07 
GeneralMore Complex Pin
StressBall2-Jan-06 16:49
memberStressBall2-Jan-06 16:49 
GeneralTransparent Pin
lovewindy19-Oct-05 19:49
memberlovewindy19-Oct-05 19:49 
GeneralRe: Transparent Pin
Hossam Aldin21-Oct-05 12:03
memberHossam Aldin21-Oct-05 12:03 
GeneralRe: Transparent Pin
lovewindy23-Oct-05 17:56
memberlovewindy23-Oct-05 17:56 
GeneralRe: Transparent Pin
RaTTe819-Dec-05 4:57
memberRaTTe819-Dec-05 4:57 
AnswerRe: Transparent Pin
athor_a8-Sep-08 6:04
memberathor_a8-Sep-08 6:04 
GeneralNot working Pin
Jitu999-Oct-05 15:58
memberJitu999-Oct-05 15:58 
GeneralRe: Not working Pin
Hossam Aldin10-Oct-05 0:24
memberHossam Aldin10-Oct-05 0:24 
GeneralRe: Not working - Working Now Pin
Jitu9910-Oct-05 6:22
memberJitu9910-Oct-05 6:22 
GeneralRe: Not working - Working Now Pin
hanafi315-Oct-05 8:06
memberhanafi315-Oct-05 8:06 
GeneralRe: Not working - Working Now Pin
Member 333319720-Jun-08 7:02
memberMember 333319720-Jun-08 7:02 
GeneralRe: Not working - Working Now Pin
hanafi315-Oct-05 8:09
memberhanafi315-Oct-05 8:09 
GeneralRe: Not working - Working Now Pin
Hossam Aldin15-Oct-05 13:41
memberHossam Aldin15-Oct-05 13:41 

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
Web03 | 2.8.171114.1 | Last Updated 30 Sep 2005
Article Copyright 2005 by HeldinBayoumy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid