I am new to AS3, and would like to trigger an as3 function from javascript.
AS3
package code {
import flash.display.MovieClip;
import flash.external.ExternalInterface;
import flash.text.TextFormat;
public class Main extends MovieClip {
public function Main() {
ExternalInterface.addCallback("changesize", this.setStyle);
}
protected function setStyle() {
var tf:TextFormat = new TextFormat();
tf.size = 15;
editabletext.setTextFormat(tf);
}
}
}
html
<html><head>
<meta charset="UTF-8">
<title>animator</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>
</head>
<body>
<div id="flashContent">
<object type="application/x-shockwave-flash" data="animator.swf" width="550" height="400" id="animator" style="float: none; vertical-align:middle">
<param name="movie" value="animator.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">
<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>
<script type="text/javascript">
var animator = document.getElementById('animator');
animator.changesize();
</script>
</body></html>
animator.changesize()
gives me Uncaught TypeError: animator.changesize is not a function
I have also tried changing allowscript access between sameDomain
and always
. neither seems to work