14 Oct
Opening a ThickBox iframe from Flash
If you don’t know what is ThickBox, check it out here: http://jquery.com/demo/thickbox/
That’s some nice way to present content on your site right? Anyway, I’ve been playing around with ThickBox for quite some time now, and a recent project required me to call up a ThickBox iframe from within Flash itself.
As the documentation on the site only provided HTML help on how to implement ThickBox, I had to look for a way to do this myself. A search on Google yielded a few complicated ways to do this, which I did not think was effective since they involved writing of new Javascript functions. Then, I found this article which describes how to do almost exactly what I wanted - but, it requires a writing of a new function. And, it is opening an image, and not an iframe.
With what I learnt from the article, I went to take a look at ThickBox’s code. Thanks to their neat comments, I understood how the functions work after a few minutes, and I implemented what I learnt from the article (which is how to use ExternalInterface) to do exactly what I wanted.
The idea is to call the Javascript function that launches a iFrame ThickBox from thickbox.js. The function name is actually tb_show, with 3 parameters that you can pass in, namely, the caption, url and imageGroup. Obviously, what I need to pass in here is the URL.
Therefore, with the ExternalInterface, this is the code I need to put into Flash:
[code lang="actionscript"]
import flash.external.ExternalInterface;
Button.onRelease = function(){
ExternalInterface.call(”tb_show” , null ,”page.html?KeepThis=true&TB_iframe=true&height=150&width=150″ , false);
}
[/code]
If that doesn’t make sense to you, you need to see how ThickBox is launched with HTML originally:
[code lang="html"]
Click Here
[/code]
You can see that it requires the a tag to have a “thickbox” class. Which is why you can’t just use a getURL in Flash.
I hope this helps people out there. =)



Recent Comments