首先,swfobject调用Flash文件比较简单。
1、引入swfobject.js文件。
<script src='swfobject2.2.js' type='text/javascript'></script>
2、编写调用脚本。
Public Sub LoadFlash()
Dim swfName As String = GlobalBusiness.GetFlashServerVirtuaPath & "/VideoServer.swf"
Dim strFlashcode As New StringBuilder
strFlashcode.Append("<script type='text/javascript'>" & vbCrLf)
strFlashcode.Append(" var params = {" & vbCrLf)
strFlashcode.Append(" bgcolor: '#ffffff'," & vbCrLf)
strFlashcode.Append(" allowfullscreen: 'true'," & vbCrLf)
strFlashcode.Append(" allowScriptAccess: 'always'," & vbCrLf)
strFlashcode.Append(" pluginspage: 'http://www.adobe.com/go/getflashplayer'," & vbCrLf)
strFlashcode.Append(" quality: 'high'" & vbCrLf)
strFlashcode.Append(" };" & vbCrLf)
strFlashcode.Append(
" var attributes = {" & vbCrLf)
strFlashcode.Append(
" id: 'myView'," & vbCrLf)
strFlashcode.Append(
" name: 'myView'" & vbCrLf)
strFlashcode.Append(
" };" & vbCrLf)
strFlashcode.Append(
" var flashvars = {" & vbCrLf)
strFlashcode.Append(
" videoWidth: 0," & vbCrLf)
strFlashcode.Append(
" videoHeight: 0," & vbCrLf)
strFlashcode.Append(
" role:'" & Rose & "'," & vbCrLf)
strFlashcode.Append(
" Id:'" & ChapterID & "'," & vbCrLf)
strFlashcode.Append(
" picxml:'" & arrFileName(0) & "'," & vbCrLf)
strFlashcode.Append(
" picpath:'" & String.Concat(GlobalBusiness.GetFlashServerVirtuaPath, "/Profile/VideoClass/", ChapterID, "/") & "'" & vbCrLf)
strFlashcode.Append(
" };" & vbCrLf)
strFlashcode.Append(
" swfobject.embedSWF('" & swfNameRight & "', 'myContent', '420', '300', '8.0.0', '', flashvars, params, attributes);" & vbCrLf)
strFlashcode.Append(
" var leftparams = {" & vbCrLf)
strFlashcode.Append(
" bgcolor: '#000000'," & vbCrLf)
strFlashcode.Append(
" allowfullscreen: 'true'," & vbCrLf)
strFlashcode.Append(
" allowScriptAccess: 'always'," & vbCrLf)
strFlashcode.Append(
" pluginspage: 'http://www.adobe.com/go/getflashplayer'," & vbCrLf)
strFlashcode.Append(
" quality: 'high'" & vbCrLf)
strFlashcode.Append(
" };" & vbCrLf)
strFlashcode.Append(
" var leftattributes = {" & vbCrLf)
strFlashcode.Append(
" id: 'myVideo'," & vbCrLf)
strFlashcode.Append(
" name: 'myVideo'" & vbCrLf)
strFlashcode.Append(
" };" & vbCrLf)
strFlashcode.Append(
" var leftflashvars = {" & vbCrLf)
strFlashcode.Append(
" videoWidth: 0," & vbCrLf)
strFlashcode.Append(
" videoHeight: 0," & vbCrLf)
strFlashcode.Append(
" role:'" & Rose & "'," & vbCrLf)
strFlashcode.Append(
" Id:'" & ChapterID & "'};" & vbCrLf)
strFlashcode.Append(
" swfobject.embedSWF('" & swfName & "', 'myVideoClass', '256', '192', '9.0.0', '', leftflashvars, leftparams, leftattributes);" & vbCrLf)
strFlashcode.Append(
"</script>" & vbCrLf)
flashControlScript.Text = strFlashcode.ToString
End Sub