It looks like you are new here. If you want to get involved, click on Join below!

AS3 External Interface - JS > Flash not working



First Post Mark as Spam platinum
Posts: 2 - Registered: 2007-01-31


Having a problem trying to get the external interface working with as3.

My flash file has 2 input text boxes with instances of 'received_ti' and 'sending_ti' and a button with instance of 'send_button'.

My html code has a simple form with 'sendField' and 'receivedField' inputs and a submit with a value of 'Send'.

At the moment i can get the flash file to send text into the html 'receivedField' input but cannot send text from html into the flash file's 'received_ti' text box.

Can anyone help me out with this? I am really struggling... My full code is below:

Flash AS3:
import flash.external.ExternalInterface;

ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript);

send_button.addEventListener("click", clickSend);

function getTextFromJavaScript(str:String):void {
received_ti.text = "From JavaScript: " + str;

function clickSend(event:Event):void {
var jsArgument:String = sending_ti.text;
var result:Object ="getTextFromFlash", jsArgument);
received_ti.text = "Returned: " + result;

HTML & Javascript:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Upload Start</title>
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>

<script type="text/javascript">
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
function formSend() {
var text = document.htmlForm.sendField.value;
function getTextFromFlash(str) {
document.htmlForm.receivedField.value = "From Flash: " + str;
return str + " received";


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="964" height="510" id="UploadStart">
<param name="movie" value="Upload_Start.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="Upload_Start.swf" width="964" height="510" id="UploadStart">
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><a href=""><img src="" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
<!--[if !IE]>-->

<form name="htmlForm" method="POST" action="javascript:formSend();">
Sending to ActionScript:<br />
<input type="text" name="sendField" value="" /><br />
<input type="submit" value="Send" /><br /> <br />
Received from ActionScript:<br />
<input type="text" name="receivedField"/>

Many thanks