PDA

View Full Version : Problems with Lightbox with AS3 in IE



Ricky55
September 4th, 2008, 05:58 PM
Hi

I have been using Lightbox with AS2 no problem but my latest project is in AS3, I came on the forum before and asked about this when I was testing the file and I was told to use the externalinterface call, I eventually got this code:



test_mc.addEventListener(MouseEvent.CLICK,callJS);

function callJS(event:MouseEvent):void
{
    ExternalInterface.call("flashLightbox", "images/jenson.jpg", "Jenson in Action" );
}

test_mc.buttonMode = true;


At the time I tested in Safari and it worked so I moved on to something else.

Now the site is complete and I have tested the page in Internet Explorer and the image fails to load I just get an error. With the old AS2 code it did work in IE.

I've been looking around and I've found some more code but I can't get this to work in any browser, can one of you guys tell me where I'm going wrong.

The alternative code
This in the HTML file


<script language="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>
[\code]

And the AS

[code]
test_mc.addEventListener(MouseEvent.CLICK,callJS);

function callJS(event:MouseEvent):void
{
ExternalInterface.call("SWFDelegate","images/jenson.jpg","600","398","Jenson in Action");
}


test_mc.buttonMode = true;


I have the AllowScriptAccess set to always as well.

Any help will be much appreciated !

teamchuck
September 26th, 2008, 02:39 PM
I'm actually just trying to install lightbox into my flash app. I'm not entirely sure how to do it. I know you can call the lightbox.js from flash using the externallinterface.call function, but I still not totally sure how to implement. Any pointers as to how to modify it for flash use?