Posted By

StevenW721 on 11/10/10


javascript actionscript function trigger as3

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Trigger Javascript from Flash with AS3

 / Published in: ActionScript 3

Short and sweet, add the following two lines where you want to trigger a javascript function. Just change the javascript denoted in the code by "javascriptFunction()" with whatever you want to call. Also jsut in case make sure you have the allowScriptAccess parameter set to "always".

  1. var runJavascript:URLRequest = new URLRequest("javascript:javascriptFunction()");
  2. navigateToURL(runJavascript, "_top");

Report this snippet  


RSS Icon Subscribe to comments
Posted By: jirirybar on November 11, 2010

Do we need the "_top" thing there?

Posted By: StevenW721 on November 17, 2010

Hey jirirybar, the second parameter works much like the target attribute of a link in HTML. If you don't specify one the default is to trigger this action in a new window (and in my opinion ruining the purpose of this snippet). That said I use "top" most of the time but have had to use "parent" on occasion when the flash was in an iframe. Hope that helps!

You need to login to post a comment.