zoukankan      html  css  js  c++  java
  • JS判断Flash是否播放结束

    • JS判断Flash是否加载完成
    (function () {  var flash = 网页上某个flash对象。   
     var interval = setInterval(function () 
    {  
    
    try {  if(flash.IsPlaying()) { 
    
    //轮询flash的某个方法即可 
     callBack && callBack.call(flash, args); 
    //回调函数  clearInterval(interval);  
    } 
    }
     catch (ex) {    
    }  }, 1000);    var callBack = function () {  alert('loaded');  }  })();

    具体运用时,flash放进setInterval或者setTimeout的函数闭包中时,可能会由于JavaScript单线程问题,导致flash不能调用IsPlaying等flash player函数或者调用结果不对等状况,这里有个临时的解决办法,我们可以读取在轮询函数中读取flash的TotalFrames属性,读取得到,我们就可以认为flash已经完全加载到页面中了。

    • JS判断Flash是否播放结束到最后一帧
    <script type="text/javascript"> 
    
    function gotoTestPage(){
    
        //get flash obj, only work normally in IE
        var flash = document["Shockwaveflash1"];
        
        //get current page number
        var currentFrame=flash.CurrentFrame();
        
        //30 is the total, if end
        if(currentFrame==30 && $('#isOpen').html()=="0"){
            $('#isOpen').html("1");
            alert("Please start to do the test.");
            
            //popup the page with sharepoint dialogue window
            OpenPopUpPage("/en/hr/Pages/ISOnlineTest.aspx",function() {window.location.href="/en/hr/Pages/InformationSecurityTraining.aspx";},960,800);
        }
    }
    
    //go to the function each 5 seconds
    setInterval(gotoTestPage,5000);
     </script>
     
     //set open popup page status
    <div id="isOpen" style="display: none">0</div>

    /*后面附上可控制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的指定属性

  • 相关阅读:
    node.js---sails项目开发(3)
    node.js---sails项目开发(2)
    基于 phantomjs 的自动化测试---(1)
    node.js---sails项目开发(1)
    mongoose基于mongodb的数据评论设计
    js复杂数据格式提交
    [LeetCode]Rotate Image
    [LeetCode]Minimum Path Sum
    [LeetCode]Generate Parentheses
    [LeetCode]Gray Code
  • 原文地址:https://www.cnblogs.com/batter152/p/4377608.html
Copyright © 2011-2022 走看看