PDA

View Full Version : Script { go to frame by URL change


christmashippo
09-21-2004, 07:01 PM
hi.

new here, but not new to flash. hopefully you guys can help, this seems like a very basic problem and i'm just being an idiot.

i'm on Flash MX (and a mac, if if matters).

I'm looking for a script that will redirect to a certain frame of my movie based on the url of the page that the .swf is embedded.

so on index.html we are at frame 1, but on nextpage.html it's frame 37. for example.

any ideas?

cheers.

-j

tg
09-21-2004, 10:21 PM
how are nextpage.html and frame 37 connected? are you using a frame label to connect them?

Ruben
09-21-2004, 10:26 PM
on both pages same swf

on both pages this javascript:<script language="JavaScript">
<!--
function throwURL(){
window.document.theIDofyirMovie.SetVariable('locat ionofpage',window.location);
window.document.getElementById('theIDofyirMovie'). SetVariable('locationofpage',window.location);
}
-->
</script>

on both pages this in the <body> tag:<body onload="throwURL();">

and in the swf this script on the _root:// script for frame 1:
if (_root.locationofpage != undefined){
goHere = (_root.locationofpage.substring(_root.locationofpa ge.length-"nextpage.html".length,_root.locationofpage.length) == "nextpage.html") ? "framefornextpage" : "frameforindex";
gotoAndStop(goHere);
}
// script for frame 2:
gotoAndPlay(_currentframe-1);


that'll do it I guess...kick me in the head if it's not working and I'll get back to you

:p - Ruben

EDIT: It might not be performing a 100% in all browsers, but most of them it'll work for...:)

EDIT: :mad: I mistyped: gotoAndStop("goHere"); should be gotoAndStop(goHere); :(

christmashippo
09-22-2004, 12:33 AM
ruben, it doesn't seem to be working.
the only things i've "configured" are the IdofyirMovie part (which i've just typed in the id name - test) and a frame in my movie called goHere.

am i missing something else to configure?

would this be easier if you emailed me the .fla and .html?
if it is, you can do that. christmashippo@yahoo.com

cheers

Ruben
09-22-2004, 10:47 AM
Excuse me for the bugs that were in the script, that's probably why it didn't function...

bugs:
- I mistyped: gotoAndStop("goHere"); should be gotoAndStop(goHere);
- The javascript function wasn't closed by a curly brace ( } );

sorry :rolleyes:

anyways, to make it up to you I attached a sample...I added you to my msn as well in case you've got any questions

:) - Ruben

christmashippo
09-22-2004, 03:24 PM
hey ruben.
i have tried debugging the stuff on my own, but i cannot get it to work. and it should work - of this i am sure. i was able to look at the movie (in MX), and i see that there is an index frame and nextpage frame, but when i load the .html files i only see "loading location".

maybe it's a mac thing.

i've tried IE and Safari.

also, i can't open movie.fla. did you protect it? again...this could be a mac thing.
failing all of these options, i'll just say thanks for the effort, really appreciated.

cheers

Ruben
09-22-2004, 03:30 PM
movie.fla is an FMX04-file...so maybe that's what's why you can't open it...

I haven't tested this way of doing stuff in safari yet, so I don't know if it's safari that's causing the problem...I tested it in IE and Firefox and it worked alright in those (I'm pretty sure they function alright in Netscape as well)...I'm on a PC...

Maybe someone else could try unzipping & testing the files I attached in my previous post?

:confused: - Ruben

pers.com
10-24-2004, 11:10 PM
Hi,

I tried Ruben's code and it works on Windows, but not Mac :(

I found this code on another bulletin board and it worked great on Mac and Win!

Just add the javascript below into the HTML page that contains the SWF file (you may want to change some of the settings, such as movie size)

This will send a variable called "page" to the SWF file.

You just need to create a Flash file with a dynamic field with a variable name of "page" or "/:page". Then publish the file, open the HTML generated by Flash, add the script below and view the HTML page (it works even from your drive).

<script type="text/javascript">
<!--
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" id=main width=550 height=300>');
document.write('<param name=movie value="test.swf?page=' + window.location + '"> <param name=quality value=high> <param name=bgcolor value=#ffffff> <param name="menu" value="false">');
document.write('<embed src="test.swf?page=' + window.location + '" quality=high bgcolor=#ffffff name=main menu=false width=550 height=300 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
document.write('</object>');
//-->
</script>

Ruben
10-25-2004, 08:00 AM
Thanks pers.com!

I'll try that one soon myself

:) - Ruben

soundwaveiijima
08-15-2005, 11:32 PM
Hi,

I tried Ruben's code and it works on Windows, but not Mac :(

I found this code on another bulletin board and it worked great on Mac and Win!

Just add the javascript below into the HTML page that contains the SWF file (you may want to change some of the settings, such as movie size)

This will send a variable called "page" to the SWF file.

You just need to create a Flash file with a dynamic field with a variable name of "page" or "/:page". Then publish the file, open the HTML generated by Flash, add the script below and view the HTML page (it works even from your drive).

<script type="text/javascript">
<!--
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" id=main width=550 height=300>');
document.write('<param name=movie value="test.swf?page=' + window.location + '"> <param name=quality value=high> <param name=bgcolor value=#ffffff> <param name="menu" value="false">');
document.write('<embed src="test.swf?page=' + window.location + '" quality=high bgcolor=#ffffff name=main menu=false width=550 height=300 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
document.write('</object>');
//-->
</script>

Can someone please walk me through all the little steps to make this code work? I'm using Flash 5 and have been trying in vain to get this to work for half a day now. I'm not too familiar with dynamic scripts and such and would really appreciate a walk thu. Thanks! =)