Skip navigation

Monthly Archives: May 2009

Let’s continue our project for visual basic with flash.

1. First create a New Project and choose Standard EXE.

vb01

2. We need a Component that will allow us to communicate to our SWF file which we created previously.
On the menu bar, click Project > Components. Under the Controls Tab, check Shocwave Flash and click Apply.

vb02If the Shockwave Flash is not present, browse to the directory and locate the “FLASH.OCX” file.

3. Now lets start designing our form.
Notice there is a new object on our tool, its the ShockwaveFlash object that we include lately in our components. Draw one of this into our form.

vb03

4. Add a TextBox, a Button and a Label into the form.

vb04

TextBox

Button

Button

Label

Label

5. For the coding.
Open the Code Editor, and enter the following code.


Private Sub Command1_Click()
'Send the message from Text1 of Visual Basic to the msgvb of Flash.
Call ShockwaveFlash1.SetVariable("msgvb",Text1.Text)

End Sub

Private Sub Form_Load()
‘Load the SWF in Visual Basic form.
Call ShockwaveFlash1.LoadMovie(0, App.Path & “/vbmx.swf”)
End Sub

Private Sub ShockwaveFlash1_FSCommand(ByVal command As String, ByVal msgmx As String)
‘Get the value entered in Flash TextBox and pass it to Label1 of the Visual Basic.
Label1.Caption = msgmx
End Sub

6. This is the final output of the example.

vbmx.exe

vbmx.exe

Advertisements