VB and Flash jointly build your charm program
Tianjin Huangxing
In the process of software development, in order to improve the extent of software, many developers are striving to make their own program interface more beautiful, but except for simple use of pictures and shading, there is no better way? Flash is a vector format animation file that can contain animation, sound, hypertext link, and the volume of the file is very small, using Flash on the web, you can make a very beautiful dynamic menu bar. So can Flash can join the application to play the use of beautifying programs? After some study, Flash can not only be inserted into the program, but also interact with the VB application through the fscommand command! That is to say that your app's button will never be asy, but a charming animation! How, is it a heart? Well, let's join the VB and Flash together to build our charm!
(1) Playing Flash animation in VB
How can I join Flash animation in VB? We only need to use the shockwave flash.ocx with Flash5. Methods as below:
1. Open VB6.0, create a new project, click Right-click on the Toolbox, select ShockWave Flash in the Controls of Parts, and then OK, the Flash control is added to the toolbox.
2. Select the Flash control on the toolbox, put it on the form and adjust the size;
3. Add the following code during the Form_Load ():
Private sub flow_load ()
Shockwaveflash1.movie = "d: /test.swf"
'Write on your Flash file directory
Shockwaveflash1.menu = false
Shockwaveflash1.playing = true
End Sub
Among them, ShockWaveflash1.Movie is used to specify the directory of the flash animation you want to play; ShockWaveFlash1.Menu is used to designate the right-click menu in the Flash animation play, true is the display menu, false is a closed right-click menu; shockwaveflash1.playing = True is to play animation.
Ok, press F5 to see it, is it the Flash animation in the program to play? :)
(2) Control VB program interact in Flash
Now Flash animation has been played in the VB program, so how to implement the program of the VB in the flash to implement interactive operations? The focus of this article is also here.
First we first understand the basic principle of controlling the VB program in Flash: There is a function called FSCommand () in Flash's ActionScript. Its main function is to send fscommand commands, such as playing animation full screen, hiding animation menu, more important It is possible to communicate with external files and procedures. In the VB program, we use the FSCommand () process of the ShockWave Flash control to complete this communication process, implement information sent, and implement the VB program based on the different commands and parameters sent.
you got it? Simply put, we use the FScommand () function in Flash to send commands to the VB, using the ShockWave Flash control to accept this command, thereby reaching the Flash Control VB program. Ok, now I know the principle, let's take a step!
1. First, open flash5 to make an interactive button, plus the following code on the button:
On (Release) {
Fscommand ("Send Action");
// Send this command this command
}
The action of this command is to send a command named "Send Action" to VB after pressing the button. Of course, the name of this command can be called other names in practical applications.
2. Export Flash becomes a SWF file, as described in the first part of the article to VB6.0, the following is how VB accepts this command;
3. Double-click the ShockWave Flash control on the form, enter the code editing window, add the following statement
Private subshockwaveflash1_fscommand (byval command as string)
If Command = "Send Action" THEN
Msg = msgbox ("Flash is successfully combined with VB!", VBApplicationModal, "Success!")
'When you receive the send action command
'Join the procedure you need
END IF
End Sub
Among them, the process of shockwaveflash1_fscommand is specifically used to receive FSCommand commands sent by flash, where the first parameter Command corresponds to the command sent by the flash, when it is consistent, executes the following program (this example is Popked MSGBOX). Ok, look at the results of the program run:
Yeah! Success! :)
How, do you completely master the combination of Flash and VB through this article? Here, as long as you turn the sentence to the sentence to be executed as the program you want to implement, then the animation button in Flash can achieve all powerful VB features!
Go, no longer don't want those dead, gray buttons, add your dazzling colorful animation buttons, create your charm program!
If you have a good comment, you can contact me: Dennis_xing@163.com