2011-03-07 3 views
1

내 AIR/Flex 응용 프로그램에서 javascript 함수를 호출하는 데 문제가 있습니다. 웹 응용 프로그램에서는 externallInterface를 사용하는 것이 쉽지만 기본 응용 프로그램에서는 문제가됩니다. 때 : 내 AIR 애플리케이션은Javascript 함수를 호출하는 Flex/AIR

<?xml version="1.0" encoding="utf-8"?> 
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" 
initialize="init()" ... > 


<mx:Script> 
     <![CDATA[ 

     private function init():void 
      { 
       myHTML.addEventListener(Event.HTML_DOM_INITIALIZE,DOMInit); 
       myHTML.location="myAIRHTML.html"; 

      } 

      private function DOMInit(e:Event):void{ 
       myHTML.htmlLoader.window.inputFunction = testInputFunction;    
      } 
     private function testInputFunction(so:String):void{ 
     //some code ...... 
     } 

     public function someFunction(e:AIREvent):void{ 
       myHTML.htmlLoader.window.outputFunction(e.param); 
      } 

      _]]> 
</mx:Script> 

<mx:HTML id="myHTML" width="5" height="5" visible="true" /> 

</mx:WindowedApplication> 

myAIRHTML.html이

<html>  
    <head> 
     <script language="Javascript"> 


      var interface = {};  

      function outputFunction(param){  
       var childInterface = document.getElementById("mySandbox").childSandboxBridge; 

       childInterface.remoteFunction(param); 
      } 


      interface.inputFunction = function(someData){ 
       testInputFunction(someData); 
      }         
      function initBridge(){ 
       document.getElementById("mySandbox").parentSandboxBridge = interface; 
     } 
     </script> 
    </head>  
    <body>   
     <iframe id="mySandbox" 
      src="js.html" 
      sandboxRoot="http://remote.example.com/js/" 
      documentRoot="app:/myAIRSandbox/" 
     ondominitialize="initBridge()"> 
     </iframe> 
    </body> 
</html> 

입니다 .... 이런 유사하며 js.html는

<html>   
<head> 
    <script language="Javascript" src="http://www/otherexample.com/other.js"></script> 

     <script language="Javascript" > 

      var interface = {}; 

      interface.remoteFunction = function(st){ 
       alert("st"); 
       callFunctionInOtherJS(st); 
      } 


      window.childSandboxBridge = interface;      

      var someObject = {}; 

      someObject.SomeFunction = function(someParam){ 
       window.parentSandboxBridge.inputFunction(someParam); 
      } 

     </script> 
    </head> 

    <body ></body> 
</html> 

이 던져이다 "정의되지 않은 값 형식 오류" myAIRHTML.html에서 "remoteFunction"을 호출합니다. 내가 놓친 중요한 것. 누구든지 도와 줄 수 있습니까? 뭔가 중요한 내가 documentRoot에 대해 잊어 버린 것 - 다른 장소에서이 이름을 사용하지 마십시오 ..... 모든 답장을 보내 주십시오.

답변

0

어쨌든 나는 이것이 당신의 오류라고 이해한다면 다소 혼란스러워 보입니다.

당신이 testInputFunction (someData)를 호출 할 수 없습니다 myAIRHTML.html이

myHTML.htmlLoader.window.inputFunction = testInputFunction; 

당신의 js를 정의하는 경우; 하지만 AS3 함수 testInputFunction을 inputFunction이라는 변수에 전달 했으므로 inputFunction (someData)

희망이 도움이되었습니다.

관련 문제