javascript - I can't get ExternalInterface.addCallback to work - trying to call an AS3 function from a js button click -


I am trying to use ExternalInterface.addClallback to allow js to call as3 method. My code is as follows:

AS:

  ExternalInterface.addClallback ("sendToActionscript", callFromJavaScript); Function callfor_script (): zero {circle_mc.gotoAndStop ("end"); }  

JS:

  & lt; Button type = "button" onclick = "callToActionscript ()" & gt; Switch to Square & lt; / Button & gt; & Lt; Script type = "text / javascript" & gt; Function callToActionscript () {flashController = document.getElementById ("jstoactest") flashController.sendToActionscript (); } & Lt; / Script & gt;  

This is not working What am I doing wrong?

I set the flash read flag as JS in the flag. Then when your SWF loads, after the event. ADDED_TO_STAGE is removed, I add ExternalInterface.addClallBack and flap the flaped flag to TRUE. It prevents the call from the SWF before it's ready. You want to throw an alert in JS function below, to see if it is stuck. Hope this helps.

JS:

  var is flashedred = false; Function to this movie (movie name) (if (navigator.pn.im.exe ("microsoft")! = -1) return window [movie name];} and {return document [movieName];} function CallToActionScript {if (isFlashReady} {This is the movie ("SWFID"). SendToActionScript ();}} function Flash read (value) {isFlashReady = true;}  

AS :

  if (ExternalInterface.available) {try {ExternalInterface.addClallback ("sendToActionScript", callFromJavaScript); flash.external.ExternalInterface.call (flashReady, true);} hold (Error: SecurityAir ) {Trace ("A security error occurred:" + Error ("Error:" + error. + "\ N");}} and {trace ("external interface is not available for this container"). Is. ");}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -