call an actionscript 2.0 function from javascript

Posted on 2009-02-19
Last Modified: 2013-11-11
I want to simply call an actionscript function located in a flash movie on an html page from a javascript located on that page.  I understand this is possible using the Externalinterface in actionscript 2.0.  My actionscript function (located within the fla file located on the html page) is as follows:

import flash.external.ExternalInterface;
ExternalInterface.addCallback( "methodName", this, pauseFLV );

//function to pause a movie when javascript is called on html page
function pauseFLV():Void {
   videoplayButton._visible = true;
   videopauseButton._visible = false;
   playbutton._visible = true;
Here's the javascript that calls the actionscript function:

//pause the flash movie when javascript function is called
function stopFlash(){

where 'player_piccolo' is the ID of the flash movie.  It won't work when testing on local server and I can't figure out why. I know the actionscript function is error free because I tested it in flash.  However, when I preview the html page in a browser, I get a javascript error message saying 'player_piccolo is not defined'.

Question by:deeholzman
    LVL 8

    Accepted Solution

    What happens if you change

    ExternalInterface.addCallback( "methodName", this, pauseFLV );


    ExternalInterface.addCallback( "methodName", null, pauseFLV );

    or see the code box for an alternative javascript.

    Hope this works.

    <script language="javascript">
    function thisMovie(movieName) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[movieName];
        } else {
            return document[movieName];
    function doWhat(value) {
    javascript call: doWhat('player_piccolo');

    Open in new window


    Author Closing Comment

    Walter - yes, the alternative javascript worked - thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
    This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
    The goal of the tutorial is to teach the user how to how to record live broadcast.
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now