首页新闻找找看学习计划

js调用flex方法出错

0
悬赏园豆:15 [已关闭问题] 关闭于 2013-07-17 16:15

html页面代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <SCRIPT language='JavaScript' charset='utf-8'>
        function callApp() {
            var x = document.getElementById("MyFlexApp").myFlexFunction();
            //var x = MyFlexApp.myFlexFunction();
            alert(x);
        }
</SCRIPT>

</head>
<body>
<button onclick="callApp()">Call App</button>
</body>
</html>


mxml代码:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
    import flash.external.*;
    public function myFunc():Number {
        return 42;
    }
    public function initApp():void {
        ExternalInterface.addCallback("myFlexFunction",myFunc);
    }
</mx:Script>
</mx:Application>


提示:无法获取属性“myFlexFunction”的值: 对象为 null 或未定义。

L875155279的主页 L875155279 | 初学一级 | 园豆:26
提问于:2013-06-02 21:54
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册