tags:

views:

790

answers:

2

Hi,

I have a flash movie from which I want to open a Jquery lightbox. Is it possible?

Thanks

+2  A: 

Try Calling any JS lightbox from Flash using jQuery

Flash:

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+"&gt;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");   
}

Or you could port flashLightBoxInjector Start Lightbox from Flash a PrototypeJS class to the jQuery framework without too much trouble if your a somewhat confident in writing javascript

jitter
Thanks man...I also thought about using ExternalInterface.call. But it's only in AS3 right? I want to add the jquery thing to a code written in AS2. Any chance?
Dubaigenius
A: 

Yes you can do it.

To call a javascript function doIt(), you write:

getURL("javascript:doIt()");

But really, if you are having to do that, there might be better ways to solve your problem.

jrh

Here Be Wolves