-
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
-
Use ExternalInterface.call() to call the LightboxDelegate function.
gparis
-
I'm new to actionscript. i didn't understand any of that. do you have a simplified way of doing this?
Thanks
-
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", url, caption);
gparis
-
Originally Posted by gparis
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", url, caption);
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.
-
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", url, caption); };
juste under the vars lines.
-
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", url, caption); };
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.
-
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
-
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?
-
That's not what i meant.. usually with lightbox you insert via "script src" prototype.js, scriptaculous.js and lightbox.js.
gparis
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|