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

Send Multiple Parameters from HTML TextField to Flash

This Flash and HTML interactivity example demonstrate how to send multiple parameters from a TextField (JavaScript) to Flash ActionScript.

Please update flash player to view this Flash ActionScript tutorial!

 

Send Message to Flash:


Flash Tutorial Content:

In previous Flash ActionScript and HTML JavaScript interactivity tutorial, we only pass the text in TextField to the Flash Movie. Actually you can pass multiple parameters along with the TextField. This example show you how to do that.

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:


Step 1:
Layout a Text Field with a button on the HTML webpage. The JavaScript function formSend will be executed when the buttons are clicked.

<form name="htmlForm" method="POST" action="javascript:formSend();">
<input type="text" name="sendField" size="28">
<input type="submit" value="Send">
</form>

 

Step 2:
Write the JavaScript function formSend. The JavaScript function will make a call to ActionScript function sendTextToFlash.

<script language="JavaScript">
function formSend() {
<!-- Obtain value of field "sendField" -->
var text = document.htmlForm.sendField.value;
<!-- Pass more parameters to Flash -->
var xLoc = 100;
var moreText = "I am fine!";
<!-- Call the reference function (sendTextToFlash) -->
<!-- The getFlashMovie function will get a reference to the Flash movie object using its name. -->
getFlashMovie("myFlash").sendTextToFlash(text, xLoc, moreText);
}
</script>

 

Flash Side:


Step 1:
Use ExternalInterface.addCallback( ) to register the ActionScript function. Once the ActionScript functions is registered, it can be called by the JavaScript function.

ExternalInterface.addCallback("sendTextToFlash", asScriptFunction);

 

Step 2:
Hook with the ActionScript Functions

 

function asScriptFunction(str1:String, str2:Number, str3:String):void {
-- do Something;
}

Download Flash Source File:

Flash Source File Awaiting to be released.

Remarks:

This Flash ActionScript tutorial shows how to send multiple parameters from HTML Text Field to Flash Movie.