Please refer to Networking Academy's another article: "In the flash program to control vb"
Say Flash animation is the most popular stuff online nowadays no one wanted to come against every time I see the good works anxiously download, but so many find collection of useful Flash player not to play. I first thought was Flash5 in the native player, but its function is weak, but also to install dozens of MB of Flash5, a bit overkill, can only enjoy the page you? So I thought I did a - it sounds very attractive, complex? Do not worry, using VB on the line, make out player functionality is not weak, with a decent standard, you can choose free play, pause, replay, you can play single frame step by step, to observe every step of vision, even VCD Flash to see the same look as the paper, random frame skipping. Cool it! Let you fully experience a return to the fun as a software DIYer.
Now I will explain in detail the whole development process.
:: Theory::
* How Play Flash animation?
Flash Player also belongs to a class of multi-media player, it should include complete playback controls: play, pause, stop, playback, back one, forward one frame, last frame, rewind, fast forward, loop and full-screen playback. As the Flash animation is a vector animation for this feature, but also a function of scale and quality of regulation.
To achieve so many features do not own programming, as long as the call system to provide the interface to Flash Player control, in fact Flash5 own player in many of the Flash player and online are doing so.
If you have access to normal web browsing with Flash animation, then your system already has this control of the. If not, you can use the "Control Panel" - "Add / Remove Programs" to install it. Select "Windows Setup" page in the "Multimedia", select "Details", "Macromedia Shockwave Flash" is what we need to select the check box in front, and then into the Windows installation CD-ROM drive, click on " OK "to install the controls Swflash.ocx registration; or you can view a Flash animation in IE prompt you to download web pages to automatically download and install this control.
Here you might think that since the controls are easy to obtain, it is only to provide call control interface, there is no difficulty. Please note! Flash-based development of control technology is not public information was available, and its information must be to develop commercial software for the purpose of signing the agreement with Macromedia may be after, but also to pay for. So the author in the development process quite a few detours, some properties and methods of use is in the dark gradually clear, and some interface, so far I still do not know how to use the source code behind you can see out to explore the scene.
* Special issue: how to play in full screen?
Full Screen Play is a deceptively simple, not easy to achieve together the functions. In all of the playback controls in full-screen playback is the only one not provided by the Flash control, because only full-screen windows have the concept of control is not, so it requires players to achieve their own. Requirement is filled with full-screen window screen, and no article title border, which requires dynamic change at runtime the style of the window, but we know the procedures for VB developers, there is no provision in the running time of dynamic change window style methods (run-time Change BorderStyle window invalid, ControlBox property can not change at run time), it appears only with the Windows API. In the user32.dll in Windows provides a set of corresponding functions to access and change the window were the attributes - GetWindowlong and SetWindowLong, they all can be found in VB's API Loader: Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ; (ByVal hwnd As Long, ByVal nIndex As Long) As Long;
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long. Where hwnd parameter is the handle of the window operation; nIndex parameter tells the function to operate the window of what property, in this process incoming GWL_STYLE value, other parameters available at MSDN; dwNewLong parameter is the value of a new window attributes. Standard window style is the title bar and scalable border, corresponding to the window style parameter value is WS_CAPTION and WS_THICKFRAME, so to achieve the full screen as long as the window style properties of these two values was removed to achieve the desired effect, the restoration of also very simple, you can re-add these two values.
Understanding of principles, the following programming practice we had!
:: Programming Practice::
Open VB, create a new standard EXE project, the project named as "MyFlashPlayer", in the control box to add CommonDialog, StatusBar, Slider, ShockwaveFlash control. Name the default property of the resulting window to "frmMyFlashPlayer", Caption to "My FlashPlayer", ScaleMode to "3 - Pixel", and then in turn add the following controls:
1,12 button (CommandButton), Name property were "cmdPlaySWF", "cmdPauseSWF", "cmdStopSWF",
"CmdRewindSWF", "cmdStepBackSWF", "cmdStepForwardSWF", "cmdGotoEndSWF",
"CmdFastBackSWF", "cmdFastForwardSWF", "cmdZoomInSWF", "cmdZoomOutSWF",
"CmdZoomNoSWF", Caption property under the "Play", "Pause", "stop", "replay", "Back," "ongoing" and "end frame", "rewind", "fast forward", "Zoom , "" reduce, "" normal. "
2,1 a paddling section (Slider), Name property SliderSWF, Max property to "100" (for 100%), TickStyle property to "3 - sldNoTicks". A status bar (StatusBar), double-click its properties "(Custom)" property page in the pop-up pane column, insert the two panes and two panes of the alignment is set to " ; 1 - sbrCenter ".
3,1 timer (Timer), Name property TimerSWF, Enabled property to "False", Interval property to "1000." A common dialog box (CommonDialog), Name property to "OpenDialogSWF", DialogTitle property to "open the Flash animation file", Filter property to "Flash animation files (*. swf) | *. swf | All files (*.* )|*.*", FilterIndex property to "1."
4,1 a ShockwaveFlash control, Name property MyShockwaveFlash, click the right mouse button pop-up shortcut menu, select "home front", to the top of all the controls, full-screen playback require this setting later in the source code I will explain its purposes.
5, open the menu editor, add the following menu: "File (& F)" (mnuFileSWF), "Open (& O)" (Ctrl + O) (mnuOpenSWF), "exit (& X)" (mnuExitSWF ), "see (& V)" (mnuViewSWF), "Quality (& Q)" (mnuQualitySWF), "high (& H)" (check) (mnuQualityHigh), "Chinese (& M)" (mnuQualityMedium), "Low (& L)" (mnuQualityLow), "loop (& L)" (check) (mnuLoopSWF), "shortcut menu (& M)" (check) (mnuMenuSWF), "Full-screen playback (& F)" (F11) (mnuFullScreenSWF). The "document" includes "open", "Exit", "View" including "quality", "loop", "shortcut menu", "full-screen playback," "quality" also includes "high", "China" "low."
Well, the interface design is complete, the effect shown in Figure 1.
Figure 1
Next we enter the following code:
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA"
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Window style parameter value''
Private Const WS_CAPTION = & HC00000
Private Const WS_THICKFRAME = & H40000
Private Sub cmdFastBackSWF_Click ()
5% back''
If MyShockwaveFlash.FrameNum> = 0 Then
MyShockwaveFlash.GotoFrame (
(SliderSWF.Value - SliderSWF.LargeChange) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only 0.01 backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news : 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only (MyShockwaveFlash.TotalFrames - 1))
End If
End Sub
Private Sub cmdFastForwardSWF_Click ()
5%''forward
If MyShockwaveFlash.FrameNum> = 0 Then
MyShockwaveFlash.GotoFrame (
(SliderSWF.Value + SliderSWF.LargeChange) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only 0.01 backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news : 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only (MyShockwaveFlash.TotalFrames - 1))
End If
End Sub
Private Sub cmdGotoEndSWF_Click ()
''To the last one
If MyShockwaveFlash.FrameNum> = 0 Then
MyShockwaveFlash.GotoFrame (MyShockwaveFlash.TotalFrames - 1)
End If
End Sub
[Next]
Private Sub cmdPauseSWF_Click ()
Pause''
Does not control''ShockwaveFlash typical multimedia player called "Pause" function
Only two do not see the difference between''function: StopPlay and Stop, are used to pause playback
MyShockwaveFlash.StopPlay
End Sub
Private Sub cmdPlaySWF_Click ()
Play''
MyShockwaveFlash.Play
End Sub
Private Sub cmdRewindSWF_Click ()
''Back to the first frame automatically starts to play
MyShockwaveFlash.Rewind
MyShockwaveFlash.Play
End Sub
Private Sub cmdStepBackSWF_Click ()
Back 1''
MyShockwaveFlash.Back
End Sub
Private Sub cmdStepForwardSWF_Click ()
Advance a''
MyShockwaveFlash.Forward
End Sub
Private Sub cmdStopSWF_Click ()
''Stop
General multimedia player''to stop the behavior is to stop playing and return to the first frame
ShockwaveFlash control''but there is no such function
''We can only "return to the first frame" and "pause" combination of two functions to achieve
MyShockwaveFlash.Rewind
MyShockwaveFlash.StopPlay
End Sub
Private Sub cmdZoomInSWF_Click ()
Zoom''doubled to 50% of the original
MyShockwaveFlash.Zoom (50)
End Sub
Private Sub cmdZoomNoSWF_Click ()
Normal size''
MyShockwaveFlash.Zoom (0)
End Sub
Private Sub cmdZoomOutSWF_Click ()
Double''reduced to the original 200%
MyShockwaveFlash.Zoom (200)
End Sub
Private Sub Form_Load ()
Set the Open File dialog box''signs are:
''File name and path must be valid, and does not show "open read-only (R)" Complex Options
OpenDialogSWF.Flags = cdlOFNFileMustExist Or cdlOFNPathMustExist Or cdlOFNHideReadOnly
End Sub
Private Sub Form_Resize ()
If Me.WindowState <> vbMinimized Then
''When the window is not minimized, the window size to adjust the controls according to the location and size
Otherwise, the height and width calculation''occurs when the error of non-positive
If Me.ScaleHeight> (cmdPlaySWF.Height + StatusBarSWF.Height + SliderSWF.Height) Then
MyShockwaveFlash.Move 0, cmdPlaySWF.Height + 8,
Me.ScaleWidth, Me.ScaleHeight - cmdPlaySWF.Height - StatusBarSWF.Height - SliderSWF.Height - 16
End If
SliderSWF.Top = Me.ScaleHeight - StatusBarSWF.Height - SliderSWF.Height
SliderSWF.Width = Me.ScaleWidth
StatusBarSWF.Panels (1). MinWidth = Me.ScaleWidth backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only 0.6
StatusBarSWF.Panels (2). MinWidth = Me.ScaleWidth backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only 0.2
StatusBarSWF.Panels (3). MinWidth = Me.ScaleWidth backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only 0.2
End If
End Sub
Private Sub mnuClose_Click ()
TimerSWF.Enabled = False
MyShockwaveFlash.Movie = "http://"''This parameter can only close the current movie, will go wrong if the incoming vbNullString
StatusBarSWF.Panels (1). Text = vbNullString
StatusBarSWF.Panels (1). ToolTipText = vbNullString
StatusBarSWF.Panels (2). Text = vbNullString
StatusBarSWF.Panels (3). Text = vbNullString
SliderSWF.Value = 0
End Sub
Private Sub mnuExitSWF_Click ()
Unload Me
End Sub
Private Sub mnuFullScreenSWF_Click ()
''Play in full screen, hide the playback controls and progress display
Dim ReturnValue As Long, WindowStyle As Long
mnuFullScreenSWF.Checked = Not mnuFullScreenSWF.Checked
If mnuFullScreenSWF.Checked Then
Change the window style,''no borders and no title for the article, and full screen
WindowStyle = GetWindowLong (Me.hwnd, GWL_STYLE)
ReturnValue = SetWindowLong (Me.hwnd, GWL_STYLE, WindowStyle - WS_CAPTION - WS_THICKFRAME)
Me.WindowState = vbNormal
Me.Move 0, 0, Screen.Width, Screen.Height
''Because ShockwaveFlash top of all the controls
''So, you can not hide the other controls full window
MyShockwaveFlash.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
Else
Style''to restore the normal window styles, and revert to the default size
WindowStyle = GetWindowLong (Me.hwnd, GWL_STYLE)
ReturnValue = SetWindowLong (Me.hwnd, GWL_STYLE, WindowStyle Or WS_CAPTION Or WS_THICKFRAME)
[Next]
Me.Move 0, 0, 488 backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only Screen.TwipsPerPixelX, 446 backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only Screen.TwipsPerPixelY
Me.Move (Screen.Width - Me.Width) 2, (Screen.Height - Me.Height) 2
End If
End Sub
Private Sub mnuLoopSWF_Click ()
Whether the loop''set ShockwaveFlash
mnuLoopSWF.Checked = Not mnuLoopSWF.Checked
MyShockwaveFlash.Loop = mnuLoopSWF.Checked
End Sub
Private Sub mnuMenuSWF_Click ()
Set ShockwaveFlash''shortcut menu is available
mnuMenuSWF.Checked = Not mnuMenuSWF.Checked
MyShockwaveFlash.Menu = mnuMenuSWF.Checked
End Sub
Private Sub mnuOpenSWF_Click ()
Open the Flash animation file''
On Error GoTo ErrorOpenSWF
OpenDialogSWF.ShowOpen
If OpenDialogSWF.FileName <> vbNullString Then
StatusBarSWF.Panels (1). Text = OpenDialogSWF.FileName
StatusBarSWF.Panels (1). ToolTipText = OpenDialogSWF.FileName
MyShockwaveFlash.Movie = OpenDialogSWF.FileName
TimerSWF.Enabled = True''starting to show playback progress
StatusBarSWF.Panels (2). Text = Format $ (MyShockwaveFlash.TotalFrames, "total # frames")
End If
Exit Sub
ErrorOpenSWF:
Open the Flash animation file''has a Bug:
''If you open a non-Flash animation Flash animation format or damaged, ShockwaveFlash control will result in exception error
After''but can not open any well-Flash animation, and that can not be given to the Movie property to any valid value, and only close the program and then re-run
''I guess the problem may be ShockwaveFlash control
MsgBox "not a valid Flash animation, or Flash animation is corrupted, the program will be shut down! ", VbCritical
Unload Me
End Sub
Private Sub mnuQualityHigh_Click ()
High quality''
MyShockwaveFlash.Quality2 = "High"''is equivalent to: MyShockwaveFlash.Quality = 1
mnuQualityHigh.Checked = True
mnuQualityMedium.Checked = False
mnuQualityLow.Checked = False
End Sub
Private Sub mnuQualityLow_Click ()
Low quality''
MyShockwaveFlash.Quality2 = "Low"''is equivalent to: MyShockwaveFlash.Quality = 0
mnuQualityHigh.Checked = False
mnuQualityMedium.Checked = False
mnuQualityLow.Checked = True
End Sub
Private Sub mnuQualityMedium_Click ()
Quality''in
MyShockwaveFlash.Quality2 = "Medium"''without the corresponding numeric value, only with the string assignment
mnuQualityHigh.Checked = False
mnuQualityMedium.Checked = True
mnuQualityLow.Checked = False
End Sub
Private Sub mnuWebOpen_Click ()
Dim SWFURL As String
SWFURL = InputBox ("enter the animation link address")
If SWFURL <> vbNullString Then
MyShockwaveFlash.Movie = SWFURL
End If
End Sub
Private Sub SliderSWF_Scroll ()
If MyShockwaveFlash.FrameNum> = 0 Then
''According to the percentage of the value of Article paddling Jump to animation playback progress
MyShockwaveFlash.GotoFrame (SliderSWF.Value backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news : 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only 0.01 backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr. sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only (MyShockwaveFlash.TotalFrames - 1))
Else
SliderSWF.Value = 0
End If
End Sub
Private Sub TimerSWF_Timer ()
''ShockwaveFlash control the progress of the event did not play
''So use the timer displays the current animation playback information
SliderSWF.Value = MyShockwaveFlash.FrameNum / (MyShockwaveFlash.TotalFrames - 1) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr . sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only 100
SliderSWF.ToolTipText = CStr (SliderSWF.Value) + "%"
StatusBarSWF.Panels (3). Text = Format $ (MyShockwaveFlash.FrameNum + 1, "No. 0")
End Sub
:: Conclusion::
Complete compile and run and run results shown in Figure 2.
Figure 2
Open a Flash animation, click the play control button, drag the article about paddling, try again play in full screen (Figure 3).
Figure 3 (click to enlarge)
Really cool!鑷虫涓?釜DIY鐨凢lash鎾斁鍣ㄥ埗浣滄垚鍔熶簡锛屾暣涓蒋浠剁殑婧愪唬鐮佷笉绠楀锛屼絾鍔熻兘鍗磋姣擣lash5鑷甫鐨勬挱鏀惧櫒寮哄ぇ鏃犳暟鍊嶅摝:)銆傜綉涓婃?鏈変汉闂浣曟垚涓洪珮鎵嬶紝鍏跺疄鍍忚繖鏍蜂翰鎵嬪仛涓?釜鍔熻兘瀹屾暣鐨勫皬杞欢灏辫兘鍦ㄥ紑鍙戣繃绋嬩腑閫愭笎鎻愰珮姘村钩銆?br />
銆??鏈▼搴忕殑绯荤粺鍏煎鎬ф瀬浣筹紝铏界劧绗旇?鏄熀浜嶧lash5鎾斁鎺т欢鍦╓in98SE+VB6涓皟璇曢?杩囩殑锛岀悊璁轰笂鍙Windows涓畨瑁呬簡Flash5鎾斁鎺т欢杞欢灏辫兘杩愯锛屾墍浠ユ垜鐩镐俊浠嶹in95鍒癢inXP閮芥槸鑳芥甯歌繍琛岀殑銆?br />
銆??濡傛灉浣犳槸DIY鍙戠儳涓?棌鍏奸珮鎵嬶紝杩樺彲浠ョ編鍖栦竴涓嬬晫闈紝灏嗙獥鍙e彉鎴愪綘鍠滄鐨勫舰鐘讹紝骞跺湪姝ょ▼搴忓熀纭?笂澧炲姞鏇村己澶х殑鍔熻兘锛氭挱鏀綞XE鏍煎紡鐨凢lash鍔ㄧ敾銆佹挱鏀惧垪琛ㄣ?闊抽噺鎺у埗銆佹埅鍙栨煇涓?抚鐨勫浘鐗囩瓑锛岄偅涔堟伃鍠滄伃鍠滐紝浣犲仛鍑轰簡涓栫晫涓婃渶瀹岀編鐨凢lash鎾斁鍣紒 ! !
相关链接:
youtube video formats
Avi to iphone
Background to Ren Zhengfei
Mr. Ma's reply to BILL Gates
SMG President Li Ruigang: IPTV Risk Is Too Cool The Temperature
News about Games Board
With a dinner of examples: MRP or APS
Dealer How To Effectively Distribution Issues?
Winamp batch format conversion and improve the playback Quality
I think the JSP problem (on)
Top Food And DRINK
How leaders "like contradicting the" get along with subordinates
Mp3 To 3g2
Converter flv to 3gp
Foxconn another sudden death, police said the two employees were excluded homicide
Games Arcade Specialist