views:

342

answers:

2

I'm using the flash 10 activex control to load a flash movie into my WinForm. Unfortunately, it only takes a path. What I'm trying to do is load the swf from a stream I can get from an EmbeddedResource so I can embed the swf into my exe such that A) I don't have to worry about paths and B) I don't have my swf quite so exposed - simpler for both usage and deployment.

I know of using f-in-box but I'd like to not add yet another dependency to my project. Is there a way to load the swf into the underlying activex control without having to use a path?

I'm using C# and .Net 3.5sp1.

A: 

I don't know if flash 10 supports the res protocol to load web content from resource. But I think the web browser control in Windows Forms and WPF support it.

To create a native resource you need an editor of native resource. Visual C++ has one. You can use RC.exe in Windows SDK to compile it to res files before linking in your C# program.

Update: Looks like the flash plugin for IE does not support the res protocol. embed the .swf file in a resource file and have it load using the movie parameter won't work. Try embed the Flash file in a web archive file (.mht) and add the .mht file to your resource.

Sheng Jiang 蒋晟
I've attempted res and couldn't get it to work. Neither have I seen any examples on the web of it working. Thanks though.
McAden
+2  A: 

Is that path always a file path? Or can it be a URL? It should be pretty simple to set up a temp localhost web-server using HttpListener (or similar), that streams back the file in response to an http request.

Another possibility would be named pipes; I wonder if you can convince the control to open a named pipe as though it were a file? (they have a logical file path, after all). I've barely touched these, though - so I can't say 100% whether it would work.

Marc Gravell
Thanks for the input. I believe it should be able to accept a URL, but is setting up a localhost webserver very client-friendly? And I believe named-pipes are simply for passing info from one process to another right? Flash's activex control only takes a string.
McAden
You won't have to set up a full webserver, just a tcp listener which will respond with a simple, predefined header and the swf content. But you'll need a free TCP port, and a background worker. I guess there's some potential for trouble, but it's not rocket science.
Tor Haugen
Not sure if it's the way we're gonna go, but this is the closest solution I've seen. Thanks.
McAden