Home | Contact Us | Store

Send HTML TextArea Contents to Flash

This Flash and HTML interactivity example demonstrate how to send value of HTML TextArea to Flash Movie.

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

 

Enter text here and click Send to send the text to Flash Movie:

Flash Tutorial Content:

This Flash ActionScript and HTML JavaScript interactivity tutorial show how to interact HTML TextArea Field with Flash Movie. The TextArea Field is often used in HTML form. This flash example shows how to send the value of TextArea Field to Flash.

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 TextArea and a buttonon the HTML webpage. The JavaScript function sendText will be executed when the value of Select Menu is changed.

<form action="" id="myform">
Enter text here and click Send to send the text to Flash Movie:<br>
<textarea id="textArea" rows="6" cols="42">Enter text here.....</textarea>
<br>
<input type="button" value="Send" onclick="sendText();">
</form>

 

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

<script language="JavaScript">
//Get flash movie id (myFlash)
var myFlashMovie;
function init() {
if (document.getElementById) {
myFlashMovie = document.getElementById("myFlash");
}
}

//Wait the page to fully load before initializing
window.onload = init;

//Sending text of TextArea to Flash
function sendText() {
if (myFlashMovie) {
//call the function as a method of the Flash object (myFlashMovie)
//Call the registered ActionScript method (sendTextToFlash)
<!-- access the value of an HTML input by assigning it an id -->
var text = document.getElementById("textArea").value;
myFlashMovie.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", getTextFromJavaScript);

 

Step 2:
Hook with the ActionScript Function (getTextFromJavaScript)

Download Flash Source File:

Flash Source File Awaiting to be released.

Remarks:

This Flash ActionScript tutorial shows how to send HTML textArea Field value to Flash Movie.

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