2010-05-17 2 views

답변

3

물론 Flash는 ExternalInterface를 사용하여 Javascript에서 메서드를 호출 할 수 있습니다.

function methodInJS(name) { 
    alert("Hello to " + name); 
    return 17; 
} 

그런 다음 ActionScript에서 당신이 부를 것이다 : :

var myName:String = "David"; 
var result:Number = ExternalInterface.call("methodInJS", myName); 
trace("Result from JS call is: "+result); 
1

예, 같이 당신의 그림자 상자를 설정 HTML에서 ExternalInterface를

를 사용하는 구문은이 Javasacript에 말을 아주 간단합니다 this :

<link rel="stylesheet" type="text/css" href="shadowbox.css"> 
<script type="text/javascript" src="shadowbox.js"></script> 

<script type="text/javascript"> 
Shadowbox.init({ 
    skipSetup: true 
}); 

function openShadowbox(content, type){ 
    Shadowbox.open({ 
     content: content, 
     player:  type, 
     title:  "Welcome", 
     height:  350, 
     width:  350 
    }); 
}; 
</script> 

그런 다음 ActionScript에서 :

if(ExternalInterface.avilable){ 
try{ 
    ExternalInterface.call("openShadowbox", "<h1>Welcome to my website!</h1>", "html"); 
}catch(error:Error){ 
    trace(error); 
} 
} 
+0

감사합니다. 어떻게 shadowbox의 크기를 변경하고 중심에 놓을까요? – Adam

관련 문제