Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > HTML and JavaScript

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-21-2004, 07:01 PM   #1
christmashippo
Registered User
 
Join Date: Sep 2004
Posts: 3
Default Script { go to frame by URL change

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
christmashippo is offline   Reply With Quote
Old 09-21-2004, 10:21 PM   #2
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,048
Default

how are nextpage.html and frame 37 connected? are you using a frame label to connect them?
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 09-21-2004, 10:26 PM   #3
Ruben
Me
 
Ruben's Avatar
 
Join Date: Jul 2002
Location: Netherlands, Europe
Posts: 3,510
Send a message via MSN to Ruben Send a message via Skype™ to Ruben
Default

on both pages same swf

on both pages this javascript:
HTML Code:
<script language="JavaScript">
<!--
	function throwURL(){
		window.document.theIDofyirMovie.SetVariable('locationofpage',window.location);
		window.document.getElementById('theIDofyirMovie').SetVariable('locationofpage',window.location);
	}
-->
</script>
on both pages this in the <body> tag:
HTML Code:
<body onload="throwURL();">
and in the swf this script on the _root:
ActionScript Code:
//  script for frame 1: if (_root.locationofpage != undefined){   goHere = (_root.locationofpage.substring(_root.locationofpage.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

- Ruben

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

EDIT: I mistyped: gotoAndStop("goHere"); should be gotoAndStop(goHere);
__________________
.
Originally Posted by MichaelxxOA
"He sounded like he knew which words he was going to use before he knew what he was going to say. I hate that shit."

Last edited by Ruben; 09-22-2004 at 10:42 AM..
Ruben is offline   Reply With Quote
Old 09-22-2004, 12:33 AM   #4
christmashippo
Registered User
 
Join Date: Sep 2004
Posts: 3
Default

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
christmashippo is offline   Reply With Quote
Old 09-22-2004, 10:47 AM   #5
Ruben
Me
 
Ruben's Avatar
 
Join Date: Jul 2002
Location: Netherlands, Europe
Posts: 3,510
Send a message via MSN to Ruben Send a message via Skype™ to Ruben
Default

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

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
Attached Files
File Type: zip zip.zip (8.7 KB, 322 views)
__________________
.
Originally Posted by MichaelxxOA
"He sounded like he knew which words he was going to use before he knew what he was going to say. I hate that shit."
Ruben is offline   Reply With Quote
Old 09-22-2004, 03:24 PM   #6
christmashippo
Registered User
 
Join Date: Sep 2004
Posts: 3
Default

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
christmashippo is offline   Reply With Quote
Old 09-22-2004, 03:30 PM   #7
Ruben
Me
 
Ruben's Avatar
 
Join Date: Jul 2002
Location: Netherlands, Europe
Posts: 3,510
Send a message via MSN to Ruben Send a message via Skype™ to Ruben
Default

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?

- Ruben
__________________
.
Originally Posted by MichaelxxOA
"He sounded like he knew which words he was going to use before he knew what he was going to say. I hate that shit."
Ruben is offline   Reply With Quote
Old 10-24-2004, 11:10 PM   #8
pers.com
Registered User
 
pers.com's Avatar
 
Join Date: Oct 2004
Posts: 1
Lightbulb

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).
Code:
<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>
pers.com is offline   Reply With Quote
Old 10-25-2004, 08:00 AM   #9
Ruben
Me
 
Ruben's Avatar
 
Join Date: Jul 2002
Location: Netherlands, Europe
Posts: 3,510
Send a message via MSN to Ruben Send a message via Skype™ to Ruben
Default

Thanks pers.com!

I'll try that one soon myself

- Ruben
__________________
.
Originally Posted by MichaelxxOA
"He sounded like he knew which words he was going to use before he knew what he was going to say. I hate that shit."
Ruben is offline   Reply With Quote
Old 08-15-2005, 11:32 PM   #10
soundwaveiijima
Registered User
 
Join Date: Aug 2005
Posts: 1
Question

Quote:
Originally Posted by pers.com
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 "/age". 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).
Code:
<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! =)
soundwaveiijima is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.