我无法让我的 Javascript 影响我的 SWF 对象。该对象在浏览器中正确呈现,但我无法调用暴露给 ExternalInterface 的“填充”方法。未调用就绪函数“flashReady”。从控制台直接调用它表示flash对象没有“填充”功能。等待一段时间然后调用该函数无济于事。
错误是类型错误:Object HTMLObjectElement has no method 'fill'
动作脚本代码:
public class Main extends Sprite
{
public function Main() {
graphics.beginFill(0xff0000);
graphics.drawRect(0, 0, 200, 100);
graphics.endFill();
Security.allowDomain("*");
ExternalInterface.addCallback("fill", fill);
ExternalInterface.call("flashReady");
}
public function fill():void {
graphics.beginFill(0x00ff00);
graphics.drawRect(0, 0, 200, 100);
graphics.endFill();
}
}
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>
Flash UI Demo
</title>
<script type="text/javascript" src="swfobject.js">
</script>
<script type="text/javascript">
function flashReady() {
document.getElementById('AddCallbackExample').fill();
}
var swfVersionStr = "0";
var xiSwfUrlStr = "";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "#ffffff";
params.allowscriptaccess = "always";
var attributes = {};
attributes.id = "AddCallbackExample";
attributes.name = "AddCallbackExample";
attributes.align = "middle";
swfobject.embedSWF(
"http://localhost:8001/swf", "flash",
"100%", "100%",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
</script>
</head>
<body>
<div id="flash" />
</body>
</html>