Using SWFObject in AS-JS Communication

38 views
Skip to first unread message

ayu

unread,
Nov 6, 2009, 4:59:10 AM11/6/09
to SWFObject
Hi! I am trying to learn this"

http://blog.circlecube.com/2008/02/01/actionscript-javascript-communication/


So I downloaded the zip file and placed the files in TEST folder. But
it is not workin in IE so the author found a new way of embedding
using SWFobject. He said he change the html file to this:

http://blog.circlecube.com/wp-content/uploads/2008/02/ActionscriptJavascriptCommunication2.html


I copied the code to my html (everything, just to test) and only
replaced this part

<script src="swfobject.js" type="text/javascript"> </script>


I also downloaded swfobject 2.2 zip and placed the swfpbject.js and
expressInstall.swf in my TEST folder. Flash is showing fine but the
script is not working.

in firefox this is the error: getElementById('flash').sendTextFromHtml
is not a function

in IE: Object doesnt support this property or method



PLEASE HELP ME T_T

Philip Hutchison

unread,
Nov 6, 2009, 12:41:55 PM11/6/09
to swfo...@googlegroups.com
ExternalInterface works fine with SWFObject 2.x

Here's an example (following instructions from an Adobe tutorial):
http://pipwerks.com/lab/swfobject/ExternalInterface/2.0/index.html

The most important things to note are:

1. If you're testing locally, you have to change your Flash Player security settings to allow the local location

2. You need to ensure your page and your SWF have finished loading before trying to invoke the ExternalInterface communication

- philip

aYu-SuiTs

unread,
Nov 9, 2009, 3:09:16 AM11/9/09
to swfo...@googlegroups.com
yes, global security settings is always allowed. Now, Flash text to javascript is working but javascript to flash is not. I got this error from IE:

'null' is null or not an object


here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Actionscript Javascript Communication from Circlecube</title>

<script src="swfobject.js" type="text/javascript"></script>
		<script type="text/javascript">
		swfobject.registerObject("flash", "9.0.0", "expressInstall.swf");
		
function recieveTextFromFlash(Txt) {

	document.getElementById('htmlText').value = Txt;

}

</script>

</head>



<body>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="400"><h1>From <a href="http://blog.circlecube.com">CircleCube.Com</a></h1> 

      <div align="center">Actionscript Javascript

      Communication</div>
      <form id="form1" name="form1" method="post" action="">

      <textarea name="htmlText" id="htmlText" cols="50" rows="15"> </textarea>

      <br />

      <input type="button" name="sendToFlash" id="sendToFlash" value="Send Text To Flash" onclick="getElementById('flash').sendTextFromHtml(htmlText.value); document.getElementById('htmlText').value = ''" />

    </form>

      Return to the post: <br />

      <a href="http://blog.circlecube.com/2008/02/01/actionscript-javascript-communication/">http://blog.circlecube.com/2008/02/01/actionscript-javascript-communication/</a></td>

    <td>

    









    <div align="left" id="myIdS">

    <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="450" height="450">
				<param name="movie" value="test.swf" />
        		<!--[if !IE]>-->
				<object type="application/x-shockwave-flash" data="test.swf" width="450" height="450">
				<!--<![endif]-->
				<div>
					<h1>Alternative content</h1>
					<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
				</div>
				<!--[if !IE]>-->
				</object>
				<!--<![endif]-->
			</object>

    </div></td>

  </tr>

</table>



</body>

</html>

--
aYu-SuiTs

Aran Rhee

unread,
Nov 9, 2009, 4:43:57 AM11/9/09
to swfo...@googlegroups.com
Your defined object id for your Flash file is <object id="myId" yet, you are trying to communicate to it as if its id is "flash". Ensure that your object id is consistent.


Aran

aYu-SuiTs

unread,
Nov 9, 2009, 6:38:48 AM11/9/09
to swfo...@googlegroups.com
oww.. i see. thanks!!!
--
aYu-SuiTs
Reply all
Reply to author
Forward
0 new messages