Introduction: Flash Player Done in VB .Net

About: I love technology. We should all go back to pencil and paper!!

Being this is my first instrucable, I hope that I do not butcher it to bad. A little background on me first. 48yr old tech lover that has been sidelined for the last ~10 years to due to a traumatic brain injury. (Literally at one point was one doctors appointment from being put away in an adult home for the rest of my years!)

I have been playing around with Visual Studio 2012 and VB .Net. I like playing online games from sites like addicting games, but sometimes I am not able to get online. So I thought there has to be away to play these games offline. So using VB and a LOT of Google searches I managed to figure this out, or at least to do enough for what I wanted to do. Hopefully someone will take this code and add to it to make it better.

Also i have entered this in the coding contest. So please vote for me!!

So in the words of all the other instrucablers that have posted, Lets Get Started!!

Step 1: New VB Project in Visual Studio

First I am going to assume that if you know what Visual Studio is then you have some programming knowledge. Even if it is not in VB, I will try to make the steps as easy as possible to follow along.

Start a New VB Project

We will only be using one form. Once the form is showing in the design area we need to add the 'Shockwave Flash Object' by right clicking the toolbox, anywhere doesn't matter, and click 'choose item'


Step 2: Selecting the Shockwave Flash Object

2) A new window will open with several tabs across the top. Click
the tab that says 'COM Components'. Scroll down through the list of names until you see 'Shockwave Flash Object', then click the check box next to it. Then click the OK button. The window will close and you should now have a new item in your tool box called Shockwave Flash Object.

Step 3: Work on the Form Design

From the 'Menus & Toolbars' section of the toolbox drag a menu strip onto the form and drop it. It should be called MenuStrip1. On the menu strip on the form there will be a box that says 'Type Here'. In the first box enter the word File. Click the box below it and type the word Open.

Now next to the word file enter the word Games. now this where it gets a little tricky. If you do not have any games yet downloaded and saved then you can leave the menu slots below Game empty until you do. Otherwise type the name of the games in below Games. One name per line.

Step 4: Add the New Shockwave Control to the Form

Locate the new Shockwave Flash Object in your toolbox and drag and drop it on the form anywhere. Once it has been added make sure it is selected and change the 'Dock' property to 'Fill'. This makes the control resize with your window as it changes size.

Step 5: Add the Code for the Open File Menu

Now in case you don't have any games yet, or for some weird reason you don't want to add any, you can open any Shockwave Flash Object and it will play in this window. Double click the word Open below File and you will be taken to the code entry window. You will need to enter the following code:

Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click
Dim ofd As OpenFileDialog = New OpenFileDialog
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim swfFile As String = ofd.FileName
AxShockwaveFlash1.LoadMovie(0, swfFile)
AxShockwaveFlash1.Play()
End If
End Sub

Now if you have no games you are done. you can compile and run the code. Remember you will need some .swf file to load for it to play. If you a a game or two that you would like to install into the program continue on to the next step(s).

Step 6: Adding the Game Files

To make sure that your program can find the game(s) you will need to create a directory inside your VS solution directory. You can really put the sames anywhere as long as you know the directory but its easier if they are in the same directory.

As you remember I have three games in my program. To code them into the program you simply double click the name of the game under the Game menu. Again you will be shown the code entry screen where you will need to enter the code below:

Private Sub CursedWindsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CursedWindsToolStripMenuItem.Click
Dim swfFile As String = Application.StartupPath & "\FlashGames\" & "cursedwinds.swf"
AxShockwaveFlash1.LoadMovie(0, swfFile)
AxShockwaveFlash1.Play()
End Sub

Please note the code after the & signs in the Dim line will be different. Where mine says "\FlashGames\" you would put in the directory where your games are located. Also after the second & sign, where my code says "cursedwinds.swf", you would enter the name of your file or game.

If you have more files you would like in the menu, then simply double click the name under the games menu and then copy the code from the first game you entered. The only change you would need to make is the name of the file, assuming that it is the same directory as the first.

Step 7: Thats It!

If I make any upgrades to the code I will add it to the instructable. Also please remember if you like this ible them please vote for me in the coding contest.

Thank you.

Step 8: Update: 5-13-2015

Here is the code to open a file from the menu:

Dim ofd As OpenFileDialog = New OpenFileDialog
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim swfFile As String = ofd.FileName
AxShockwaveFlash1.LoadMovie(0, swfFile)
AxShockwaveFlash1.Play()
End If

Remember to vote Please!

Coded Creations

Participated in the
Coded Creations