javascript调用Flash中的函数出错,记得以前调用是没问题的.现在都用问题了.
在MyEclipse中报错:
高手们帮忙看下,我是菜鸟.
please help me!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>InteractFlashJS.html</title>

    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->  </head>
  
  <body>
    <script type="text/javascript">
        function callJSFunction(string) {
            //document.writeln(string + '<br/>');
        }
        
        function thisMovie(movieName) {
            if (navigator.appName.indexOf("Microsoft") != -1) {
                return window[movieName]
            } else {
                return document[movieName]; 
            }            
        }
        
        function callFlashFunction() {
            var flashplayer = thisMovie('flashPlayer');
            flashplayer.flashCallBack();
            //document.write(flashplayer);  HTMLObjectElement      
        }
    </script>    
<br/>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="flashPlayer" width="500" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,14,0">
   <param name="movie" value="../../Flash_Demo/Study/InteractJavaScript/bin-debug/InteractJavaScript.swf">
   <param name="quality" value="high">
   <embed src="../../Flash_Demo/Study/InteractJavaScript/bin-debug/InteractJavaScript.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
</object>
<br/>
<button type="button" id="btn1" onclick="callFlashFunction()">调用Flash内部函数</button>
  </body>
</html>

解决方案 »

  1.   

    错误提示:flashplayer.flashCallBack is not a functionReason:
      flashplayer.flashCallBack is not a function-------------------------------------------------
      

  2.   

    可能是由安全沙箱引起的,尝试加入 allowScriptAccess="always" 
    我的
      

  3.   

    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="fileUpload" width="550" height="200"  align="middle" id="fileUpload">
    <param name="allowScriptAccess" value="always" />
             <param name="movie" value="aa.swf" />
              <param name="quality" value="high" />
            <param name="wmode" value="transparent">
           <PARAM NAME=FlashVars VALUE="uploadPage=Upload.axd<%=GetFlashVars()%>&completeFunction=UploadComplete()">
                <embed src="aa.swf"
                FlashVars="uploadPage=Upload.axd<%=GetFlashVars()%>&completeFunction=UploadComplete()"
                 quality="high" wmode="transparent" width="550" height="100" 
                 id="fileUpload" align="middle" allowScriptAccess="always" 
                 type="application/x-shockwave-flash" 
               pluginspage="http://www.macromedia.com/go/getflashplayer" />
            </object>
      

  4.   

    http://www.scriptlover.com/post/458
      

  5.   

    参见:Javascript与flash交互通信控制的方法
      

  6.   


    还是不行哦 。
    以前这个例子是可以的。好像是Flash10出现后就不行了。不知道是不是和Flash10有关。
      

  7.   

    to tantaiyizu,dh20156:基本原理都是一样的。
    就算是我把代码复制过来,还是不行。错误提示一样.
      

  8.   

    是由安全沙箱引起的,尝试加入 allowScriptAccess="always"
    这个我遇见过!
      

  9.   

    加了还是不行,一样的错误提示.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>InteractFlashJS.html</title>

        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        
        <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->  </head>
      
      <body>
        <script type="text/javascript">
            function callJSFunction(string) {
                //document.writeln(string + '<br/>');
            }
            
            function thisMovie(movieName) {
                if (navigator.appName.indexOf("Microsoft") != -1) {
                    return window[movieName]
                } else {
                    return document[movieName]; 
                }            
            }
            
            function callFlashFunction() {
                var flashplayer = thisMovie('flashPlayer');
                flashplayer.flashCallBack();
                //document.write(flashplayer);  HTMLObjectElement      
            }
        </script>    
    <br/>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="flashPlayer" width="500" height="400" 
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0">
       <param name="allowScriptAccess" value="always" /> 
       <param name="movie" value="../../Flash_Demo/Study/InteractJavaScript/bin-debug/InteractJavaScript.swf">
       <param name="quality" value="high">
       <embed src="../../Flash_Demo/Study/InteractJavaScript/bin-debug/InteractJavaScript.swf" 
        quality="high" 
    pluginspage="http://www.macromedia.com/go/getflashplayer" 
    type="application/x-shockwave-flash"
    align="middle" 
    allowScriptAccess="always" 
    >
    </embed>
    </object>
    <br/>
    <button type="button" id="btn1" onclick="callFlashFunction()">调用Flash内部函数</button>
      </body>
    </html>
      

  10.   

    差不多快好点.还有个安全沙箱的问题:
    SecurityError: Error #2060: 安全沙箱冲突:ExternalInterface 调用者 file:///E:/Web_Demo/InteractFlashJS/InteractJavaScript.swf 不能访问 file:///E:/Web_Demo/InteractFlashJS/InteractFlashJS.html。Flash中的代码:
    public function init():void {
    flash.system.Security.allowDomain("*");

    ExternalInterface.addCallback("flashCallBack", flashCallBack);
    }
    public function flashCallBack():String {
    mx.controls.Alert.show('sssssssssssss');   
    return 'call flash function succeed.';
    }为何还有这个问题呢?我两边都设置了允许访问.