View Full Version : pass url to flash, popup window
epicpix
05-19-2003, 04:16 PM
hi everyone,
i am trying to have a button in flash open a pop-up window upon release with a specific size
BUT
i need the url for this window either in an EXTERNAL TEXT FILE or IN the html page itself for easy editing.
PLease Help.
i have tried the following:
text file: url=http://www.google.com
flash file:
on (release) {
getURL("javascript:openNewWindow('url','google','height=53 0,width=565,toolbar=no,scrollbars=no')");
}
and inserted in the html page:
<script language ="JavaScript">
function openNewWindow (URLtoOpen, windowName, windowFeatures) {
newWindow=window.open(URLtoOpen, windowName, windowFeatures); }
</script>
</HEAD>
<BODY bgcolor="#000000">
<A HREF=javascript:openNewWindow('http://www.google.com','google','height=530,width=565,too lbar=no,scrollbars=no')></A>
but IT DOESN'T WORK. IT CANNOT FINE THE URL. a popup window with the correct size appears but it says that the file cannot be found.
what am i doing wrong? i know that i am almost there but need your help.
any help appreciated. thankyou.
catbert303
05-19-2003, 10:17 PM
Hi,
try,
in the html page add the function,
<script type="text/javascript">
function openNewWindow(url, name, features) {
newWindow = window.open(url, name, features);
}
</script>
then in flash,
on (release) {
getURL("javascript:openNewWindow('" + url + "','" + name + "','width=565,height=530');");
}
in the textfile have the variables url and name
&url=http://www.google.com&name=google&
make sure the variables have had chance to load before they're used in the link.
epicpix
05-20-2003, 12:04 AM
no, it still doesn't work.
i have added the as as described and the html page looks like this
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
<TITLE>plex_01</TITLE>
<script type="text/javascript">
function openNewWindow(url, name, features) {
newWindow = window.open(url, name, features);
}
</script>
</HEAD>
<BODY bgcolor="#000000">
<A HREF=javascript:openNewWindow('http://www.google.com','google','height=530,width=565,too lbar=no,scrollbars=no')></A>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="400" HEIGHT="300" id="plex_01" ALIGN="">
<PARAM NAME=movie VALUE="plex_01.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src="plex_01.swf" quality=high bgcolor=#000000 WIDTH="400" HEIGHT="300" NAME="plex_01" ALIGN=""
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>
</BODY>
</HTML>
But it still doesn't work. couldn't we simply add the vars in html and have them load into flash? how would we do that? loadVariablesNum("index.html", 0);
?
please help. thank you.
catbert303
05-20-2003, 10:04 AM
take
<PARAM NAME=movie VALUE="plex_01.swf">
and edit it as follows,
<PARAM NAME=movie VALUE="plex_01.swf?url=http://www.google.com&name=google">
then in the embed tag,
src="plex_01.swf"
becomes
src="plex_01.swf?url=http://www.google.com&name=google"
then in your movie use the link,
getURL("javascript:openNewWindow('" + _root.url + "','" + _root.name + "','width=500,height=400');");
make sure you remove the space in the word javascript
note that this method of passing variables to the movie only works when it is running on a web server.
epicpix
05-20-2003, 05:42 PM
this is great. it works. thank you so much.
but what if there are several pop-up buttons on the same swf (gallery01.html, gallery02.html, gallery03.html)?
how do i tweak it the javascript and as now so that each button knows where to go to?
has it anything to do with the value?
please advise.
thank you.
catbert303
05-20-2003, 09:39 PM
I guess you could separate out the urls and names with a separator character (in this example i'll use | ) then in the movie split the string into an array,
eg change the old query strings from,
url=http://www.google.com&name=google
to
url=http://www.google.com|http://www.actionscript.org|http://www.macromedia.com/support/flash&name=google|asdotorg|macromedia
then in the movie this loaded variable can be turned into an using,
urlArray = url.split("|");
nameArray = name.split("|");
then in your links the google link would become,
getURL("javascript:openNewWindow('" + _root.urlArray[0] + "','" + _root.nameArray[0] + "','width=500,height=400');");
the link to actionscript.org would then be,
getURL("javascript:openNewWindow('" + _root.urlArray[1] + "','" + _root.nameArray[1] + "','width=500,height=400');");
and so on. Note that if you want each new page to open in the same popup window you wouldn't need to use a separate name for each link, instead you could dispense with loading the name variable and just set a default name in the movie, eg
getURL("javascript:openNewWindow('" + _root.urlArray[0] + "','newWindow','width=500,height=400');");
also if the variables are likely to change often (since each time you change the variables the movie can't be retrieved from the users cache anymore, though sometimes this is desirable), you might want to conisder using flashvars.
To do this instead of the query string attached to the file name add a new <param name tag,
<param name="FlashVars" value="url=http://www.google.com|http://www.actionscript.org|http://www.macromedia.com/support/flash&name=google|asdotorg|macromedia" />
and the for the embed tag add the attribute,
FlashVars="url=http://www.google.com|http://www.actionscript.org|http://www.macromedia.com/support/flash&name=google|asdotorg|macromedia"
epicpix
05-21-2003, 02:30 AM
great. i have made it work with all of your great advice.
thank you so much.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.