Home | Contact Us | Store

Send HTML TextField Contents to Flash

This Flash and HTML interactivity example demonstrate how to send text string from HTML Text Field (JavaScript functions) to Flash Movie (ActionScript functions).

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:

This Flash ActionScript and HTML JavaScript interactivity tutorial shows that you can use ExternalInterface.addCallback( ) to register the ActionScript function in the Flash Movie. Once the ActionScript function is registered in the Flash Movie, you can call it from the HTML Send button.

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;
<!-- Call the reference function (sendTextToFlash) -->
<!-- The getFlashMovie function will get a reference to the Flash movie object using its name. -->
getFlashMovie("FlashID").sendTextToFlash(text);
}
</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(str:String):void {
-- do Something;
}

Download Flash Source File:

Flash Source File Awaiting to be released.

Remarks:

This Flash ActionScript tutorial shows how to send text string from HTML Text Field to Flash Movie.

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