国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 辦公 > Flash > 正文

js與flash的交互FLASH連播控制器

2024-09-12 17:50:50
字體:
來源:轉載
供稿:網友
該實例主要實現了js與flash的交互,運行前提是瀏覽器安裝了flash插件!

前段時間領導提出的一個問題:能否實現多個flash的連續播放?
查了相關資料并通過自己的努力,最終實現了如下一個簡單的Flash連續播放的js腳本。
該功能的實現實際上相當簡單,主要是要了解js對flash控制的接口函數,知道了這些,問題的難度馬上就降到了1+1=?的級別。
復制代碼 代碼如下:

var flashs=[   
"http://60.210.98.23/theater/flash/2007-07/1436151_1183823655.swf",   
"http://www.flashempire.com/theater/flash/2007-08/1300680_1186654843.swf",   
"http://60.210.98.23/theater/flash/2007-05/1178503513_chinese.swf",   
"http://60.210.98.23/theater/flash/2007-07/1192848_1183734914.swf"  
];   

function makeFlashStr(url){   
  return '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="550" height="400" id="swf">/  
    <param name="bgcolor" value="#ffffff">/  
    <param name="movie" value="'+url+'">/  
    <param name="quality" value="high">/  
    <embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed></object>';   
}   

var curFlash=0;   
var flashLen=flashs.length;   
var $=function(obj){return document.getElementById(obj)}   
//判斷是否需要播放下一個flash   
function updateMovie(){   
  var swf=$("swf");   
  var swf_container=$("swfcontain");   
  if(swf.PercentLoaded()==100){   
    var totalFrames;   
    //IE與標準瀏覽器的差別   
    try{  //For Opera/FF   
      totalFrames=swf.TotalFrames();   
    }catch(e){  //For IE   
      totalFrames=swf.TotalFrames;   
    }   
    var curFrame=swf.CurrentFrame()+1;   

    var isPlay=swf.IsPlaying();   
    if(totalFrames==curFrame){   
      swfcontain.innerHTML=makeFlashStr(flashs[++curFlash%flashLen]);   
      $("flashList").selectedIndex=curFlash;   
    }   
    //調試信息   
    $("curFlash").value=flashs[curFlash%flashLen];   
    $("totalFrames").value=totalFrames;   
    $("curFrame").value=curFrame;   
    $("playStatu").value=(isPlay?"播放中"+[".","..","..."][parseInt(curFrame/10)%3]:"停止");   
  }else{   
    //調試信息   
    $("curFlash").value=flashs[curFlash%flashLen];   
    $("totalFrames").value="Loading Flash";   
    $("curFrame").value="Loading Flash";   
    $("playStatu").value="Loading Flash";   
  }   
  setTimeout("updateMovie()",100);   
}   
//手工指定要播放的flash   
function setMovie(index){   
  curFlash=index;   
  $("swfcontain").innerHTML=makeFlashStr(flashs[index]);   
}   
window.onload=function(){   
  var sel=$("flashList");   
  //初始化并生成flash列表   
  for(var i=0;i<flashLen;i++){   
    $("flashList").add(new Option(flashs[i],i));   
  }   
  setMovie(0);  //播放第一個flash   
  //循環檢測并更新flash   
  setTimeout("updateMovie()",10);   
}  

另奉上js與flash的操作接口函數,一方面自己備忘,另一方面希望對這個程序有興趣的朋友能有所幫助。

--------------------------------------------------------------------------------

可控制Flash Player的Javascript方法一覽表:

Play() ---------------------------------------- 播放動畫 
StopPlay()------------------------------------停止動畫 
IsPlaying()----------------------------------- 動畫是否正在播放
GotoFrame(frame_number)---------------- 跳轉到某幀 
TotalFrames()------------------------------- 獲取動畫總幀數 
CurrentFrame()------------------------------回傳當前動畫所在幀數-1 
Rewind()-------------------------------------使動畫返回第一幀 
SetZoomRect(left,top,right,buttom)-------放大指定區域 
Zoom(percent)------------------------------改變動畫大小 
Pan(x_position,y_position,unit)------------使動畫在x,y方向上平移 
PercentLoaded()----------------------------返回動畫被載入的百分比 
LoadMovie(level_number,path)----------- 加載動畫 
TGotoFrame(movie_clip,frame_number)- movie_clip跳轉到指定幀數 
TGotoLabel(movie_clip,label_name)------ movie_clip跳轉到指定標簽 
TCurrentFrame(movie_clip)--------------- 回傳movie_clip當前幀-1 
TCurrentLabel(movie_clip)-----------------回傳movie_clip當前標簽 
TPlay(movie_clip)---------------------------播放movie_clip 
TStopPlay(movie_clip)----------------------停止movie_clip的播放 
GetVariable(variable_name)-----------------獲取變量 
SetVariable(variable_name,value)-----------變量賦值 
TCallFrame(movie_clip,frame_number)---call指定幀上的action 
TCallLabel(movie_clip,label)----------------call指定標簽上的action 
TGetProperty(movie_clip,property)--------獲取movie_clip的指定屬性 
TSetProperty(movie_clip,property,number)-設置movie_clip的指定屬性 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泸州市| 宁远县| 独山县| 遵义县| 留坝县| 涡阳县| 炉霍县| 都匀市| 溧水县| 沅陵县| 沂水县| 平邑县| 淮安市| 佳木斯市| 武平县| 鄂伦春自治旗| 衡水市| 西青区| 大渡口区| 盐山县| 荥经县| 北安市| 普安县| 建昌县| 青川县| 昌都县| 翁牛特旗| 信阳市| 麻江县| 赤壁市| 炎陵县| 辽源市| 靖边县| 新安县| 榆社县| 双柏县| 贵德县| 屏东市| 雷州市| 高唐县| 汉源县|