js获取flash文件总帧数

JavaScript019

js获取flash文件总帧数,第1张

1、在HTML中,使用JavaScript嵌入swf文件(test.swf),并且赋予id,name(比如 swfobj)

      <embed src='test.swf' width='500px' height='500px' id='swfobj' name='swfobj'></embed>

2、获取当前播放帧数:var currentFrame= swfobj.CurrentFrame()    

      获   取    总   帧  数:var totalFrames=swfobj.TotalFrames()

3、如果要在swf播放完后移除它,在定时器中监听时,判断条件  swfobj.CurrentFrame()>=swfobj.TotalFrames()-1(或者==,感觉>=更加保险  )   是否为true。  CurrentFrame的最大值为总帧数-1

/*附上可控制Flash Player的js方法列表*/

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的指定属性

flash 调用js 最简单的方法是 :

getURL("javascript:function()")//function 为此FLASH所在页面的JS函数名.

js 传递变量给 flash 最简单的方法是:

flash.setVariable("变量名","变量值")//flash为此FLASH的id

你说的情况真的不是很明白``希望上面的能对你有用``

其实JS可以直接控制FLASH的播放``你可以在网上自己去找

使用flash.external.ExternalInterface

步骤一:flash中定义可以访问的函数hello

flash as文件中的关键代码:

import flash.external.ExternalInterface  

function hello(){  

        return "测试成功了哦~~"  

    } 

//允许js调用flash中的函数 参数1:要调用flash函数的js函数,参数2:被调用flash函数  

ExternalInterface.addCallback("helloas",hello)

步骤二:js中定义可以访问的函数hello和flash文件加载

<script type="text/javascript">  

  function hello(v)  

  {  //js中定义的测试函数

      alert(v)   

  }  

</scritp>

<body>

  //flash组件

  <object  id="test" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="" width="560" height="270"> </object>

</body>

步骤三:flash访问js中的hello方法

ExternalInterface.call("hello", "jacky")

步骤四:js访问flash的hello方法

document.getElementById("test").helloas()