flashLightBoxInjector – Start Lightbox from Flash

WARNING: This project is no longer updated, and unsupported. It is kept here merely for archiving purposes. You should check out my most recent projects on Github


What is flashLightBoxInjector?

flashLightBoxInjector is a PrototypeJS class that bridges the gap between Flash and Lightbox2. Not only does flashLightBoxInjector let you start an already existing Lightbox driven gallery (viz. static HTML), it also lets you dynamically build a list of images to show through Lightbox (viz. inject the needed HTML from within Flash).


Imagine a Flash movie loading a set of images from Flickr, showing all thumbnails. A click on the thumbnail will then fire up Lightbox to show that image (within its set). This is where flashLightBoxInjector jumps in: after having loaded the images into your Flash file it automagically injects the needed HTML code into the current HTML document and then lets Lightbox know that this new set of images was included, enabling Lightbox to show them. And all this with the ease of a few calls made through Flash’s proprietary ExternalInterface object. (See demo)

Looking for a version that works with ShadowBox instead of Lightbox? Head over to the PictureFlow project page and download the latest version in order to lay hands on flashShadowboxInjector.


Alternative (non-Flash) implementations of flashLightBoxInjector

The great thing about flashLightBoxInjector is that its usage is not limited to Flash only, as the JavaScript can be called from anywhere you like

flashLightBoxInjector Alternative Usage

Imagine a website where you have a dropdown to select an image from and after a click on a button, Lightbox2 shows the selected image. Yes, flashLightBoxInjector can be used for this purpose. (See demo2)




The download of flashLightBoxInjector includes a full example, including Flash Sources.

In order for this to work with Lightbox 2.0.4 (released 2008.03.09), you’ll need to make 1 tiny change to the lightbox.js file! Versions 2.0.x predating 2.0.4 will work “out of the box”

Latest Version

Download flashLightBoxInjector 1.2

Old, Archived Versions

NOTE: it is advised that you use the latest version!

Download flashLightBoxInjector 1.1

Download flashLightBoxInjector 1.0

Don’t forget to read the License & usage and Installation/Configuration blocks on this page! 😉


Version History

Version 1.2 – 2007.11.22

  • [add] Added a prependElement function
  • [add] Added a new, more impressive, example (Flash Polaroid Photo Gallery)

Version 1.1 – 2007.08.03

  • [fix] Array passed into flashLightBoxInjector appeared reversed in Lightbox2

Version 1.0 – 2007.07.27 – * INITIAL RELEASE *

  • Small coding of class, flash example, documentation, etc. resulting in a first release.


License & usage

The script is released under a creative commons Attribution-ShareAlike 2.5 license. Should you use the script within a commercial context please think about clicking the PayPal donate button.



In order for this to work with Lightbox 2.0.4 (released 2008.03.09), you’ll need to make 1 tiny change to the lightbox.js file! Versions 2.0.x predating 2.0.4 will work “out of the box”

  1. Make sure you’ve set up Lightbox2 correctly.
  2. Include flashLightBoxInjector.js in your HTML headsection, underneath the Lightbox2 references:
    <script type="text/javascript" src="js/flashLightBoxInjector.js"></script>
  3. That’s it, you’re done!


Static Code Example

If you already have a set of links in your HTML, only a minor change is needed: each element must be given an id.

<a href="images/image-1.jpg" rel="lightbox[roadtrip]" id="roadtripImage1">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]" id="roadtripImage2">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]" id="roadtripImage3">image #3</a>

From within Flash then call myFlashLightBoxInjector.start through ExternalInterface along with the id of the linked picture as parameter. If you’d want to show the second picture, then you’d be using this piece of code:

import flash.external.*;

btnShowImage.onRelease = function() {
ExternalInterface.call("myFlashLightBoxInjector.start", "roadTripImage2");


Dynamic Code Example (Step-by-step example)

Imagine that you’ve pulled an XML file from Flickr containing a set of pictures and that you’ve loaded all thumbnails into Flash. flashLightBoxInjector provides you the option to automatically generate the needed HTML, so that Lightbox has knowledge of that gallery. Here’s what you have to do:

Before going through the steps needed, it’s needed for you to know that flashLightBoxInjector automatically creates a div-element with the id flashLightBoxInjectionBox where it will store the HTML needed for Lightbox.

If you have a robust knowledge of coding Flash/Javascript, then you might want to skip this example, and immediately go to the All-in-one example

First you have to import flash.external.* in your Flash file, enabling javascript calls from within flash, the proper way

import flash.external.*;

(yes, we could use getUrl("javascript:...") to call javascript functions, but that cannot be trusted 100%)

  1. First call a myFlashLightBoxInjector.reset() from within Flash, this will clear the contents of flashLightBoxInjectionBox if you don’t want previously injected elements to appear in the same set (when using the same set ID):
  2. While looping through your set of images within Flash (and placing a thumbnail version of the image onto the Stage for example), call a myFlashLightBoxInjector.appendElement for each image:
    ExternalInterface.call("myFlashLightBoxInjector.appendElement", linkToTheImage + "", titleOfTheImage + "", uniqueIdOfTheImage + "", nameOfTheSet + "");

    Note that I’m appending an empty string to each parameter (viz. implicit casting to String), as Flash otherwise tends to freeze due to some weird reason.

    Don’t forget to hook an onRelease event to the thumbnail you’ve placed onto the Stage, which will call the myFlashLightBoxInjector.start function

    ExternalInterface.call("myFlashLightBoxInjector.start", uniqueIdOfTheImage + "");
  3. After you have looped throuh all of your images, call a myFlashLightBoxInjector.updateImageList, so that Lightbox will know of the newly injected set

That’s it, you’re done!

If you notice that your images appear in the reverse order in Lightbox than the order you’ve inserted them in your Flash File, then use prependElement instead of appendElement in the code above (Requires fLBI 1.2)


Dynamic Code Example (All-in-one example)

A full piece of code might look like this (full workout in example included in the download)

function attachImagesToStage(photoArray:Array):Void {

    // reset myFlashLightBoxInjector

    // loop photoArray
    for (i=0; i &lt; photoArray.length; i++) {

        // attach new MC to Stage
        var mc:MovieClip = this.attachMovie("photoFrame", "photoFrame" + photoArray[i].id, _root.getNextHighestDepth());

        // add image to MC, set x and y coordinates, etc.
        mc._x = ((mc._width * (i+1)) - (mc._width / 2));
        mc._y = 25 + Math.round((Stage.height - (mc._height*2)) * Math.random());
        mc._rotation = 30 - (60 * Math.random());

        // append element in DOM through myFlashLightBoxInjector.appendElement
        ExternalInterface.call("myFlashLightBoxInjector.appendElement", photoArray[i].url + "", photoArray[i].desc + "", "photoFrame" + photoArray[i].id + "", "mySetOfImages");

        // hook onRelease event
        mc.onRelease = function() {
            // show Lightbox with this image
            ExternalInterface.call("myFlashLightBoxInjector.start", this._name + "");


    // let Lightbox know stuff has changed


Now build an array of the images you wish the load, each entry having an id, url and desc property and pass that array through the function.




One can always leave a comment in case any questions should arise or if a bug were to be found; and one can always support me by donating me a tidbit to my paypal ;)


Make a donation

It certainly is no obligation but it would most certainly put a smile on my face 😉 Alternatively you can support me by clicking one of the ads below.


Join the Conversation


  1. @ Nick : you have the wrong lightbox version! Version 2.03.3 is required, as that version holds a updateImageList function which is used by flashLightBoxInjector. 😉

  2. bramus thank you for you help. I appreciate getting back to me I need to take a holiday as well. Anyway I’ll try updating to the new version this weekend. I’ll also be sure to send a donation to you once this is done your gonna save me alot of time

  3. Bramus sorry to bother you I got it working and it works great. I was using my macbook, but today I got a call saying the formatting was wrong. So i brought it up on my windows machine and noticed in IE it all messed up are you aware of any bugs? If you see anything you can email me or respond on this Thanks

  4. hi,

    like to know if i can implement the inyector into a flash scroller which has several linkings driven by a external xml document.

    thanxs & best

  5. Great script!

    Just want to point out a “typo” in your ‘Static code example’. It’s almost nothing but I had some trouble with this for like half an hour before I realised what the problem was.

    If you copy/paste the HTML code the id’s says “roadtripImage2” but in the AS code it says “roadTripImage2”, and that capital ‘T’ just messed it up for me.

    Now you know 😉

    Thx for a great script

  6. hi,
    im really looking forward to getting this running from my flash files.

    im launching a .swf as full page with SwfObject. i dont have the links to the images embedded into the HTML, can i still use flashlightboxinjector?

  7. Hi Liam, you sure can do that. FlashLightBoxInjector will automatically insert the needed (hidden) div element when loaded.

    Then follow the instructions to insert the images from within flash (through FlashLightBoxInjector) into the HTML, hook the events within your Flash file (viz. the buttons/objects which will start the Lightbox) and everything will work as it should 🙂

    On a sidenote: I’ve done this myself over at http://www.trancefusion.be, for which I have created FlashLightboxInjector 😉

  8. can someone help please?
    my test page

    i’m using the exact code from the “Static Page Example”.
    the button in the swf file has the instance name of btnShowImage and the actionscript is as below

    import flash.external.*;
    btnShowImage.onRelease = function() {

    i have a folder called images in the same directory containing


    if i click on the links in the page, it works but if i click the flash button, i dont get the gallery. how come?

    also i dont want the links on the page, so instead of the identifier can i but in the url of the image instead?

    i am a total javascript novice. sorry

  9. @ liam: you’re calling “roadTripImage2” from within your flash, yet your id’s on the a elements are “roadtripImageX” (notice the lowercase T) … either change one of the two and you’re set 😉

  10. thanks for the lightning fast reply!

    one small query though, why does my swf file disappear when the gallery launches? is it because im not using SwfObject?

    felt i had to reply to the “What’s the deal with Scrubs?” entry below, hopefully you agree with me??

  11. @ liam:

    – your swf is hidden as Lightbox does this automatically. To not hide it, comment out lines #376 (which reads hideFlash();) & #624 (which reads showFlash();) from Lightbox.js by placing // in front of the lines.

    – Didn’t get that comment on the scrubs thread :-S

    – Looks like you’ve sorted out the hiding (for those not knowing: place them in a div with display:none; applied to it)

  12. Gotcha!

    Aaaahh now i can go to sleep!! its 2.30am here in Ireland. (i dont know where you are)

    thanks for all your help. il be getting a Credit card very soon, il make a donation!

  13. Bramus, outstanding job on http://www.trancefusion.be

    Did you especially customise the polaroid sorting effex by yourself or is it built into flashinjector ?

    Do you have some sample code on how you got flashinjector to work for downloads in your http://www.trancefusion.be download section ?

    Thanks for the great mod and look forward to hearing a lot from me.

  14. (wmode = transparent) + (text inputs) = living nightmare

    OMFG! is there anyway round this? in my text fields, @ becomes “.

    surely, someone at Mozilla or adobe has heard about this?

  15. this fixes it..

    keyPresser = new Object();
    keyPresser.onChanged = function(intxt:TextField) {
    if (34 == ((Key.getAscii())) || 64 == ((Key.getAscii()))) {
    intxt.text = intxt.text.slice(0,intxt.text.length-1) +”@”;

  16. @ Roland: the polaroid sorting effect has nothing to do with flashLightBoxInjector. As in the included exmaple it’s an XML (from Flickr) that is read in, then looped through and an array is built. The only difference between Trancefusion.be and the code-example provided is that photoArray is randomized before being passed to attachImagesToStage 😉

    @ Roland bis : the downloads are normal getURL() calls, has nothing to do with flashLightBoxInjector 😉

    @ Liam : encountered the same problem whilst developing trancefusion.be … 😛

  17. Bramus, the example code in your download provides non-polaroid effect, non draggable, ie:fixed images.

    I’m not able to see in operation the kind of functionality that appears on trancefusion.be. What am I missing ?

  18. @ Roland: I thought you meant the randomizing … anywho, yes, it’s a modded (read: flashLightBoxInjector integrated) version of the link you’ve posted 😉

  19. I am testing this on a Mac and running Safari 3.0.4 displays the Lightbox as if it is going to come up (only the transparent background appears) but nothing ever comes up. I run it in Firefox and it works just fine. Any ideas on this one. Is it using a tag that Safari doesn’t like in the javascript? Any help would be greatly appreciated!

  20. Thanks for the update.

    The fla files included in the v1.2 source seem corrupted as Flash 8 gives me the error ‘unrecognised file format.’

    I suspect zip corruption.

    Can you please recheck & repost ?

  21. having the same problem as Chas…

    I took the first example, commented out the flickr XML and loaded my own image array. The thumbs show up fine, the background dims, and nothing ever comes up. I JUST tested it using the original example (which is fine), but every time I load my own images in the SWF the damn thing freaks out!

    I am literally yelling at my computer because I can’t get this thing to work… HELP!

  22. It appears that when I load the RSS feed from flickr it functions perfectly… yet even when I download that VERY SAME FEED from flickr and put it on my server as an XML file the injector stops functioning. Any ideas/insight with this one?

  23. @ Chas, Adam: will take a look into that … must say that over at Trancefusion.be the images of 2007 (which are over 200 images, yet only 15 are shown) aren’t loaded from an XML but inserted by a loop (alle images are named image-X.jpg, where X ranges from 1 up to 200).

    @ Adam bis: sure the headers are ok (UTF-8 it should be)?

    @ Roland: Flash CS3 is required. Will post a Flash 8 version of the .fla

  24. Is there a way to use this with an already existing external xml file? instead of creating one and importing everything into an array? I have a flash thumbnail scroller that I want to open the images in lightbox, but everything I’ve tried has failed when it tries to access the external xml file to retrieve the images. Any thoughts? Thanks

  25. @Brandon: yes, that’s perfectly possible. In the examples provided, it reads in an already existing external xml (from Flickr in this case) and then builds an array of it.

    @Jacob: Glad to have helped 🙂

    @osamwal: very nice work! Kudos!

  26. Thank you for this awesome effect for flash!!

    Now, my problem is that i’ve downloaded the latest version, and I have serious problems to use it with static code and images at the same folder.

    Could you help me please?

    Which code should I use?

    Thank U very much!

  27. Hi Bramus, is it possible to insert flashinjector into another existing flash movie ?

    So the polaroid effect would appear in a panel within another flash movie.

    Appreciate any help on this.

  28. @ Kriz : didn’t test in Opera. Think it has to do with the implementation on how Flash is loaded into Opera. Will check it out.

    @ Roland: that not possible, as Lightbox is HTML+CSS+JS and Flash is … well … Flash. The thing you’re looking for is a flash version of Lightbox; don’t know if that exists (although a clever search on Google will tell you quickly).

  29. Hi,

    I wanted to ask, if it’s possible to use lytebox (http://www.dolem.com/lytebox/) with the injector instead of lightbox2…I need lytebox because I work with iFrames and lightbox doesn’t support them…I tried already some things but it didn’t work…I would like to use lytebox in combination with pictureflow 2.4 (http://www.yaelle.com/?p=61) which is already working with lightbox2, so it shouln’t be such a problem because pictureflow 2.4 works already with your injector…

    but I’m not getting it and so I ask you =), what do I have to do to make this work…finally it should work with my site: http://fred.lee.john.031.be/booking.html –> under “Jamathetics” –> “Pressefotos” … the gallery is already there, but the pictures shouldn’t open in the iFrame, they sould open over the whole page (the nice thing of light/lytebox =D)…

    thank you for your work with the injector, for your time and maybe your help =)!



  30. if (mc._name.indexOf("reflection") == -1) {
    mc.onPress = function():Void {
    if ((getTimer()-this.pressTime<=doubleClickRegister && this.pressTime) || !doubleClickURL) {
    if (infostruc[this.cid].urlToGet) {
    getURL(infostruc[this.cid].urlToGet, "_"+infostruc[this.cid].urlAction);
    this.pressTime = getTimer();
    current = this.cid+1;

    Currently I have that setup to link to an outside link, when clicking on an image, but I would like it to load the large image in light box.

    you can use any of these variables:
    auth, album, httpType, urlToGet, urlAction

    Can anyone help me add this into my flash app?

    I tried doing: but no go.

    if (mc._name.indexOf("reflection") == -1) {
    ExternalInterface.call("myFlashLightBoxInjector.appendElement", infostruc[this.cid].httpType + infostruc[this.cid].art + "", photoArray[i].auth + "", "photoFrame" + infostruc[this.cid].art + "", "mySetOfImages");
    mc.onPress = function():Void {
    if ((getTimer()-this.pressTime<=doubleClickRegister && this.pressTime) || !doubleClickURL) {
    if (infostruc[this.cid].urlToGet) {
    ExternalInterface.call("myFlashLightBoxInjector.start",infostruc[this.cid].httpType + infostruc[this.cid].art + "");


    this.pressTime = getTimer();
    current = this.cid+1;

  31. @ LuK : what you’re looking for is to use Lightbox from within an iframe, yet targetting the parent window. Lytebox indeed can do this as I have read, yet a modded Lightbox can do this too. Both are untested though, hope you can figure it out (I’m currently very busy, so can’t help you right now). 😉

    @ Chris : you’ve mailed me that you have found the solution already. Care to post it here? It might help other people out (t)here 😉

  32. Early morning:

    (Thought people might want an explanation as some I wouldn’t have understood without playing with the script.)
    In aways the solution is if your not familiar with the script find the loop which goes through every image (I set up some text box and set the value to the image until i saw it looped through all of them)

    Place the Reset function above the loop. In the loop add all your variables in, using the append function.

    After the loop is finished add in the update or in my case there was a section to check, and once all the images were loaded it set a value this was were I placed mine.

    As for setUrl,

    just replace it with ExternalInterface.call(“myFlashLightBoxInjector.start”,this.cid + “”);

    I used the id in the loop for the unique id, which worked out nicely.

    But I found one flaw, on certain machines the script does not like to work locally. I tried, and tried to find a solutions. If I upload onto the web it works.. Maybe someone can tell me why or find a solution?


  33. Hi Bramus!

    Came upon your script as I look thru the Lightbox forum – I am looking to have an image in a form script included in my Image View via Javascript. Lightbox2 cant do it – can flashLightbox?

    The reason I need the image wrapped in a tag is that on each image that opens at the site below (click on “Gallery”, then choose a piece of art), the site visitor needs to see a PayPal “Buy Now” button. Paypal wraps those images in a form tag, and I cannot get the Flash/Lightbox javascript call to utilize such a tag (only an {HREF=} is working (with correct carats of course).

    Would love to hear if I could utilitize your script instead!



  34. @Andrew: I see you’re using LightboxDelegate; which can be used too. Set the onclick of the button (type image) to call LightboxDelegate() with the correct parameters.

  35. Hi…
    I am a newbie as far as javascript goes, but i have been using actionscript to create my portfoliowebsite. When I discoved shadowboxing images, i figured that might be a nice, dynamic way of letting viewer look at my work, how ever, HELP!! I do not understand all the steps I must go thruough just to get this to work!

    I am using actionscript 2.0 and Flash CS3.
    My entire site is ONE (1) SWF, embedded into an HTML page in Dreamweaver.

    I would like the option for a viewer to click one of my image thumb buttons, and run an “on(Release)” command to call this javascript into action, from the FLASH BUTTON, using images stored on my webserver.

    What do I need to do? What files files from the flashlightboxinjector download need to be on the server, and where? Are there specific directories i need to create for this? In Dreamweaver, do I have to do extra HTML coding even tho my entire site is basically a flash movie? What would my code look like in AS 2.0 for my flash button? Any help would be greatly appreciated. I am trying to wrap up final revisions to my site

    Thank You!!

  36. I have got this to work, the problem I’m having is that my flash in the back ground is disappearing. Is there any way to prevent that?

    Thank you

  37. Hi Bramus,

    I had one issue while using your great script. Is there a compatibility Issue with Lightbox2.04? I’ve used your script with Lightbox2.03 and it works seamlessly, but there seems to be an issue regarding compatibility with MacOS and Firefox, so I wanted to upgrade to 2.04, which didn’t work at all for me… Any help would greatly be appreciated!

  38. @Derek: in order to use flashLightBoxInjector with 2.0.4 you’ll need to make 1 tiny change to the lightbox.js source file. You’ll need to change the very last line from:
    document.observe('dom:loaded', function () { new Lightbox(); });
    document.observe('dom:loaded', function () { myLightbox = new Lightbox(); });

    For some reason unknown to me, Lokesh has removed the instantiation into a variable. I’ve mailed him about this issue and hope to see it fixed in a newer version of Lightbox.


  39. I was just wondering if with this lightbox source allows for the loading of html or php documents in the lightbox?

  40. for this to work do i have to use your lightbox js because i know of one that allows for the use of an html page to be opened in the lightbox?

  41. hello bram, i have a urgent question for you. i saw your example with the lightbox loaded from a flash file. but in your example the swf is dinamically loaded from the web, from flickr, isn’t?
    i would like to do the same thing but from a flash button.. so if i release the flash button (the final swf is inserted in an html simple page) i would like to launch a little pictures gallery.

    can you send me a sample example please?
    thank you aniway

    my mail is angelucci.diego@gmail.com

  42. In a comment above (10/07) you said if the swf is hidden (ie. no transparency to Lightbox background) then do this:

    – your swf is hidden as Lightbox does this automatically. To not hide it, comment out lines #376 (which reads hideFlash();) & #624 (which reads showFlash();) from Lightbox.js by placing // in front of the lines.

    I have the same problem with transparency (can’t see my flash file in the background), but I went to Lightbox.js and the line numbers don’t match any code dealing with Flash. In fact I can’t find any references to Flash anywhere in the js file. Any recommendations? Everything else works OK. I have some looping effects and sound in the full page Flash file. Could that be hosing up the transparency?

  43. Fixed it…

    I had to downgrade to V1.1 in order to be able to comment-out the flash related lines in the js file. All is good now. Transparency works great.

    I think something is broken in V1.2 (Lightbox 2.04) that screws up transparency on full page flash sites.

  44. @Taki: Given that the gallery is already there and you know the id of the image you want to start (prerably the first one), you’ll only need to call ExternalInterface.call("myFlashLightBoxInjector.start", uniqueIdOfTheImage + ""); where uniqueIdOfTheImage of course is the ID of the first lightbox-link 😉

    @ Jim: Will check that out; Thanks!

  45. Hello Bramus! Thank you for the wonderful scripts.

    I used the flash LightBox Injector on my website http://www.pacomelo.com in order to display some of my work on the “Portfolio” section (icons hanging from a tree). I tested on FF and Safari and it runs fine however I got some comments that is not working on IE 7. I haven’t been able to find any comments from people with similar problems yet and since I have a Mac (and no IE 7 available) is hard for me to do any testing. Any ideas what is going on?

    Any comments will be greatly appreciated…


  46. Hi Bramus,
    I have a .swf file that I want to run in a lightbox and have tried lightwindow and another one but it won’t read my xml when open in the lightbox. Will flashlightboxinjector do it?

  47. @Whathell: hmmz, can’t really pinpoint that one but am seeing a JS error. You could try installing companion.js/debugbar (both IE plugins) in order to get some more information about the error.

    @Ben: flashLightBoxInjector will indeed do it (tip: read this page its intro and/or check out the demo’s ;))

  48. Hi Bramus,

    Have you received a reply about the myLightbox variable instantiation that disappeared? I have numerous sites that I would like to update with Lightbox 2.04, and I don’t really want to put in hacks in the author’s code, except if this is a permanent change.

  49. Hi,
    I need i little help.

    I make a test with the “Static Code” and it works. But when i try to use the function “appendElement” it dont work, im calling the exactly id that i injected and they just make the screen dark and dont show the white window with the image. Take a look:

    import flash.external.*;
    ExternalInterface.call(“myFlashLightBoxInjector.appendElement”, “images/image-1.jpg”, “its a test”, “test”, “group”);

    btnteste.onRelease = function() {
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “test”);

  50. Hey, I like what youve done with the flashinjector. I can get it to work in IE and FF and everything.
    But where I am stuck on is trying to call the Lightbox from a button, that is located in a Movie Clip on the main timeline

    Ive tried allsorts of things.
    _root.mcname.btnname.ExternalInterface.call(“myFlashLightBoxInjector.start”, “Edge2”);

    ive tried just in the MC
    on release :
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “Edge2”);

    tried in the MC onrlease:
    _root.ExternalInterface.call(“myFlashLightBoxInjector.start”, “Edge2”);

    even tried to put the action onto the button itself.
    Just cant get it to work.

    But when I put my button on the main timeline it works great.
    with simple blahbtn.on rlease ( ;
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “Edge2”);

    Anyone have any ideas, I dont know how often people check here.

    I just want the button thats in a MC to call up the lightbox.
    Im struggling here.

  51. @Allen, @Tom: check your Flash Export Settings … be sure to have at least Flash Player 8 selected (have noticed that ExternalInterface can’t be called upon in FP7) 😉

  52. Hi Bramus!

    I have a website build with Flash. In the main Flash file I use mx.controls.Loader to load and replace parts of the main file and one of the loaded files is a gallery.

    Question: Is it possible to use the flashlightboxinjector on that gallery?


  53. Hi Bramus. First I’d like to congratulate you for your research and script, it’s just great!!!

    I’m using the flashinjector in my portfolio (www.tiagopimentel.com) and it’s doing fine. If you can visit the link you can check it out. But I did a flash script that change somethings in the site according to the hour of the day. If you adjust your computer clock to something between 8 pm and 5 am you will see what i’m talking about. And when I have a Flash mask in that part of the site and I click a job and it have to open in the Lightbox it simply don’t show it up. Do you have any idea what I’m doing wrong? The script have a bug when you use a Flash Mask?

    thanks in advance


  54. Hey, everythiing is working fine in regards to loading dynamic images. However, if I substitute I try to load a swf instead of an image I get a broken link. Is it possible to load swfs? If so please advise how. Thanks, good work.

  55. Hey,

    flashlightboxinjector is a god send. You’ve ridded me of a huge headache. I have one problem though. I already had the images displayed in my flash clip. If I hard code an image id to call, for example roadtrip2, it works perfectly. I tried to do this, however, and won’t work.

    private function onClick(event:MouseEvent):void {
    trace(“lbExpand: ” + lbExpand);
    ExternalInterface.call(“myFlashLightBoxInjector.start”,lbExpand + “”);

    lbExpand is a string. It contains myImage0, myImage1, myImage2…etc. Those are the id’s I’ve attached to the images in my html. If I replace lbExpand with say, myImage5, it loads myImage 5. Using lbExpand fubar’s it though. Any suggestions?

  56. You can totally disregard that question. Lightbox will never work if you don’t specify the right directory for the images. Works perfectly. Thanks for this great tool.

  57. Maybe I don’t really hate spam. Sorry for the trifecta but I do have a question. When lightbox kicks in, rather than the overlay fading in, it flashes in. Any idea what might be causing that?

  58. Hello, I’m from Germany, sorry bout my bad english haha, I’ve got a problem with the Lightbox 2.04. I’ve got a Flash-Page and want to directly start the Lightbox Diashow from a textbutton, without havin thumbs, Javascript bumpin up on the same page, like not startin a new html. Short form: startin that Javascript from Lightbox 2.04 via Textbutton from Flash. Any way to realize it? THX

  59. Hi, it´s awesome how u did the solution for calling lightbox roadtrip from flash, really awesome! The best what i´ve find. But i am noobie and ionno how i can do my flash gallery working with lightbox roadtrip. If can help me, please contact me by e-mail jakub@probrand.cz and i will send u my simple flash gallery (working eith lightbox, but not working roadtrip). Thank you very much!

  60. Hi, I have a flash site(several.hu/ujfox007), and works everything with lightbox. But if i use IE and open the lightbox, the sound in the flash disappear. In firefox everything is oké.
    How can i do this problem?
    Sorry my poor english:)

  61. Hi,
    first, I appologies for my english…
    I’m trying to use your awesome script but after 2 days of researches, I really need some help.
    I don’t understand what is the XML structure so I can use my own (and not a flickr link)
    Hope anyone could help
    Thanks a lot

  62. Maybe I’m wrong, but if you don’t want swf to disapear, you can change line 205 of lightbox.js (V1.2) from
    $$(‘select’, ‘object’, ’embed’).each(function(node){ node.style.visibility = ‘hidden’ });
    $$(‘select’, ‘object’, ’embed’).each(function(node){ node.style.visibility = ‘normal’ });

  63. Bramus, any luck with the Opera 9 problem? I’ve noticed that it’s really only on Opera Mac. The Windows version displays Flash fine.

  64. @kimweb:

    Could you post the XML structure that you found the solution to? I don’t know coding at all, but cut & paste my way through. I don’t want to use the flickr link either. Do I need to comment “//” a specific code out? Thanks.


  65. Bramus, it’s the first time I use Lightbox. I’m using static code and have a fullscreen flash. The problem if that if I insert the links in the html, the show below the flash animation. Where should I place them if I want them to be hidden, but still available to be called from within the flash movie?


  66. Sorry Bramus, I should have read all the comments, I figured it out. Great script by the way!

  67. When using the static code and adding

    import flash.external.*;

    to my ActionScript, I keep getting a syntax error on exporting:

    import flash.external.*;

    btnShowImage.onRelease = function() {
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “image1”);

    Evrythign is set up perfectly, and LightBox works from an HTML link. I just can’t get Flash to cooperate. Running CS3.

  68. Hi Bramus,

    I’m using this to launch lightbox from a thumbnail gallery that is loaded from an xml file. Everything is working except that no matter what thumbnail I click, lightbox always opens the first image in the xml file. I can’t figure it out so I thought I’d ask you. Here is my AS

    import fl.containers.UILoader;
    import caurina.transitions.*;
    import flash.external.*;

    //---------loading the external xml file-------
    var urlRequest:URLRequest = new URLRequest("pics.xml");
    var urlLoader:URLLoader = new URLLoader();
    var myXML:XML = new XML();
    var xmlList:XMLList;
    myXML.ignoreWhitespace = true;
    //--------holds the paths to the thumbnails-------
    var arrayURL:Array = new Array();
    //--------holds the paths to the big photos-------
    var arrayName:Array = new Array();
    //--------holds the thumbnail objects-------
    var holderArray:Array = new Array();
    //--------represents the number of collumns-------
    var nrColumns:uint = 5;
    //-------represents the container of our gallery
    var sprite:Sprite = new Sprite();
    var thumb:Thumbnail;
    //-------- the thumbnails container-------
    var thumbsHolder:Sprite = new Sprite();

    /* loop through the xml file
    populate the arrayURL, arrayName and position the thumbnalis*/
    function fileLoaded(event:Event):void {
    myXML = XML(event.target.data);
    xmlList = myXML.children();

    for (var i:int=0; i<xmlList.length(); i++) {
    var picURL:String = xmlList[i].url;
    var picName:String = xmlList[i].big_url;
    holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
    holderArray[i].name = arrayName[i];
    holderArray[i].buttonMode = true;
    if (i<nrColumns) {
    holderArray[i].y = 65;
    holderArray[i].x = i*110+65;
    } else {
    holderArray[i].y = holderArray[i-nrColumns].y+110;
    holderArray[i].x = holderArray[i-nrColumns].x;
    ExternalInterface.call("myFlashLightBoxInjector.appendElement", xmlList[i].big_url + "", "persons");

    thumbsHolder.addEventListener(MouseEvent.CLICK, calllightbox);

    function calllightbox(event:MouseEvent):void{

    ExternalInterface.call("myFlashLightBoxInjector.start", this._name + "");
    trace("lightbox called")



    my xml is structured like this:



    Do I have to change my xml file? Or is there a problem in my AS. Sorry if the answer is obvious, I suck at coding but I’m getting better. Any help would be greatly appreciated.


  69. Sorry the tags in my xml file structure didn’t show up like I thought they would. Here is the structure with braces instead of brackets:



  70. Is there any one to modify the code below so that I can place on an object’s actionscript such as a Button?

    btnShowImage.onRelease = function() {

    ExternalInterface.call(“myFlashLightBoxInjector.start”, “roadTripImage2”);



    on(release) {



  71. hi been trying hard to understand how lightbox 2 works with flash. But I’m so confused on what to do…
    1. where do i put the files/which files?
    2.where do u put your own sized images in so that they can be call when clicked?
    3. basically need a step by step guide, NEED HELP BAD!!!!!

    hopefully you can help me, cheers

  72. hi i’ve implemented this semi-successfully into a gallery. it seems to work in safari on mac but not in firefox. i haven’t yet been able to test it on a pc. are there currently any bugs?
    link using flashlightboxinjection 1.2 and lightbox 2.04

  73. Hi bramus and the rest of the visitors

    i would like to use lightbox (lightframe) to display other site pages from a flash file

    What do i have to change to accomplish this ?

    Also because of the newbie level in flash when you say “import flash.external.*;” do i have to substitute the * with something else or it’s the exact syntax

  74. are this .js support or posibble we use in ‘multibox’ ?

    regard from indonesia

  75. I’m having trouble getting this to work (using static code). The links show up on my HTML page, all of which initiate lightbox fine, but the buttons in my swf don’t seem to want to work (and yes, i have changed the upper/lower case error for the id).

    Could it be because I’m using AS3? (I’m currently calling myFlashLightBoxInjector.start through a function triggered by an event listener)

  76. Hi,

    thanks a ton for the injector, i am an amateur id say at Actionscripting. how can i load thumbnails from xml onto my flash file and then connect it to the lightbox. this should be really simple but cant figure out how to do it. please help. PLEASE.

  77. Hi Bramus!

    Thank you very much for the code. I implemented it in a site I am doing for my wedding just for fun. Funny thing is that lightbox turns off my music. Sounds work after I close the box but my timeline music is gone. Any suggestions?

    Thanks again,


  78. Hi Bramus!

    I’m currently working on a site for a photographer in flash and I’m having a real hard time trying to add lightbox into the site to show an added enlargement of the photos. I’ve been working on trying to figure this out for several days and have tried several people’s tutorials on how to do it but after countless headaches, I’m on my last leg. I think my problem might be that my flash file is somewhat complex. The page in which I want the button to show the lightbox is about 3 pages in from the main page. I’ve been trying to use the as to call the lightbox from that sub page, is this wrong? Should I be calling it from the main page? If so how do I link that to a button in another swf located inside that page called from a uiloader? I am a beginner when it comes to html (using dreamweaver) but I’ve done everything that I needed to in all these tutorials. I’ve gotten the lightbox to work directly from the html but It never seems to work when I try to do any of it from flash. With the as I was trying to use from your instructions for the lightboxinjector I kept getting error reports like ShowImage is not a definition keyword. I ended up using

    import flash.external.*;


    function callJS(evt:MouseEvent):void{

    which doesn’t give me any error messages but when I view the page in the browser with dreamweaver the button brings up a message in firefox (adobe flash player has stopped a potentially unsafe operation” and in safari it simply brings up a black blank page. This is what I have in html other than the lightbox2 lines to set that up

    I took out the “image #1” in the projects, where I want the lightbox to appear is when you click on the detail image.) Please, I don’t know what else to try/do.

  79. Hi..
    I love this code and what it can do, but I just noticed that it’s not working for me in Internet Explorer. Every single other browser I checked seems to work out just fine. Did I miss a fix along the way that will allow this to work with IE? If so, can you pleeeaaseee help me figure out where it is and how to fix?

  80. Lovin this just 2 things 🙂

    How can I make the Thumbnail bigger like a 100 by 100?

    And also so how can I get them to come in just in a line not all rotated?

    Help would be great!



  81. Hei ppl!

    Does anyone figure out the Internet explorer bug that stop my sound my flash site when a open a lightbox image?

    Thanks in advanced!

  82. Has anyone have to deal with transparency and this script hiding flash? i can add a

    and it will show the bg but i cant get the lightbox to be transparent over my full screen flash movie

  83. ok i figured out the problem with the transparency

    in line 205 of lightbox.js theres a piece of code

    $$(‘select’, ‘object’, ’embed’).each(function(node){ node.style.visibility = ‘hidden’ });

    Which needed to be removed which i did and its not hiding my flash anymore the only problem i have now is that im not getting the shadowy overlay that surrounds the photo:


    im just over looking one minor thing here. i know it..

    I hope this helps pave the way for the people in my shoes atm. If you encounter or know a way to fix it please help.

  84. okay i finally fixed it

    line 52 in lightbox.js

    I was going crazy trying everything that i had changed the line below to 0.2 and completely forgot about the change
    when i rememeber going though all the steps when i set it back to default it fixed it. So make sure u leave this line defaulted @ 0.8 and take out the line above.

    overlayOpacity: 0.8, // controls transparency of shadow overlay

  85. i am having trouble with getting the flashlight box injector to work nothing happens when i click my button in my flash site that is suppose to call the injector here is my html and actionscript 3 code


    Untitled Document


    Content on this page requires a newer version of Adobe Flash Player.



    import flash.external.*;
    officers.addEventListener(flash.events.MouseEvent.CLICK, lightbox);

    function lightbox(event:MouseEvent) {
    flash.external.ExternalInterface.call(“myFlashLightBoxInjector.start”, “myphotoimage1”);

  86. Hi Bramus,

    read through all the comments and still stuck.

    Lightbox 2 working fine in my html.

    But Im confused as to what to do in my flash file.

    Using the static code example but cant seem to set it up right in flash. Yes Im publishing with Flash Player 8.

    What I dont understand is why you couldnt make the ‘simple’ example .fla file just use images found locally with none of the flickr/xml functionality, which quite frankly confuses me and is only really required for the more ‘complex’ examples.

    Its a fantastic script, but like alot of people on the comments I dont know how to implement the actionscript. Please help.


  87. There are too many problems with Lightbox, mostly if you use it from Flash! When it runs from a MovieClip call, it hides the whole site and there is no need to use the transparent image. Also, it stops all sounds when it run from Internet Explorer (which is the tool that 70% of users use…). It is a nice tool but… if it works! DO SOMETHING TO HELP US… AND STOP ASKING FOR A DONATION BECAUSE IT IS “NOT” WORKING FINE…!!


  88. Hey Bramus, what lines need to be commented out of the lightbox javascript to keep flash visible in the background using lightbox 2.04?

    This is the first script that worked well in all browsers for me, thanks for the great work…

  89. Hi

    I have used this as3. Freddy is an mc on the stage

    import flash.external.ExternalInterface;


    ExternalInterface.call(“myFlashLightBoxInjector.appendElement”, “http://www.ee-web.co.uk/tests/lightbox/pic1.jpg”+””, “title1″+””, “uniqueId1″+””, “stopm”+””);


    freddy.addEventListener(MouseEvent.CLICK, goAndGetIt);

    function goAndGetIt(e:Event):void{
    if (ExternalInterface.available)
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “uniqueId1″+””);

    when I press freddy the whole stage goes gray – you can’t see the swf at all. There is no image either.

    I appreciate your time


  90. Hi Bram,

    is there a way to use your script with the Lytebox, too? Or does it only work with the Lightbox?

    Best regards,

  91. Hi Bramus – love the scripting you’ve done – i however like a few noobs would like a simple static script which i can apply to a flash button that launches the lightbox script (and a specific image)

    Many thanks

  92. Hi Bramus,

    Sweet app, but I’m having problems implement it. I have the html working but not the flash part.

    Here’s my actionscript:

    import flash.external.*;
    baseSEOmc.onRelease = function() {
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “roadTripImage2”);

  93. just figured it out – you need both the html links and the flash button for this to work – you then just hide the html buttons

  94. I’m having a problem with lightbox2 and lightboxinjector.

    I’ve used the same script, as stated above for the static code example as I am only using lightbox for a few buttons in Flash, but am getting script errors.

    Script I’ve used:

    import flash.external.*;

    btnShowImage.onRelease = function() {
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “itpie_info_text_image”);

    Error messages I get in Flash:

    Statement must appear within on handler

    import flash.external.*;

    Statement must appear within on handler

    btnShowImage.onRelease = function(){

    I’ve noticed that there has been a few people asking this question, here and on Adobe’s site. But no one has addressed it openly yet.

    If anyone can help that would be great.

    Thank you.

  95. This is the code that I am using for my buttons in AS 3. How do I work your code into this in order to view an image instead of a url?

    import flash.events.MouseEvent;

    var reqprint1:URLRequest = new URLRequest(“http://www.idyllwildjazz.com”);


    function b21Click(event:MouseEvent):void{

  96. Hi,

    I used it and the lightbox works in my flash site, except my whole video now takes ages to load and i tried everything and i think it’s because of lightbox – is that possible? is there a way to fix it? when i go to the page it is black and then the preloader starts from like 90%. This didn’t happen before and im going nuts trying to fix this 🙁 please help. thanks!

  97. Ok so I’ve been doing a little digging around since my last post as I need this in a hurry and haven’t had a response yet.

    I thought I would post my findings here to help anyone else who was having the same trouble.

    So I found that a lot of people were confused with this ActionScript (AS):

    import flash.external.*;

    btnShowImage.onRelease = function() {
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “roadTripImage2”);

    In Flash there is an error which says that the script has an error:

    Statement must appear within on handler

    import flash.external.*;

    Statement must appear within on handler

    btnShowImage.onRelease = function(){

    What I found out was that you cannot apply this AS to a button directly, as you would with a .onrelease function etc.

    What you need to do is to apply this LightboxInjector AS to the stage. So just click on the stage and then select the AS Window and then put the AS code in there.

    The reason I found for this is that the import flash.external.*; command only works as a Static AS and when attached to a button it is classified as Dynamic AS. This is also the reason for the error in the line btnShowImage.onRelease = function(){.

    This should eliminate all the error messages you are getting with the syntax in Flash.

    The other thing you have to do, now that the AS relates to the stage and not the button you want it to work with is give the button an instance name. If you haven’t already.

    The next step would be to go back to the AS on the stage and in the line where it says btnShowImage.onRelease = function() { and change the part btnShowImage to the same as the instance name for the button you want it to effect.

    eg. buttoninstancename.onRelease = function() {

    However, after doing all this to eliminate the Flash AS errors I can still not get the lightboxinjector to work with the button I want.

    Please can I get some help with this.

    And as before I’ll post my findings on here unless it is answered here.

    Hope that helps someone.

  98. Is it possible to use flash injector from flash to launch an external SWF?

  99. Hello,

    Great script, but I’m struggling to get any images to display for me.

    Testing site: http://www.creo-group.com/lo/celebrity-closets.php

    When the limo stops, Click here to Enter displays, at which point user would click an the 1st image of the set of 26 should appear. But it doesn’t.

    Any help would be greatly appreciated.

  100. I use foxycart in my site and the script seems to be clashing with foxycart files. It works perfectly without the foxycart files, but after adding foxycart script, nothing happens. Any help will be greatly appreciated!!!

    Thanks in advance.

  101. I got lightbox to work in FF and Safari, but it doesn’t work in Internet Explorer? I have the “id” attribute set, so what else am I doing wrong.

    this is my code in FLASH:

    import flash.external.ExternalInterface;


    function callJS(event:MouseEvent):void
    ExternalInterface.call(“GroupDelegate”, “Thumb01” );

    Like I said, it works fine in Firefox and Safari but not in Internet Explorer.

    my site is http://solarinkgraphics.com/
    and it’s in the PRINT section.

  102. Hi folks.
    Anyone having problems triggering Lightbox from their swf’s mc buttons? I spent about 12 hours on this today pulling my hair out, searching across every forum I could find. Problem was that I had been testing it locally, and though the html links work fine for lightbox off my c drive, the flash triggers were doing nothing.
    Loaded it all up online, voila! it works perfectly!!
    Feel stupid now as it was such a simple solution!

  103. Hi everyone,
    is there any final solution (after 2 years !!!) for the flash swf file disappearing when the lightbox starts to open the images – mean, above mentioned lines 376 and 624 of lightbox.js version 1.1. – when the site is uploaded in IE…i got it working in Firefox but cant do it in Explorer…IE is putting the lightbox always under the swf!!!


  104. Hi,
    thanks for your great script!
    Unlike most other users here I’m going for the “alternative usage” 🙂
    I don’t want to use a drop down like you did, but I’d like to have a normal Input field where the user types something like “picture.jpg”, hits enter and picture.jpg will be opened with lightbox.
    Should be pretty easy I guess but I’m stuck… 🙁

  105. Hi,

    I already made this work for one flash button > one gallery.
    Thanks a lot!

    But now I want to have several flash buttons that open different lightbox galleries.

    To do that, repeated the flash code, editing the new button instance name and the new file id (I also created another lightbox rel in the html):

    import flash.external.*;

    btn_bedroom1.onRelease = function() {
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “Bonjardim1” + “”);

    btn_bedroom3.onRelease = function() {
    ExternalInterface.call(“myFlashLightBoxInjector.start”, “Bedroom3-1” + “”);

    But for some reason, the second button doesn’t work.
    What am I missing?

    Thanks in advance!

  106. Hello, this looks great.
    I am trying to launch “Lightbox Plus” plugin in WordPress with a Flash button.
    Could this work? is there a working example for this or code modifications?

  107. Hi Bramus,

    I am developing a website in which I have embed the flash object at the center of the HTML page. I have made all the pages in this way only. Now I want to show some images and videos on this flash content .i.e. I want to show images and videos at the center of my HTML page which is Flash object and I want to use the LightBox and VideoBox effect for showing the Images and Videos.
    I have downloaded the example which you have put on your site but I didn’t help much.
    Would highly appreciate if you can help me in this regard or can give me some pointer.

    Thanks & regards,

  108. Nice job with this! This was exactly what I was looking for. Is it possible to do a Google Maps lightbox thru Flash? Think it would be a complex build?

Leave a comment

Leave a Reply to kimweb Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.