A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Using LightBox 2 with a flash button

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    16

    Using LightBox 2 with a flash button

    Hi guys I've copied this code into my head tag in my html document



    <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>

    What is my code for the flash button supposed to look like? I'm using actionscript 2.0.

    Thanks

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Use ExternalInterface.call() to call the LightboxDelegate function.

    gparis

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    16
    I'm new to actionscript. i didn't understand any of that. do you have a simplified way of doing this?

    Thanks

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    I'm new to actionscript. i didn't understand any of that
    ok, do you at least know about functions and how to call them, even if just in javascript? because that's exactly what you need to do.

    You have a javascript function (LightboxDelegate) that has 2 parameters (url,caption). You need to call that function and pass the parameters as Strings, therefore using quote marks.

    So like with any other Class you first import it, then call the function:
    PHP Code:
    import flash.external.ExternalInterface;
    //define params:
    var url:String "somepage.html";
    var 
    caption:String "some caption";
    //call the javascript function:
    ExternalInterface.call("LightboxDelegate"urlcaption); 
    gparis

  5. #5
    Junior Member
    Join Date
    Aug 2009
    Posts
    16
    Quote Originally Posted by gparis View Post
    ok, do you at least know about functions and how to call them, even if just in javascript? because that's exactly what you need to do.

    You have a javascript function (LightboxDelegate) that has 2 parameters (url,caption). You need to call that function and pass the parameters as Strings, therefore using quote marks.

    So like with any other Class you first import it, then call the function:
    PHP Code:
    import flash.external.ExternalInterface;
    //define params:
    var url:String "somepage.html";
    var 
    caption:String "some caption";
    //call the javascript function:
    ExternalInterface.call("LightboxDelegate"urlcaption); 
    gparis
    ok good I'm following you here, i understand that. Flash keeps telling me that line 1 needs to appear within an on handler. I tried it with on(release) but I'm still getting errors. What is the proper way of applying this commands to a button?

    Thanks.

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    The code goes in a frame. The actual call can be triggered by a button. That button needs to be present on that particular frame number where the code is entered.

    For example, give your button the instance name lbox (via the property panel) and write:

    PHP Code:
    lbox.onRelease = function() {
    //call the javascript function: 
    ExternalInterface.call("LightboxDelegate"urlcaption); 
    }; 
    juste under the vars lines.

  7. #7
    Junior Member
    Join Date
    Aug 2009
    Posts
    16
    If I understood that correctly this is what I should have on a frame.

    PHP Code:
    import flash.external.ExternalInterface;
    //define params:
    var url:String "assets/images/robertsonEnlarged";
    var 
    caption:String "Robertson";
    lbox.onRelease = function() {
    //call the javascript function:
    ExternalInterface.call("LightboxDelegate"urlcaption); 
    }; 
    I gave my button an instance name of lbox. When I click the button the flash movie just disappears.

    Was the code I placed in my html page correct? I know I'm getting close.

  8. #8
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    As you're using Lightbox, i'm guessing you should have some insert for the js in the head of the html?
    Also if you load an image, i guess you should give it an extension. For example:
    robertsonEnlarged.jpg

    gparis

  9. #9
    Junior Member
    Join Date
    Aug 2009
    Posts
    16
    I added the jpg extension and my flash still disappears and no image pops up.
    I have the JavaScript in my first post inserted into the head tag of my HTML.

    PHP Code:
    PictureMC.onRelease = function() {
       
    getURL("javascript:LightboxDelegate(image1.jpg','caption1')")

    I've tried this code also and the same thing happens. I wonder what would cause the image not to pop up?

  10. #10
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    That's not what i meant.. usually with lightbox you insert via "script src" prototype.js, scriptaculous.js and lightbox.js.

    gparis

  11. #11
    Junior Member
    Join Date
    Sep 2001
    Posts
    13
    Does this work for 'Lightbox Plus' ?
    Looking for info or working examples of Flash button opening 'Lightbox Plus' plugin for WordPress

    Thanks
    Last edited by Firehazzard; 06-15-2011 at 01:08 PM.

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