467,077 Members | 947 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

How can I call Flash function using JavaScript?

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

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

My Action Script
Expand|Select|Wrap|Line Numbers
  1. import flash.external.ExternalInterface;
  2.  
  3.  
  4. var success:Boolean = ExternalInterface.addCallback("thisMethod",this, test);
  5.  
  6. function test(){
  7.     displayTxt.text = "OK";
  8. }
  9.  

My Javascript & HTML
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="swfobject.js"></script>
  2. <SCRIPT LANGUAGE="JavaScript">
  3. <!--
  4. function pause()
  5. {
  6.     var flash = document.getElementById("mymovie");
  7.     flash.thisMethod();
  8. }
  9.  
  10. //-->
  11. </SCRIPT>
  12.  
  13. <div id="flashcontent">This text is replaced by the Flash movie.</div>
  14.  
  15. <script type="text/javascript">
  16.    var so = new SWFObject("test.swf", "mymovie", "200", "80", "8");
  17.    so.addParam("flashvars", "filename=music.mp3");
  18.    so.addParam("allowScriptAccess", "always");
  19.    so.write("flashcontent");
  20. </script>
  21.  
  22. <INPUT TYPE="button" value="Pause" onclick="pause()">
  23.  
have anything wrong? thank you
Jan 4 '08 #1
  • viewed: 8290
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Terry Haufler | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.