こちらのサイトでタイトルのことをやりたかった次第。DataGrid内の写真をダブルクリックすると拡大表示。
Photo Stream(フォトストリーム)
この辺を見て試してみるものの、Lightboxを実行する時点でエラーになる。。
unstaticINACTION » Blog Archive » Execute Lightbox Scripts From Flash
しばらく悩んだらこちらに行き着きました。
Bram.us » flashLightBoxInjector 1.2 and Lightbox 2.0.4
In Lightbox 2.0.4 Lokesh (the author of Lightbox) decided to create the Lightbox instance without storing it into a variable. As flashLightBoxInjector relies on that variable, things broke. Now, to fix this follow this tiny procedure and it'll work just fine, as it did with version 2.0.3:
2.0.4では変数にインスタンスを格納しないようになっているんですね。これを解決するにはlightbox.jsの末尾にある
document.observe('dom:loaded', function () { new Lightbox(); });
これを
document.observe('dom:loaded', function () { myLightbox = new Lightbox(); });
としてあげて、Lightboxを呼び出すJavascript側では
// lightbox caller
function show(img_url) {
var objLink = document.createElement('a');
objLink.setAttribute('href',img_url);
objLink.setAttribute('rel','lightbox');
objLink.setAttribute('title','test');
myLightbox.start(objLink);
}
てな感じで。あ、Flex側はこちら。
var request:URLRequest = new URLRequest("javascript:show(" + targetData + ")");
navigateToURL(request, "_self");
targetDataには表示したい画像のURLを入れます。