Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Call Flash ActionScript from JavaScript HTML Button

This Flash and HTML interactivity example demonstrate how to use HTML Button with JavaScript functions to call ActionScript functions in Flash Movie. This is very easy to call the Actionscript in Flash with HTML button hook with JavaScript Functions.

Please update flash player to view this Flash ActionScript tutorial!

HTML Button Interact with Flash Movie:

Flash Tutorial Content:

This Flash ActionScript and HTML JavaScript interactivity tutorial shows how to create communication between HTML JavaScript and Flash ActionScript. It shows how to call the Flash ActionScript from two HTML buttons. The JavaScript Functions will be executed when the buttons are clicked. Then the JavaScript Functions will in turn make a call to the responsible ActionScripts of the Flash Movie.

The completed Flash Movie of this tutorial is shown as above. You may play around to see how it works.

Flash ActionScript and HTML Codes:

HTML Webpage Side:

Layout two buttons on the HTML webpage. The JavaScript functions will be executed when the buttons are clicked.

<input type="button" value="Display Message in Flash Movie"

<input type="button" value="Remove Message in Flash Movie"


Flash Side:

Step 1:
Use ExternalInterface.addCallback( ) to register the two ActionScript functions. Once the ActionScript functions are registered, they can be called by the JavaScript functions.

ExternalInterface.addCallback("runActionScript_1", asScriptFunction_1);

ExternalInterface.addCallback("runActionScript_1", asScriptFunction_2);


Step 2:
Hook with the ActionScript Functions


function asScriptFunction_1():void {
-- Print out text message


function asScriptFunction_2():void {
-- Remove text message

Download Flash Source File:

Flash Source File Awaiting to be released.


This Flash ActionScript tutorial shows how to call Flash ActionScript from HTML button with JavaScript.