A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Flash in Wordpress with Lightbox 2

  1. #1
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268

    Flash in Wordpress with Lightbox 2

    Flash CS3
    AS2


    Ok i've designed a strip of thumbnails in flash to go in a Wordpress site i'm working on, which when clicked need to open up images and videos using Lightbox 2. (Lightbox is already setup and working.)

    The problem is that i'm importing the links for each of the thumbnail buttons from a .txt file which works like this:

    Flash:
    Code:

    Code:
    getURL(_root.link1, "_blank");
    Text file:
    Code:

    Code:
    link1=http://www.website.com/image1.jpg
    This at present just opens the image in a new window, how can i make this work with Lightbox? I had look at this: http://www.bram.us/projects/flashlightboxinjector but not sure if it does what i need and can't figure out how to work it anyway

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    http://blog.codefidelity.com/?p=18

    this may help

    gparis

  3. #3
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    Thanks gparis, i actually just tried that but i'm still having problems. Here is my JS in the HTML page:

    Code:
    <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>
    In Flash i've got:

    Code:
    on (press) {
        getURL("javascript:LightboxDelegate('http://mywebsite.com/wp-content/themes/theme_name/images/logo.gif','My Caption Text')");
    }
    This is activating the lightbox i.e. the screen is darkening, but the image is not showing...whatever i change the url to (e.g. just 'logo.gif')

    Any idea why it won't show?

  4. #4
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    can anyone see any potential problems at all? still totally stuck with this

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    On the link i provided, it is specifically said that you need to send the w/h of the image.
    I'll post their code sample:

    PHP Code:
    <script type="text/javascript">
    function 
    SWFDelegate(url,width,height,caption) {
       var 
    objLink document.createElement('a');
       
    objLink.setAttribute('href',url);
       
    objLink.setAttribute('rel','lightbox');
       
    objLink.setAttribute('title',caption);
       if(
    typeof width != 'undefined') {
          
    objLink.setAttribute('width',width);
       }
       if(
    typeof height != 'undefined') {
          
    objLink.setAttribute('height',height);
       }
       
    Lightbox.prototype.start(objLink);
    }
    </
    script
    You’re now specifying the width and the height in your getURL functions, to match the signature of our javascript method. Remember, you must specify the arguments in the correct order: URL, width, height, and caption.

    gparis

  6. #6
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    sorry my mistake i was using the code from:

    http://blog.codefidelity.com/?p=16

    not

    http://blog.codefidelity.com/?p=18

    which is actually a bit simpler. I used the code exactly as it was in the example though, so why wouldn't it show the image? I'll give the one you suggest a go but i would rather not have to specify height and width as this would make it harder for my client

  7. #7
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    ok just tried that code and getting exactly the same thing: the screen darkens so it's triggering lightbox, but no swf is showing

  8. #8
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    Firebug is showing that im getting this error:

    Code:
    imageLink.childNodes[0] is undefined
    [Break on this error] Failed to load source for: http://mywebsite.com/wp-content/plug...box.js?ver=1.8
    the line from lightbox thats its referring to is:
    Code:
    var possibleLightboxImageTitles = [imageLink.getAttribute('title'), imageLink.childNodes[0]['title'], imageLink.childNodes[0]['alt'], " "];
    help!

  9. #9
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    well that's different. Seems like it's an xml problem. Try hardcoding the url with that JS version, see if it works.

    gparis

  10. #10
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    where would i add the url?

  11. #11
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Since you get this error:
    imageLink.childNodes[0] is undefined
    replace that xml faulty var with a real path to an actual image. Troubleshooting 101

    Also tracing the other vars that come from the xml would be a good idea. You whole problem may come from there.

    gparis
    Last edited by gparis; 03-25-2010 at 04:58 PM.

  12. #12
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    ok thanks, where?

  13. #13
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    in the onLoad of the xml.

    gparis

  14. #14
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    if the problem is within lightbox2's code then surely it would be fixed if i just reinstalled it? If the lightbox works fine with normal images why wouldn't it work with the above AS and javascript?

  15. #15
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    can you tell me how to add it to the onLoad of the xml please gparis

  16. #16
    Senior Member brocwind's Avatar
    Join Date
    Jan 2003
    Location
    London
    Posts
    268
    can anyone else help with this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center