• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2630
  • Last Modified:

call an actionscript 2.0 function from javascript

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 {
   ns.pause();
   videoplayButton._visible = true;
   videopauseButton._visible = false;
   ns.pause(true);
   ns_paused=true;
   playbutton._visible = true;
}
------------------------------------
Here's the javascript that calls the actionscript function:

//pause the flash movie when javascript function is called
function stopFlash(){
                    
        player_piccolo.methodName();
            
}

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'.

0
deeholzman
Asked:
deeholzman
1 Solution
 
wal_toorCommented:
What happens if you change

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

to

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

or see the code box for an alternative javascript.

Hope this works.

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

Open in new window

0
 
deeholzmanAuthor Commented:
Walter - yes, the alternative javascript worked - thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now