[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

call an actionscript 2.0 function from javascript

Posted on 2009-02-19
2
Medium Priority
?
2,621 Views
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 {
   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
Comment
Question by:deeholzman
2 Comments
 
LVL 8

Accepted Solution

by:
wal_toor earned 2000 total points
ID: 23690844
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
 

Author Closing Comment

by:deeholzman
ID: 31549009
Walter - yes, the alternative javascript worked - thank you!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

864 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