in Visual Basic
         by Seifer Tim

One of the things that Flash is good for is making great user interfaces, which is a feature most other programming languages lack. I’ve discovered a way to make a user-friendly interface in Flash, and then use that interface inside a Visual Basic Application.

For an example of what you will be creating, download the following file, unzip it, and run the vbSample.exe program:

[ extract and open the file vbFlash.exe ]

Steps to Create Program
The following steps will guide you in creating the files you opened above:

  1. Start Flash MX, and make a new movie with any dimensions you would like. I used the dimensions 200px by 150px.

  2. Next, make a new Button Symbol, and name it anything you want:

[ create a new button symbol ]

  1. Make a rectangle in the first frame of the button, about 10 X 50 pixels, any color other than your background color. Align it to the center of the scene.

  2. Make a Key Frame in the next 2 frames of the button, and change the colors of the button for each frame:

[ modify the button for the up, over, and down states]

  1. Make a new layer, and put the word “Click” in that layer.

  2. Now, go back to the Scene 1, and drag an instance of the Button onto the scene.

  3. Drag a Text Field from the toolbox onto the scene, and give it the Dynamic Text property:

[ the text field and button ]

  1. Set the Instance Name to: “testField” and the var to: “testVar”.

[ the properties text field ]

  1. Click on the Button on the Scene, and open the “Actions” box.

  2. Type:

[ copy and paste the above code ]

  1. Publish the movie as a SWF File, save, and exit Flash MX.

Visual Basic Instructions
Now, you will get to use the above animation in Visual Basic:

  1. Run Visual Basic, and start a new Standard EXE project.

  2. Go to “Project | Components”, then look for the component called: “Shockwave Flash” this comes with every Flash Movie Player install, so if you can view Flash movies, you should be fine:

[ the shockwave flash component ]

  1. Drag an instance of the Shockwave Flash component into your main form. Add a Text Box, and a button.

  2. Go to the Code Editor, and enter the following code:

[ copy and paste the above code ]

  1. That’s it! Make the EXE file, and save it in the same folder as the flash movie, then run the exe!

If you have any questions, please do not hesitate to post on the forums at: kirupaForum.

Seifer Tim




kirupa.com's fast and reliable hosting provided by Media Temple.