Copy link to clipboard
Copied
I'm trying to pass an identification name or number from Javascript so I can use one SWF to pass data based on the page.
This works with ActionScript 2 but can't figure out why it does not with ActionScript 3:
<script type="text/javascript">
tPageID = 145;
function getPageID() {
return tPageID;
}
</script>
Flash:
import flash.external.ExternalInterface;
var pageID = ExternalInterface.call("getPageID");
It seems it's always NULL with AS3.
Thanks for your help,
cpliu
then your embedding html may be the problem. change test2.swf to match your swf and fix the width/height values and try:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test2</title>
<style type="text/css" media="screen">
html, body { height:100%; background-color: #ffffff;}
body { margin:0; padding:0; overflow:hidden; }
#flashContent { width:100%; height:100%; }
</style>
<script type="text/javascript">
tPageID = 145;
fu
...Copy link to clipboard
Copied
put the script tags in the head tags so that executes before your swf is embedded.
Copy link to clipboard
Copied
Yes, the Javascript was located before the code to load SWF. This is on SharePoint. I even move the Javascript to a different web part ahead of the script loading the SWF but it didn't make any difference.
If I try to pass the value to a text field, it always gets the following error; I assume this was caused by the null data:
TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at AS_n_JS_AS3_fla::MainTimeline/frame1()
Copy link to clipboard
Copied
then your embedding html may be the problem. change test2.swf to match your swf and fix the width/height values and try:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test2</title>
<style type="text/css" media="screen">
html, body { height:100%; background-color: #ffffff;}
body { margin:0; padding:0; overflow:hidden; }
#flashContent { width:100%; height:100%; }
</style>
<script type="text/javascript">
tPageID = 145;
function getPageID() {
return tPageID;
}
</script>
</head>
<body>
<div id="flashContent">
<object type="application/x-shockwave-flash" data="test2.swf" width="550" height="400" id="test2" style="float: none; vertical-align:middle">
<param name="movie" value="test2.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
</object>
</div>
</body>
</html>
Copy link to clipboard
Copied
I then tested loading the SWF and included the Javascript in header with Dreamweaver. It works. I then compare the code from DW, and converted it a format acceptable to SharePoint then it works. THANKS for your help.
I don't know why, but the 2nd line below is the old one and if I switch to that line, SWF in AS3 does not pick up the data from Javascript. Maybe something wrong with the codebase=.... being not used anymore?
document.write("<object id='FlashModule' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='550' height='400'>")
//document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='550' height='400' id='freeflash_final' align='middle'>");
Copy link to clipboard
Copied
only some swf embedding methods are compatible with externalinterface. using an incompatible method causes externalinterface to fail.