C# - Embed Flash loaded directly from a binary memory stream! - Printable Version +- (wL) Forums (https://war-lords.net/forum) +-- Forum: Resources (https://war-lords.net/forum/forum-31.html) +--- Forum: Programming (https://war-lords.net/forum/forum-33.html) +--- Thread: C# - Embed Flash loaded directly from a binary memory stream! (/thread-7012.html) |
C# - Embed Flash loaded directly from a binary memory stream! - MindHACKer - Apr 27 2012 I saw leaky back on business, So I got excited to see some coders back to the boring css community :, & decided to share this new tut with you all. Ok I'm gonna show you how to embed flash movies (.SWF) to your application without needing the actual .swf file, because were gonna embed that to the (.EXE) assembly, & then load it out directly from the memory, YEH THAT"S AWESOME RIGHT! So that might seem impossible especially using CLR, but it's not. I made this little app for my friend, It's similar to an interactive business card, so I just edited the texts, and hid my name. This is how the main form would look like After compiling and running, when press push a form with all contact info appears, The video is just a sample music video. [/hr] We need to add our .SWF movie, and in this case it's called "xeno.swf" as you can see plus other images & stuff. & we choose embed resource to each embed file: [/hr] Now we reference the following: [/hr] Now we use this awesome class Code, very unique way to load .swf from a memory binary stream Code: private void InitFlashMovie(AxShockwaveFlashObjects.AxShockwaveFlash flashObj, byte[] swfFile) & ofcourse we use it like this: Code: byte[] data = Properties.Resources.xeno; We load the movie from the embed resource into a byte array, & then we load the array as into the class, & the class buffers it into the flashobject directly, awesome right. Here is the full code to my little project, whats important about it, is the 3 dynamic link library, which are needed to run the app, but we can't just leave them out because it wouldn't be professional, so I figured out a way to embed them to the .exe assembly & then when you run it, the app will install them to the directory where the app is placed, which will make the app much more dynamic and smooth. Code: using System; As you can see, The code checks if the library's exist in the base directory, & if they don't it copy's them from it's self to the hard drive, But in order to load them to the memory, it needs to restart it's self, so simply closing it & reopening it would work. then it "initiallizecomponent();" then on formload() it loads the movie to a byte array & starts playing the movie with loop enabled ofcourse. That's it. |