Calling a JavaScript function from flash movie controls

半世苍凉 提交于 2019-12-11 05:08:59

问题


I have a swf streaming an flv with the default controls from Flash. Is there a way to call a javascript function when the pause button is clicked? And then another when the play button is clicked?

Thanks for any ideas.


回答1:


An easy way is on the button controls simply call

getURL("javascript:yourFunction();");



回答2:


The best way to do this is using ExternalInterface. Here's an example:

AS:

ExternalInterface.call("pauseFunction");

JS:

function pauseFunction() {
    alert("Called from ActionScript");
}



回答3:


  1. Import the ExternalInterface library to your action script by using the line:

    import flash.external.ExternalInterface;
    

    Note: without this line you will not be able to call the JavaScript function.

  2. Use this command to call the JavaScript function:

    ExternalInterface.call("pauseFunc", "");
    
  3. In your HTML page, add your JavaScript function:

    <script>
    function pauseFunc() {
       doSomthing ...
    }
    </script>
    



回答4:


use this Action code:

getURL("javascript:ActionJS()");

ActionJS is function on html file

read more => Call Js from Flash file



来源:https://stackoverflow.com/questions/8129016/calling-a-javascript-function-from-flash-movie-controls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!