Flash Script – Controlling Visual Basic From Flash

By Georgina Laidlaw
We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now

1. Create a new VB project.

2. Add the Shockwave Flash ActiveX control to your project. Create an instance of the control in your form.

3. Name the control "flashmov".

4. Open the code window for your form (i.e the Form_Load event), and add the following code:

'movie.swf is movie file 
flashmov.Movie = App.Path & "movie.swf"

Note that the above code assumes that the movie is in the same file as the vb project.

5. You can call vb function from flash by using fscommand.

For example, you can create a button in flash and insert the action:

//the below code is for flash not for vb 
fscommand("execute");

6. Create the swf file.

7. The vb code that responds to the Flash command is:

Private Sub flashmov_FSCommand(ByVal command As String,  
ByVal args As String)
If command = "execute" then  
MsgBox "Hey i can control vb"
End Sub

8. The code displays a messagebox when you press the Flash button.

The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now
Login or Create Account to Comment
Login Create Account