1

Flash의 버튼에서 jQuery로 작성된 함수를 호출하기 만하면됩니다.
jQuery의 $ (document) 밖에 함수를 배치하면 .ready 잘 작동합니다.
* btw Flash를 포함하기 위해 SWFObject를 사용합니다.Flash AS3 ExternalInterface에서 jQuery 문서의 함수를 호출 할 준비가되었습니다.

AS3 :

import flash.external.ExternalInterface; 
function test_fnc(event:Event):void { 
    ExternalInterface.call("jsFunction", "hello world"); 
} 
test_mc.addEventListener("click", test_fnc); 

JS : 플래시 jsFunction 호출이 정의되지한다시

<script type="text/javascript">  
    function jsFunction(words) { 
     alert(words); // "hello world"; 
    } 
    $(document).ready(function() { 
     // not from here 
    }); 
</script> 
+0

정말 당신이 무엇을 요구하는지 분명치 않습니다. 왜 $ (document) .ready 내에서 함수를 정의해야합니까? – spender

+0

내가 jQuery를 사용하여 만든 배열에 액세스해야합니다. \t \t \t \t VAR alt_array = $ ("# 섬네일 IMG")를지도를 (함수() { \t \t \t \t \t 반환 $ (이) .attr ("고도 "); \t \t \t \t}); – FFish

답변

1

. ExternalInterface 호출이 발생한 후 $(document).ready이 실행중인 경쟁 조건이 있으므로 $(document).ready에 정의 된 내용이 아직 실행되지 않았기 때문에 Flash가 호출 할 때 사용할 수 없습니다. 귀하의 코멘트에 대한 응답으로

:

당신은 플래시 모두 준비하고 문서가이 작업을 준비 할 필요가있다. 나는 초기화의 순서가 확실하지 않으므로 Flash에서 JS가 준비되었음을 알리는 알려진 함수를 호출 할 것을 권장합니다. 아마도 다음과 같은 것일 수 있습니다 :

var waitingForItems=2; 
function itemReady() 
{ 
    //called from both Flash and $(document).ready 
    --waitingForItems; 
    if(waitingForItems==0) 
    { 
     //create your array 
     //send to Flash by calling Flash rather having Flash call JS 
    } 
} 
$(document).ready(function(){ 
    itemReady(); 
}); 
+0

답장을 보내 주셔서 감사합니다. 끝에 그리고 빛을 보았다. 난 그냥 var alt_array doc.ready 외부 정의하고 플래시에서 배열에 액세스 할 수 있습니다. 이제 IE7에서 작동하도록해야합니다. – FFish

관련 문제