veryserious
veryserious

Reputation: 305

Calling a JavaScript function from flash movie controls

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.

Upvotes: 1

Views: 4839

Answers (4)

Peter Bird
Peter Bird

Reputation: 11

use this Action code:

getURL("javascript:ActionJS()");

ActionJS is function on html file

read more => Call Js from Flash file

Upvotes: 0

Wessam El Mahdy
Wessam El Mahdy

Reputation: 467

  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>
    

Upvotes: 0

shanethehat
shanethehat

Reputation: 15580

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

AS:

ExternalInterface.call("pauseFunction");

JS:

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

Upvotes: 2

Jeff Wilbert
Jeff Wilbert

Reputation: 4520

An easy way is on the button controls simply call

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

Upvotes: 5

Related Questions