欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2007年08月29日 19:14:19   作者:  
該實(shí)例主要實(shí)現(xiàn)了js與flash的交互,運(yùn)行前提是瀏覽器安裝了flash插件!

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

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與標(biāo)準(zhǔn)瀏覽器的差別   
    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;   
    }   
    //調(diào)試信息   
    $("curFlash").value=flashs[curFlash%flashLen];   
    $("totalFrames").value=totalFrames;   
    $("curFrame").value=curFrame;   
    $("playStatu").value=(isPlay?"播放中"+[".","..","..."][parseInt(curFrame/10)%3]:"停止");   
  }else{   
    //調(diào)試信息   
    $("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   
  //循環(huán)檢測并更新flash   
  setTimeout("updateMovie()",10);   
}  

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

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

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

Play() ---------------------------------------- 播放動畫 
StopPlay()------------------------------------停止動畫 
IsPlaying()----------------------------------- 動畫是否正在播放
GotoFrame(frame_number)---------------- 跳轉(zhuǎn)到某幀 
TotalFrames()------------------------------- 獲取動畫總幀數(shù) 
CurrentFrame()------------------------------回傳當(dāng)前動畫所在幀數(shù)-1 
Rewind()-------------------------------------使動畫返回第一幀 
SetZoomRect(left,top,right,buttom)-------放大指定區(qū)域 
Zoom(percent)------------------------------改變動畫大小 
Pan(x_position,y_position,unit)------------使動畫在x,y方向上平移 
PercentLoaded()----------------------------返回動畫被載入的百分比 
LoadMovie(level_number,path)----------- 加載動畫 
TGotoFrame(movie_clip,frame_number)- movie_clip跳轉(zhuǎn)到指定幀數(shù) 
TGotoLabel(movie_clip,label_name)------ movie_clip跳轉(zhuǎn)到指定標(biāo)簽 
TCurrentFrame(movie_clip)--------------- 回傳movie_clip當(dāng)前幀-1 
TCurrentLabel(movie_clip)-----------------回傳movie_clip當(dāng)前標(biāo)簽 
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指定標(biāo)簽上的action 
TGetProperty(movie_clip,property)--------獲取movie_clip的指定屬性 
TSetProperty(movie_clip,property,number)-設(shè)置movie_clip的指定屬性 

相關(guān)文章

最新評論