Level: Intermediate Languages: AS 2.0, JavaScript
In this tutorial, I will show you how to launch a Lightbox window from within a flash movie.
Step 1:
You need to install Lightbox++ on you server for it to work.
Click on the Lightbox++ link for instructions
Then paste the following code between the <head></head> tag of your html page holding your swf.
<script type=”text/javascript”>
function LightboxDelegate(url,caption) {
var objLink = document.createElement(‘a’);
objLink.setAttribute(‘href’,url);
objLink.setAttribute(‘rel’,'lightbox’);
objLink.setAttribute(‘title’,caption);
Lightbox.prototype.start(objLink);
}
</script>
Step 2:
In the Flash movie, you need to use the getURL method on a button to call the images. You can create your button dynamically or using the Flash IDE.
Your ActionScript should look like this:
my_btn.onRelease = function(){
getURL(“javascript:LightboxDelegate(‘image1.jpg’, ‘caption’)”);
}
Embed your flash movie or publish the html file using the Flash publish settings.
Step 3:
After publishing your html page,
Within the <body> tags, specify the following parameters to your flash movie:
<param name=”allowscriptaccess” value=”samedomain”>
<param name=”wmode” value=”transparent”>
You also need to add the following attribute to your <embed> tag: wmode=”transparent”
Make sure you have edited the location of all you script and images for lightbox++.
This is important for the lightbox.css file to be linked properly as well as the images for it to work.
Then all you have to do is upload it to your server.
Download my example here.



is there a way to get thisworking with actionscript 3?
I haven’t tried yet with AS 3.0. I think you should check out the following link for more details on how to use the it with AS3.0.
http://www.anthonytanaka.com/?p=180
Let me know how things go.
Hello Mr.Flashcraving,
Thanks for your post. Could you please check your download example, since I tried it, but the lightbox didn’t open.
Thanks!
You need to upload all the for the javascript to work.
I m not sure about Ligthbox with AS 3.0 as the new Actionscript implementation is very different from AS2.0, will have a look at it as soon as I can.
you have to make sure you link correctly to the js files from within your html and install all the .js files needed on your server.
the downloaded example won’t work because the .js is activated online.
drop me an msg if you still have trouble with it.