Page 1 of 1

Simple SWF Loader

Posted: Sun Feb 06, 2011 8:45 am
by smashvb
I have seen these around but I thought I would make a simple tutorial.

Add a panel and dock fill it Top
Put a textbox and a button inside.
Add a web browser and dock it to fill

First, Add this code to the button1.Click
Code: Select all
    If TextBox1.Text.Contains("swf") = True Then
        WebBrowser1.Navigate(TextBox1.Text)
        Else
            MsgBox("You can only load SWF Files!")
        End If
Next, lets make it so the Enter key will also load the SWF, click the Textbox and in the properties click the Event button scroll down to KeyUp and double click it.

Add this code:
Code: Select all
   If e.KeyCode = Keys.Enter Then
            If TextBox1.Text.Contains("swf") = True Then
                WebBrowser1.Navigate(TextBox1.Text)
            Else
                MsgBox("You can only load SWF files!")
            End If
        End If
Pretty simple :) tell me what you think

Re: Simple SWF Loader

Posted: Sun Feb 06, 2011 9:09 am
by MrAksel
I think its great for newbies, but there is other ways too. Like right clicking the toolbox, press 'Choose Items' And find a component named 'AxShockwaveFlash' or something like that.
And you forgot an end parentheses in the first code box:
Code: Select all
If TextBox1.Text.Contains("swf") = True Then
        WebBrowser1.Navigate(TextBox1.Text    '<-------- There it is
Else
        MsgBox("You can only load SWF Files!")
End If

Re: Simple SWF Loader

Posted: Sun Feb 06, 2011 9:21 am
by smashvb
yeah I do know the Flash Component but I left it as a WebBrowser because then you make it so it loads web pages too if you wanted too

Re: Simple SWF Loader

Posted: Sun Feb 06, 2011 9:30 am
by MrAksel
Yeah i know. But you should fix that code, else you will get many posts its not working

Re: Simple SWF Loader

Posted: Sun Feb 06, 2011 9:44 am
by smashvb
Fixed thanks didn't see that

Re: Simple SWF Loader

Posted: Sun Feb 06, 2011 10:15 am
by Axel
I think it would be better if you used endswith , there might be a website called "www.swfthings.com"

so
Code: Select all
If TextBox1.Text.endswith(".swf") Then
'true' isn't needed

Re: Simple SWF Loader

Posted: Sun Feb 06, 2011 10:31 am
by smashvb
Pretty new to VB, thanks :)