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 HTML TextArea Contents to Flash

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

Please update flash player to view this Flash ActionScript tutorial!

 

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.