hi all - really hope someone can sort me out with this question i have.
i am trying to get lightwindow to launch from my script in as3
i have some thumbnails that are generated via xml - and when clicked the thumbnail opens a url in a new window.
i want it to open in the lightwindow box instead.
this is the as that i have on my thumbnails
PHP Code:
function p_click(me:MouseEvent)
{
var loader : Loader = new Loader ();
var request : URLRequest = new URLRequest ( "javascript : myLightWindow.activateWindow({href: 'wall.swf', title: 'lightwindow', author: 'anon', height: 480, width: 640});" );
loader . load ( request );
navigateToURL ( request , '_parent' );
}
but that doesn't seem to work - i am using this article as my reference for what should go in the script for the button.
the script i used and it worked to open a url in a new window was
PHP Code:
function p_click(me:MouseEvent)
{
var sp:Sprite = me.target as Sprite;
var s_no:Number = parseInt(sp.name.slice(8,10));
navigateToURL(new URLRequest(url_list[s_no]), url_target_list[s_no]);
}
that opens the url from the xml doc. this how the items in the xml look
PHP Code:
<thumbnail filename="name_of_thumb.jpg" url="http://www.domainname.com/folder/item.mov" target="_blank"
title="Item title"
description="some text that shows up on thumbnail mouse over" />
i am really struggling with this - i have also dropped the swf into html doc for lightwindow
and the html links - open the lightwindow up perfectly but the swf doesn't want to know.
has anyone managed to get this working before? or know of good points of reference to make it work from a flash button/xml.
there is no support on the stickman site - lots of config info - but not for flash?
is it even possible in flash? anyone know?
in summary how do i trigger lightwindow from an as3 button???
okay, been trying to work this out but i am still running into trouble getting it to work properly.
this is the script for the click on the thumbnail
PHP Code:
function p_click(me:MouseEvent) { var sp:Sprite = me.target as Sprite; //array reference to the url, var s_no:Number = parseInt(sp.name.slice(8,10));
var urlstring:String = "javascript:myLightWindow.activateWindow({" //include the url of the video in the string // urlstring += "href:'"+url_list[s_no]+"', " ///tweak those parameters (i guess you can even remove them urlstring += "title:'Sometitle', " urlstring += "author:'author'"
///leave the line below urlstring += "})"
//to check that you did right trace the urlstring: trace (urlstring) ////the output should be something like // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'author'})"
var req:URLRequest = new URLRequest(urlstring) /////and then finally go to the url: navigateToURL(req, url_target_list[s_no]); }
it gives me the correct trace message but when i drop it into the html doc - it doesn't want to work!?
this is the html that it is sitting in:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
is there something glaringly obvious that I am missing? i just can't seem to get it work. is it something in that script and code that i am trying to combine or would it be the way my xml is written? this how i have defined the items - this is what the flash should be reading...
PHP Code:
<thumbnail filename="thumb_01.jpg" url="gallery/fische01.mov" target="_blank" title="Item No. or title" description="description of this thumbnail image and associated file" />
...been doing my best to work it out - but just not there yet...
You cannot use navigateToURL for Javascript interaction. As I said above you need to use the ExternalInterface class and your movie would not work on your harddrive. You need to test it on your server. The Adobe language reference has a nice example when you check the ExternalInterface class.
- The right of the People to create Flash movies shall not be infringed. -
hi cancerinform - many thanks for the reply - appreciate your help and advice
...I have tested the files on a server and it didn't work - but as you have pointed out it won't because I am using navigate url.
I have read the instructions and tried to follow them for the ExternalInterface class - but am getting a little lost with it
instead of navigatetourl should i be using
ExternalInterface.addCallback()
or do I need to rewrite that somehow like this?
PHP Code:
function p_click(me:MouseEvent)
{
var sp:Sprite = me.target as Sprite;
//array reference to the url
var s_no:Number = parseInt(sp.name.slice(8,10));
var urlstring:String =
"javascript:myLightWindow.activateWindow({"
//Now, you need to include the url of the video in the string //in this way
urlstring += "href:'"+url_list[s_no]+"', "
///tweak those parameters (i guess you can even remove them
urlstring += "title:'Sometitle', "
urlstring += "author:'name'"
///remember to leave the line below
urlstring += "})"
//to check that you did right trace the urlstring:
trace (urlstring)
////the output should be something like
// "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'name'})"
var req:URLRequest = new URLRequest(urlstring)
/////and then finally go to the url:
ExternalInterface.addCallback(req, url_target_list[s_no]);
}
I am not sure what and where I need to add stuff or edit my existing script?
AS3 is a lot cleaner and stricter (which is good) - but it is something of a steep learning curve.
to the start of the script along with the other imports
and go to my onclick command that was this...
PHP Code:
function p_click(me:MouseEvent) { var sp:Sprite = me.target as Sprite; //array reference to the url, var s_no:Number = parseInt(sp.name.slice(8,10));
var urlstring:String = "javascript:myLightWindow.activateWindow({" //include the url of the video in the string // urlstring += "href:'"+url_list[s_no]+"', " ///tweak those parameters (i guess you can even remove them urlstring += "title:'Sometitle', " urlstring += "author:'author'"
///leave the line below urlstring += "})"
//to check that you did right trace the urlstring: trace (urlstring) ////the output should be something like // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'author'})"
var req:URLRequest = new URLRequest(urlstring) /////and then finally go to the url: navigateToURL(req, url_target_list[s_no]); }
do I need to change all refs to urlstring to the new call to the externalinterface? like this?
PHP Code:
function p_click(me:MouseEvent) { var sp:Sprite = me.target as Sprite; //this is your array reference to the url, right? var s_no:Number = parseInt(sp.name.slice(8,10));
var ExternalInterface.call:String = "javascript:myLightWindow.activateWindow({" //Now, you need to include the url of the video in the string //in this way ExternalInterface.call += "href:'"+url_list[s_no]+"', "
///remember to leave the line below ExternalInterface.call += "})"
//to check that you did right trace the urlstring: trace (ExternalInterface.call) ////the output should be something like // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'Fariska'})"
var req:URLRequest = new URLRequest(urlstring) /////and then finally go to the url: ExternalInterface.addCallback(req, url_target_list[s_no]);
I don't know what I need to do - is it six of one and half a dozen of the other? or have i fallen off altogether? is there more script to add elsewhere?
....nnnrgh! I am trying to write that line but i keep getting this error message
[PHP]1084: Syntax error: expecting rightparen before javascript:myLightWindow.activateWindow({.
function p_click(me:MouseEvent) { var sp:Sprite = me.target as Sprite; //this is your array reference to the url, right? var s_no:Number = parseInt(sp.name.slice(8,10));
var newWindow:String = String(ExternalInterface.call"javascript:myLightWindow.activateWindow({" //Now, you need to include the url of the video in the string //in this way ExternalInterface.call += "href:'"+url_list[s_no]+"', "
///remember to leave the line below ExternalInterface.call += "})"
//to check that you did right trace the urlstring: trace (ExternalInterface.call) ////the output should be something like // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'Fariska'})"
var req:URLRequest = new URLRequest(urlstring) /////and then finally go to the url: ExternalInterface.addCallback(req, url_target_list[s_no]); }
You cannot call javascript:..... You need to have a javascript function in the HTML page. Then as I mentioned above you call the Javascript function like this:
var newWindow:String = String(ExternalInterface.call("openWindow","page.h tml"));
Start simple with your Javascript function to get it working and then add up.
- The right of the People to create Flash movies shall not be infringed. -
...hi cancerinform - i do have the javascript in the html page
this is the entire html
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
this is a simplified version of the files - the .mov is missing from the gallery because of it's size but this is the movie that it calls...
anyone see what i am missing!?
...but this what is very odd! - in an fla with just a static button in and importing that class - when the swf button is clicked it 'does' load the lightwindow box with that video into the html doc - in the right way (ie as an overlay!)
but it just doesn't like anything else. Any ideas why that is? i'm at a total loss!
ps: apologies for my being so slow on the uptake here - so much has changed from as2!
...so now i get this error both locally (desktop) and online
PHP Code:
SecurityError: Error #2147: Forbidden protocol in URL ExternalInterface.call:myLightWindow.activateWindow({href:'gallery/fische01.movtitle:'Sometitle', author:'name'}).
at global/flash.net::navigateToURL()
at wall_fla::MainTimeline/p_click()
it tells me the same thing both if the publish settings are at local or/and network?
this is how my script now looks
PHP Code:
function p_click(me:MouseEvent)
{
var sp:Sprite = me.target as Sprite;
//this is your array reference to the url, right?
var s_no:Number = parseInt(sp.name.slice(8,10));
var urlstring:String = "ExternalInterface.call:myLightWindow.activateWindow({"
//Now, you need to include the url of the video in the string //in this way
urlstring += "href:'"+url_list[s_no]+"', "
///tweak those parameters (i guess you can even remove them
urlstring += "title:'Sometitle', "
urlstring += "author:'Fariska'"
///remember to leave the line below
urlstring += "})"
//to check that you did right trace the urlstring:
trace (urlstring)
////the output should be something like
// "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'Fariska'})"
var req:URLRequest = new URLRequest(urlstring)
/////and then finally go to the url:
navigateToURL(req, url_target_list[s_no]);
}
i feel like i've been trying to work this out for months now!!!1