当点击浏览器关闭按钮时,我需要通过js调用actionscript 2函数。我怎样才能做到这一点?我尝试过,但没有成功。
AS2
import flash.external.*;
function test1() {
//do something
}
JS
<script type="text/javascript">
window.onbeforeunload = function(){
test1();
return 'text here' };
</script>
最佳答案
我可以在 ActionScript 3 中实现这一点。
JS代码:
window.onbeforeunload = function(){
var flashObj = document.getElementById('fla');
flashObj.changeText("closing");
return 'text here'
};
AS代码:
ExternalInterface.addCallback('changeText', changeText);
ss.text = "ello"
function changeText(val)
{
ss.text = val;
}
这里 ss 是一个动态文本字段。
关于javascript - 通过Javascript触发ActionScript函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23490813/