Home | Contact Us | Store

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.

Flash ActionScript and HTML JavaScript communication example display here. Your flash player version is too old to see this flash example!

 

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.

Call Flash ActionScript from HTML JavaScript Call HTML JavaScript from FlashActionScript Float Advertisement Sliding Out