最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Calling a JavaScript function from flash movie controls - Stack Overflow

programmeradmin10浏览0评论

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.

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.

Share Improve this question edited Nov 14, 2011 at 23:36 Marty 39.5k19 gold badges97 silver badges163 bronze badges asked Nov 14, 2011 at 22:20 veryseriousveryserious 3051 gold badge4 silver badges6 bronze badges 1
  • 1 Added the actionscript-2 tag to your question. It's nice to lock people who are willing to answer down to a specific language as this will yield you more accurate answers :) – Marty Commented Nov 14, 2011 at 23:38
Add a ment  | 

4 Answers 4

Reset to default 5

An easy way is on the button controls simply call

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

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

AS:

ExternalInterface.call("pauseFunction");

JS:

function pauseFunction() {
    alert("Called from ActionScript");
}
  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 mand to call the JavaScript function:

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

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

use this Action code:

getURL("javascript:ActionJS()");

ActionJS is function on html file

read more => Call Js from Flash file

发布评论

评论列表(0)

  1. 暂无评论