Monday, March 23, 2009

Easy Step to show SWF File on Visual Basic

As I've search for an answer on How to put or show up an SWF File on a form in Visual Basic, but its quite difficult to find. But yet I've found a step but it needs you to generate those .dll on an OCX file then import it on your project and it has problems with VB Studio 2005 using the COM files.

But here it is I've found a solution for this problem, here's how you do it but first it requires you to have:

1. Adobe/Macromedia Flash Plugin/Player (of course!)
2. Any Visual Basic Studio/Express that has Web Browser component I think but I'm using VB Studio 2005.

Many web browsers can play swf directly without the standalone player because they have plugins, if you don't have plugins yet download at Adobe Flash Player. That's why I used WebBrowser Tool.

Easy simple steps:

1. Create a New Project, and name it "TestApp" (this is for testing purpose only, import it in your project later when you get the steps.
2. Now you have the form, Drag and drop WebBrowser Tool from the Toolbox to your Form.
3. Go to the properties window, change Url with "Path of your .swf file" or in code:

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

WebBrowser1.Url = New System.Uri("Path of your SWF File", System.UriKind.Absolute)

End Sub
End Class
It has disadvantages, can't control you movie with buttons in the form like play and stop.
First you have to configure it in your SWF File, like put a button to play it.


The Trashman said...

nosebleed! haha

The Siraniks said...

Nope, it's not it's a simple code... hehe...