VB 调用flash为什么播放flash的时候会卡?
各位大侠,洒家用的是VB6.0企业版,程序里调用了flash (.swf文件)用的是ShockwaveFlash控件。但是程序播放flash 的时候会一卡一卡的,隔三四秒会停顿一下。是什么的原因呢?flash文件大小21.9 MB
[解决办法]
flash 缓存太小,下载速度小于播放速度。
[解决办法]
VB的Flash这个控件 一点问题都没有 试看我这代码与你的有啥不同 ?
Option Explicit
Dim AppDisk$, FlashName$, FlashLength&
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
AppDisk = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\")
ShockwaveFlash1.ScaleMode = 0 '将画面大小设置为在控件内保持动画原来比例全部显示
Option1(0).Value = True: Check1.Value = 1
Text1.Text = AppDisk & "cars.swf"
Timer1.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
ShockwaveFlash1.Stop
Set Form1 = Nothing
End
End Sub
Sub SelFile()
On Error GoTo ErrH
FlashName = ""
With CommonDialog1
.DialogTitle = "请选择文件"
.CancelError = True
.InitDir = AppDisk
.Filter = "FLASH格式(*.swf)|*.swf"
.ShowOpen
End With
FlashName = CommonDialog1.FileName
If FlashName <> "" Then Text1.Text = FlashName
ErrH:
If Err = 32755 Then Exit Sub
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0 '打开
Call SelFile
If Text1.Text <> "" Then
If Dir(Text1.Text) <> "" Then Command1_Click (1)
End If
Case 1 '播放
Command1_Click (6)
ShockwaveFlash1.Movie = Text1.Text '打开文件
ShockwaveFlash1.Playing = True '开始播放动画。
FlashLength = ShockwaveFlash1.TotalFrames
Label3.Caption = "本播放文件共有: " + CStr(FlashLength) + " 帧"
Slider1.Max = FlashLength
Timer1.Enabled = True
Case 2 '跳到动画的上一帧
ShockwaveFlash1.Back
Case 3 '跳到动画的下一帧
ShockwaveFlash1.Forward
Case 4 '放大画面。
ShockwaveFlash1.Zoom (50)
Case 5 '缩小画面。
ShockwaveFlash1.Zoom (150)
Case 6 '暂停
ShockwaveFlash1.Stop
Case 7 '退出程序
Unload Me
End Select
End Sub