Random techie babbling...

Embedding Flash in a .Net form

I’ve needed to do this various times and there’s always a few gotchas, here’s a brain dump for my own future reference if nothing else…

  • In Visual Studio 2005 Express Edition, go to Tools -> Choose Toolbox Items
  • From the “Com Components” panel tick “Shockwave Flash Object” then click OK.
  • In the toolbar now, if you expand the “All Windows Forms” group and look at the end you should see a new “Shockwave Flash Object” entry that you can drag onto your form.

swf_obj_img.JPG

To load a swf into your object, either set the full path in the “Movie” parameter using the Properties panel at design time, or at runtime using something like…

this.axShockwaveFlash1.LoadMovie(0, "D:\\test.swf");

Note – in both cases the paths must be absolute or the movie wont load.

If you get the error…

“Failed to import the ActiveX control. Please ensure it is properly registered”

…with VS running you need to go into the \obj\debug folder under your project root and delete any file(s) in there with ‘interop’ in their name. New (working) files should be auto generated for you and the problem fixed.

I’ll add more tid-bits to this list as I find them…

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

2 Comments

Got something to say? Feel free, I want to hear from you! Leave a Comment

  1. wondering says:

    What about passing parameters to the flash movie? Is this possible? I want to create some animated graphs in flash and feed them data from a data source. I want a button that can refresh the flash movie when the data changes.

  2. dean says:

    This post is great. I was getting the error message. Your meathod works and is the cleanest I’ve seen

    Thanks

Leave a Comment

Let us know your thoughts on this post but remember to place nicely folks!