I was wondering whether some Actionscript exists that can detect what URL its SWF is in, and jump to a frame within the SWF accordingly?
For instance if menu.swf detects that it is embedded within home.html,it goes to Frame 1. Or if it detects it’s embedded within services.html it goes to Frame 2, etc.
If this is a ridiculous question, please excuse my ignorance.:hat:
Use flashvars. For example, edit each HTML page like so:
Within the OBJECT tag, place PARAM NAME=movie VALUE=“menu.swf?HTMLPage=home” for the home.html page and PARAM NAME=movie VALUE=“menu.swf?HTMLPage=services” for the services.html page.
Do the same with the EMBED tag, e.g. EMBED src=“menu.swf?HTMLPage=home” and EMBED src=“menu.swf?HTMLPage=services”
If you’re using SWFObject to embed your SWF file, use the following code; so.addVariable(“HTMLPage”, “home”); and so.addVariable(“HTMLPage”, “services”); for each respective page.
Repeat the above steps for every HTML page that you want to detect.
In the root timeline of your menu.fla you can use an if or switch/case statement, e.g.
switch (HTMLPage) {
case "home" :
targetFrame = 10;
break;
case "services" :
targetFrame = 20;
break;
// repeat for each page you want to detect, e.g.
case "contact" :
targetFrame = 30;
break;
default :
trace("ERROR: HTMLPage has no corresponding flashvar");
targetFrame = 99;
break;
}
gotoAndStop(targetFrame);