01
Jun
08

Using Lightbox++ on a Flash button

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.


6 Responses to “Using Lightbox++ on a Flash button”


  1. 1 Maldor
    June 20, 2008 at 7:51 am

    is there a way to get thisworking with actionscript 3?

  2. June 20, 2008 at 4:04 pm

    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.

  3. 3 Daniel
    June 26, 2008 at 12:01 am

    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!

  4. June 26, 2008 at 4:21 am

    You need to upload all the for the javascript to work.

  5. October 15, 2008 at 11:29 am

    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.

  6. 6 flashcraving
    July 22, 2009 at 9:38 pm

    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.


Leave a Reply




Flickr Photos

27/365 : Escape

let the wind blows

Untitled

More Photos

del.icio.us tags