Integrating Flash with C# Applications

Does anyone have any experience with integrating Flash applications / content within C# based windows applications?

If so, what was your experience like? How hard was it to get started?

Post your comments in the comments section.

48 Responses to Integrating Flash with C# Applications

  1. Nik says:

    i made a projector a while back thats customizable via XML to specify n load swfs into a c# program and have some more functionality like access to filesystem, ftp etc….needs the .net framework installedhttp://nuthing.com//FlashMXProjector/ive done more advanced stuff with it, its not so bad once u know how to use the flash object. its like any other activeX control.issues i noticed are, the .net app itself takes a little time to load, and then find the flash dll in the windows dir & load the swf. if the swf is embeded in a resource file or an external swf (in this case theres an external swf specified via the xml) its a tad slower i think. but its fine. i didnt have any issues. depends how much C# you know i guess. i didnt have many problems.with the files above ive made quite a few small utility apps that i keep in the taskbar… easieer to spend 30 mins and have a new flash tool for some things u do repeatedly.i addressed something like this in the wishlist a few days ago… better activeX support/commands so apps like this have more access to the objects + functions inside the movie loaded in activeX flash objectemail me if u need any help…nik

  2. Brian Rogers says:

    I have just started experimenting with the Flash 6 PocketPC player in a .NET Compact Framework app. I’ve just gotten started, but I’d love to see if anyone else has any sample files for this.I’ve done quite a bit of FlashMX/ASP.NET work though…-Brian

  3. http://www.sidedev.net/FlashBOXpre.zipMike this is a great .net/flash example. Joseba Alonso (SideDev) has released the first public beta of FlashBOX:

  4. Hi,I’ve had lots of experience integrating C# and flash on a recent project. Basically we are using C# to do web services, data pre-processing, integration with other devices (e.g. proximity detectors); and an embedded flash movie does the visualization. It’s a healthcare application with lots of clinical data presented in a friendly way in flash.Integration and development has been hard. Loading the movie etc. is no problem, speed is not too bad in general — Flash aches when the object count rises.The problems are in communicating between C# and flash, and in debugging. Also, the lack of control over memory management is a pain.In our app, C# and flash send quite a bit of data to each other. Since the integration occurs via setting variables in the Flash ActiveX control, and catching events in C#, we have had to go to some lengths to allow fast and asynchronous communication. I’m talking about multiple state machines and queues here, both in flash and C#!If the doctors didn’t like the UI so much our life would be much simpler with just C#. ActionScript is not robust enough for a mission critical application.I would like the ability to access flash objects directly within C#, including arrays. e.g. some kind of shared object. Calling flash functions directly is just as desirable. Flash calling functions in C# would be a good trick. I often dream of having access to .Net’s xml object within Flash when running in a windows application (yes, this project is getting to me…)Malcolm.VP R&D, Alcidion Corporation

  5. Me again.I forgot to mention a problem with deployment of Windows C# + Flash. The ActiveX installer with Flash MX is very unreliable and doesn’t seem to register the control properly. The most reliable way we’ve found is to download via the macromedia web site.I’ve read on MSDN that some people have put flash into their own MSI’s (windows installers) to get around this problem. We’ve had to manually register the control if web access has been blocked.Malcolm, mp at alcidion.com.auVP R&D, Alcidion Corporation

  6. Nik Khilnani says:

    i agree with the last few posts, the activeX needs to give us more access to the flash objects contents.also right now since communication is tough its makes integrating flash and c# more interesting than practical.nik

  7. Kooba says:

    Thanks you guys for looking closer at this topic, definately not enough resource around, I got question to Mike: If (and if so, than how soon) can we expect native .NET flash component?thank you everybody for source code.Kooba

  8. Hi,I agree with Kooba that a managed code version of the player would be nice as it would avoid any of the tie ups that using Com Interop means. It would also allow Flash a way of interacting more closely with a .net language with access to meta data/IL etc etc. While Flash Remoting allows you to start talking Flash > CTS and vice versa its not ideal for desk tops apps.Andrew

  9. Im working in a proyect called FlashBox (mentioned above) to develop a free-of-use desktop enviorement functionality. Data access and file access are the firt priority but i have redesigned FlashBox to load custom extensions so anybody can write a little c# assembly and easy put the functionality into Flash. The version that you can download online is only a preview version. The actual development of the app is very different from the original. Especially the internal engine (core of the app) has been redesigned to implement the extensions interface. The beta version is almost done and i finished de Actionscript thing a few days ago. Now im testing it in a real project, then i will put it all online. Documentation is now in spanish only :(In the background, i have choosen to do a XML Socket connection to communicate both. Because the lack of functionality of the activeX Interface (has been the same from Flash 4). And using this type of communication i can have data-ready events and pass estructured data between them. Used WDDX for basic typing and a custom Package of classes called DBSWF for Database data exchange.The worst thing is the slowness of XML parsing in Flash. With medium-large amouts of data. Parsing a XML structure to a custom classes inside Flash is still pretty slow. Other thing is the .NET Framework enviorement requirement that need the user who runs the app. But i think this problem may dissapear in a near future when MS will integrate it with the next generation of OS.Maybe a better ActiveX support… or better, a Flash .NET native component will be cool. Especially the capability of call Flash Functions from outside.

  10. Nik Khilnani says:

    I dont think making a .net component would be a very good solution at least where desktop apps are concerned. For serverside stuff yes, but right now a lot of user do not want to or do not have the MS .net framwework installed, so apps made with .net & flash would have a limited audience.Thats one of the reasons i stopped development on aflash .net swf environment (first post) to let u create an flash app by modifying an xml file.for me, personally, id rather use screenweaver than spend the time to recreate screenweaver for a .net environment. Its cool we know how to do it butid use .net only if the app is designed specificatlly for the .net framework and a .net using audience.New editions of the MS Windows 2000/Me/XP/ etc have framework 1.0 bundled but a lot of companies do not want or do not have the .net framework installed.I think screenweaver and SWF studio have been doing a lot of good work.Joseba is right, the activeX methods havent chnged since a while, using TCallFrame etc or using fscommands are more a problem than anything when trying to make a desktop app. I like his idea of making a local socket server to handle communication. Would it cause conflicts or firewall issues on corporate networks?The best solution at this time would be to update the activeX methods.We can get it into .net they way weve been doing & using it vb6/vc++6 etc as well.additional methods id like in the active X would be1. call functions2. access _level/_root/_global.3. if possible …access object instances (read only is fine) and their properties (read/write).4. export the swf. this would give the ability to use the activeX, create objects and export/save the created SWF. its a streatch but would be great for server side & desktop apps.5. if u decide to make it a product it’s cost should be less than 2/3rd the price of the flash IDE & competing desktop apps like screenweaver, around 1/2 to 2/3 of the flash IDE? $200 – $300. i know u guys need to make money too. (Just updating the activeX to give u access to functions and properties via dot syntax wouldnt justify charging for it)my 2 cents….thats all.nik

  11. I dont think a native .NET component is a bad idea. *All* of the Microsoft Software is moving that way. No matter if you like it or not, soon or late *everybody* will have the framework installed. Its a matter of time. Even if they dont update their OS the apps they use may. And when they are updating some kind of software, the software installer itself will install the framework. Imagine an Office .NET or somewhat else. Something like this happened with IE, when MS wanted to spread it, there is no way out.By the way, an activeX update is sufficient to cover todays lack of functionality but it will not in a near future. ActiveX died the day .NET appeared.This is my opinion…

  12. Nik Khilnani says:

    activeX:* used by IE, MM broswer plugin (not going anywhere soon)* used by javascript to talk to flash and vice versa, would enhance the communication* already exists but would be updated.* vb6/vc6 compatiable hence wider audienceCOM component (practically same as activeX)so has same advantages except it wouldnt be used in the browser. This could let it have more functionality since theres less security issues invloved.net component* need .net framework installed* avg user doesnt have this.* large companies will likely refuse to upgrade their systems for a new desktop tool* not viable for apps targeting a wide audience (how many commercial .net do u see? very few .net apps are very fast to develop, my company has made a LOT of .net apps for internal use but none would fly in the commercial market).net is going to be everywhere soon but currently it isnt. COM objects arnt going anywhere anytime soon and work on practically all current WIndows machines. If one component is going to be made i think it makes more sense for it to be COM which can be used by by a wider audience than .net. A corporate isnt going upgrade their computers for desktop app unless it really does something benificial. If the app doesnt really use the power of .net it doesnt need to be built in .net.In the end it depends on the audience. Ideal would be to have COM & .net, but if its only one we,i think the COM should be built before the .Net component.my 2 centsnik

  13. The ActiveX interop between Flash and C# does not seem to be a bottleneck in our app which has significant amounts of data exchange between the two environments. The slow speed of ActionScript is much more of a bottleneck.What’s the difference between using Sockets and setting variables to xml strings via ActiveX?Whether the Flash component is native .Net is not the issue, the issue is reducing the impedence mismatch between the two environments via access to functions, objects, etc.How about if Macromedia created a .Net component that exposed the Flash drawing/animation API but driven by .Net languages instead of ActionScript? Imagine Flash running with a JIT compiled language, and the full benefit of the .Net framework. WOW!The business model would be better for Macromedia too because Flash Player is free. The Flash.Net component could be licensed.GDI+ in .Net is not that great for animation, and DirectX isn’t great for 2D vector-based graphics. So there is a space for a Flash graphics engine component.BTW. we have had no problem requiring customers to have .Net Framework installed by our customers. It’s very unobtrusive compared to VB 6 libraries, and all the associated COM/ActiveX crap that’s involved. If you think Screenweaver is comparable you probably need to spend a bit more time understanding what’s in .Net.Regards,Malcolm

  14. Nik Khilnani says:

    i agree completely with you malcom, the features it has is more imp than whether its COM or .net. i dont think screenweaver compares to .net, i’m only emphasizing use what you need, if ure app doesnt benifit from being .net based theres no need to make it .net. if it does need/use .net specific features, well, use .net. having the option is what im getting at.anyway…. i think we’ve gotten OT. on the other hand i think we’ve touched on most of the features we’d like to see.what does mike think?nik

  15. Ahmet Zorlu says:

    At the long term SWF interpreter will be a native .NET component (either MM or somebody else will do it), ActiveX interpreter will be with us probably for a few years more.As MS has stopped the development of Internet Explorer (in favor of IE .NET and Longhorn), radical changes will be required.imho, in the SWF arena, two kinds of C# driven applications will be popular. One will be a wrapper for ActiveX control, so that SWF content can be integrated in Windows Forms applications.Here is a SVG equivalent for that kind of app:http://www.kevlindev.com/dom/asv_sharp/index.htmThe second would be C# libraries to create SWF files (ming sharp ?).Here is a SVG equivalent, SVG#:http://sourceforge.net/projects/svgdomcsharp/

  16. Vitor says:

    HELP!!!How do I communicate an C app with a Parallel/Serial port and send this to FLASH?!?!?This is a LOCAL/DESKTOP app with low but constant data flow…

  17. Bhupendra says:

    Hi,I need to use flash with C#. But before that I want ActiveX of flash. Where it will be available? Also I have “shockwave flash Factory Object” in my toolbar but when I drop it on my C# form it gives error that object is not properly registered. I registered the flash.ocx with regsvr32.exe but no change in error. Can anyone help me? Thanks! response will greatly appreciated.

  18. dror says:

    We develop a fair amount of C# applications that use c# and flash integration. No major problems besides not being able to call flash functions from inside flash. Although, I was wondering how one embeds an swf as a resource and references it from axShockwaveFlash. We are currently only using external swf’s as a result of this.thanksdror.

  19. snorris says:

    We’re developing an application with a Flash MX front-end, a c#.net business and data-connectivity layer, and a sqlServer 2k database.IIS and asp have always been installed on the server we are using. Can we access c#.net without having IIS and asp installed on the server?

  20. Jesse says:

    I am doing a similar project, and the only problem I am having is getting rid of the background in the flash movie. I can do it easlily in a browser with the wmode=transparent tag, but in .net when I set the designer’s wmode value to transparent the background is still there. Anyone know of a work-around?Cheers, Jesse

  21. dror says:

    I’ve developed a google_image_cd_box_generator in c# and flash … parts of it are open source and the rest of the code is available on request .. check it out at http://www.runme.org/project/+makeBox/

  22. Miroslav Christov says:

    I have the same problem as Jesse:wmode= “transparent” do not work in .NET studio at all!I’d be glad to know sth more about itThanks in AdvancedP.SIt works fine in Visual Studio 6!

  23. Mike says:

    Has anyone got an example of embeding a swf in an exe and then loading it from the resources (without saving out to a temporary file)?

  24. jatin says:

    hi,I want to integrate my flash work with c#. can somebody tell me the site where i can get the needful help.Jatin

  25. cheenu says:

    hi!!!i m using Flash .swf file with C#2002…it works well on my PC.My problem is when i deploy my project and use it in some other PC having .NET framework it gives error.Component not registered.what shud i do then.iff anybody know what to do in this case.thanschini

  26. warriach says:

    Does anyone have any experience with integrating Flash applications / content within Visual c++ or with .Net frame work based windows applications?

  27. Warriach says:

    HiI want to integrate my Flash applicationwith .Net frame work by using VC++.can any body help me on that?Thanks

  28. dhananjay says:

    I have integrated Flash control to C# and vice-versa. I want to change the label of the pushbutton at the runtime. Application accept the value of the string for the pushbutton label, but dont display it on the button according to the language selected in C# combo box. Plz assist in this regard

  29. Blakk Nite says:

    Yo, I’m not into the whole business deal of all this stuff you guys are talking about but I ran across this page searching for a specific function that I’m trying to do with Flash 5 (haha yeah I know you guys got much better stuff but I’m poor)I was just wondering, is it possible to run external applications from a Flash 5 movie? Such as, if i wanted a visitor to click on a button in the flash movie and it starts up the windows solitaire game, or notepad or something like that… Is it possible? And if so… How do I do it?

  30. Jankrod says:

    I have been working on a project for 2 years now were about half of the code is C# and the other half is Flash.. I think i have tried just about everything with them two now. Im getting stuck on changing the cursor on the C# side so that i don’t have to make flash do it and worry about the graphic staying on the stage.What I really wanted to add to discussion was my disappointment in net. If anyone is tying to make there exe and flash integration secure .NET is not the way to go. It is insanely easy to decompile a .NET application. Yes, there are some tools to scramble the code, but you are much better off with a pre .NET version of the visual studio that actually compiles the code. For me after 2 years I’m out of luck because the old versions of the visual studio didn’t offer C# and I’m not going to change my code. But anyone starting fresh should look at where the exe is going to be, and if its on the clients computer I wouldn’t use .NET.With all that said anyone having question feel free to e-mail me, i may have some guidance, and ill check my mail before I will this post. I saw some post about transparency, and embedding resources, some quite old though.Im surprised it hasn’t been posted yet all you need to do the communication is at: http://www.flashfanatiker.de/blog/archives/000032.html

  31. Hamish says:

    In response to:I have the same problem as Jesse:wmode= “transparent” do not work in .NET studio at all!I’d be glad to know sth more about itThanks in Advanced—————————-Currently I’m working on a project using C# and with a Flash front end. The transparency issue i have overcame and what is needed is in visual studio on the form transparency key which is near the bottom of the properties – need to set that as a color such as green and when the color is shown print screen then open up photo shop paste the image get the correct color of the green and set that color as the background in the flash movie. Also in visual studio set the form mode so it does not have title bar close or minimize box. Right now my app sends fs commands to c# to minimize close, and operations that c# needs to perform and all the interface is flash based and resizable. The flash uses xml for some of the interface related information and c# will do the brunt of the work of the app. The app now has a pretty cool look and feel and i have seen nothing yet like it. So far when the program runs it will have a transparent look for the alpha per pixel of 0% or 100% although not semi transparent say 50% which i would love to find an answer to that. In visual studio on the form if you set the transparency of the form to other than fully opaque it will mess up the look of the flash and display the color green semi transparent. As well on the photoshop side you want to make sure that the .png’s used on the edges of the graphics are either fully opaque other wise it will display a green edge around the app when ran.I’m not a pro on c#, but if anyone found this useful or even not i would greatly appreciate any information on sending data from c# to flash.Hamish

  32. Frank says:

    There is a .Net flash component may help you.You can down it free now!http://www.e-iceblue.com

  33. dagy says:

    Have any 1 found a way how to manage WMode to be transparent in .net ?

  34. Zep says:

    About transparent background…I’m using VC++ .Net and I got a dialog with a flash activeX Control. When I select the control (dialog ressource editing) and have a look to the properties, there is a property called “WMode” ans set to “Window”. I just set it to “Transparent” and got a transparent background when playing the flash movie. That may help… 😉

  35. Waqas says:

    I have two swf files (text viewer and text editor) which are loaded in .Net Flash Objects1. text viewer swf has a button which when clicked passes the htmltext in its text field to .net through FSCommand.2. In response to this the htmltext is passed to the text editor swf through setVariable function.3. This text is then displayed in the text editor text field.Issue:The issue is when I click on the text editor text field the focus does not go to the text field instead I have to click it twice to set the focus to text field.I have done the same thing with the .Net command button but it works perfectly fine.Can anyone of you tell me to what might be the problem here when I try to do it without the command buttonThanx in advance

  36. wsstefan says:

    dagy,CAN YOU POST YOUR .SLNI’ve tried to get the flash transparency but the wmode=Transparent does nothing.I can get keying to work but then I’m left with a nasty border where flash antialiases.

  37. Fabio says:

    In c# WinForm Application, I set wmode to “Transparent” but it doesnt work

  38. Jeny says:

    Help!!I am working on a module to export the custom animations designed in powerpoint 2003 to .swf files – To be coded in .NET environment. Any help on this or guidance to related links is most welcome!!

  39. Robert says:

    I am using vb6 with the Flash ActiveX component.I can’t set or get the global variables from Flash. Why?code in Flash:_global.variableX = “test”;var var1 = “probe”;code in VB6:MsgBox flashOCX.GetVariable(“_global.variableX”)Call flashOCX.SetVariable(“_global.variableX”, “xxx”)With var1 everything works fine !!MsgBox flashOCX.GetVariable(“var1”)Call flashOCX.SetVariable(“var1”, “xxx”)

  40. Nhilesh Baua says:

    Hi,I want to unload a movie and reload it once again with diff. parameters, for the same I am using the following command,AxShockwaveFlashObjects.Dispose();I am able to unload the movie but not able to reload which throws some read only memory exception.Can you help on this?Regards,Nhilesh Baua.

  41. I am trying to use the Flash ActiveX/COM object in C# to load SWF files and get the image or bitmap data from the control. However, I was unable to find that data exposed by the control, I also looked at a freeware product SWFToImage, but that library isn’t able to export with alpha channel transparency PNG files (which I really need). I also tried just grabbing the screen using the method described here:http://66.129.67.100/247reference/a.aspx?u=http://www.bobpowell.net/capture.htmBut that didn’t really work for me either because I’m back to where I started without the alpha transparent background. Anybody know how I can convert a swf file into a png with transparencies that I can display in a windows form?

  42. Michael Jacinto says:

    Nhilesh baua. You could use. swfobject.movie=”” since it only loads the object manually.

  43. Nhilesh Baua says:

    Hi Michael,Thanks for the help, howeverI have tried your code but I am having the same problem again.It would be nice if you mail me the solution on n_baua@yahoo.com

  44. Nhilesh Baua says:

    Hi Michael,Thanks for the help, howeverI have tried your code but I am having the same problem again.It would be nice if you mail me the solution on n_baua@yahoo.com

  45. Steven says:

    Does anyone manage to have transparent flash Ocx control in .NET 2.0 (C#) desktop application? I know it is do-able with transparency-key on form, but that doesn’t work sometimes and also I need it to work on win98SE (I doubt the transparency key works on 98′)