I’m new to the whole Action Script / Flash world…but trying to teach myself enough to get something done.
I’m sure the answer to this is simple…but I have a .as file with the following code in it:
package
{
import flash.external.ExternalInterface;
public class Sender
{
public function Sender()
{
ExternalInterface.call("func1()");
}
}
}
I’ve got a fla with the following code (I’ve touched nothing else):
import Sender;
var mySender:Sender = new Sender();
Now after publishing, I made some tweaks to the html file (included below)….and my Javascript gets called (yay!). Unfortunately, after dismissing the alert, it gets called again…and again…….and again. I have no clue why (I have verified that my flash movie isn’t set to loop, but that’s all I have). Any help would be greatly appreciated!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>sender</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<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>
function func1()
{
alert('hello external stuff');
}
</script>
</head>
<body>
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="1" height="1" id="sender" align="middle">
<param name="movie" value="sender.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="always" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="sender.swf" width="1" height="1">
<param name="movie" value="sender.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="always" />
<!--<![endif]-->
<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>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</body>
</html>
In the html code you posted, it says
It is possible that this is the cause.
EDIT: Maybe you only checked in the IDE if the
.swffile exported was to loop, but the html generated by CS5 put in the tag regardless.EDIT2: I agree with gmale that you should put
stop();in your code. If you put your code anywhere else (or if you want someone else to use it) they might haveloopset to true, in which case coding it to be foolproof is your only way to ensure that it doesn’t loop. This principle applies to all AS3 code.