How can I call Flash function using JavaScript?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • forsiam
    New Member
    • Jan 2008
    • 1

    How can I call Flash function using JavaScript?

    I've seen the example in
    http://www.thescripts. com/forum/thread694359.ht ml

    but I still have problem about javascript. (I use SWFObject)

    My Action Script
    Code:
    import flash.external.ExternalInterface;
    
    
    var success:Boolean = ExternalInterface.addCallback("thisMethod",this, test);
    
    function test(){
    	displayTxt.text = "OK";
    }

    My Javascript & HTML
    Code:
    <script type="text/javascript" src="swfobject.js"></script>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function pause()
    {
    	var flash = document.getElementById("mymovie");
    	flash.thisMethod();
    }
    
    //-->
    </SCRIPT>
    
    <div id="flashcontent">This text is replaced by the Flash movie.</div>
    
    <script type="text/javascript">
       var so = new SWFObject("test.swf", "mymovie", "200", "80", "8");
       so.addParam("flashvars", "filename=music.mp3");
       so.addParam("allowScriptAccess", "always");
       so.write("flashcontent");
    </script>
    
    <INPUT TYPE="button" value="Pause" onclick="pause()">
    have anything wrong? thank you
Working...