2009-06-17 43 views

回答

3

嘗試Calling any JS lightbox from Flash using jQuery

閃光燈:

import flash.external.ExternalInterface; 
button.addEventListener(MouseEvent.CLICK, external, false, 0, true); 
function external(evt:MouseEvent):void { 
ExternalInterface.call("external", "lightbox/photos/image1.jpg"); 
} 

的Javascript:

function external(path) { // pass in the correct path to the function so we only need one <A> for infinite amount of calls from flash    
// if the lightbox does not exist we will make it    
if ($('a#lightbox').length == 0) {     
    $("body").append("</A><A id="lightbox" style="visibility: hidden; position: absolute; left: -9999px;" href="http://www.thetruetribe.com/+path+">calling js lightbox from flash</A>");     
    $('a#lightbox').lightBox();   
// if it already exists but the path is different we will set the new path    
} else if ($('a#lightbox').attr("href") != path) {     
    $('a#lightbox').attr("href", path);   
}  
// now we will simulate the click here.    
$('a#lightbox').trigger("click");  
} 

,或者你可以端口flashLightBoxInjector Start Lightbox from Flash一個PrototypeJS類jQuery框架沒有太多的麻煩,如果你有點自信在寫作javascript

+0

謝謝你......我也想過使用ExternalInterface.call。但它只是在AS3的權利?我想將jquery添加到用AS2編寫的代碼中。任何機會? – Dubaigenius 2009-06-17 11:57:39

0

是的,你可以做到。

要調用javascript函數doIt方法(),你寫的:

getURL("javascript:doIt()"); 

不過說真的,如果你有這樣做,可能有更好的方法來解決你的問題。

jrh