How to trigger javascript function from Flash using Actionscript 3

After dealing with this situation for about two hours, I have decided to blog this so that you will easily implement your own code into your web page.

First of all calling events for buttons in flash has changed a little in Actionscript 3. The new code to implement event is as the following…

btnA.addEventListener(MouseEvent.CLICK, onClickbtnA);
function onClickbtnA(event:MouseEvent):void
{
 ExternalInterface.call("funct(\"E3A\")");
}

At the example above, btnA is the name of the button and funct(string) is the name of the javascript function in the page. addEventListener function is the new way to implement events in Actionscript 3.

 That’s it. When you click btnA the “funct” javascript function will be triggered.

Popularity: 4% [?]

Tags: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>