源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

js与flash的交互FLASH连播控制器

  • 时间:2021-02-13 01:54 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:js与flash的交互FLASH连播控制器
该实例主要实现了js与flash的交互,运行前提是浏览器安装了flash插件! 前段时间领导提出的一个问题:能否实现多个flash的连续播放? 查了相关资料并通过自己的努力,最终实现了如下一个简单的Flash连续播放的js脚本。 该功能的实现实际上相当简单,主要是要了解js对flash控制的接口函数,知道了这些,问题的难度马上就降到了1+1=?的级别。
[u]复制代码[/u] 代码如下:
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的指定属性 
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部