<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Can an SWF file read the filename of the XHTML file that loaded it?</title>
	<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it/</link>
	<description>Comments on Ask MetaFilter post Can an SWF file read the filename of the XHTML file that loaded it?</description>
	<pubDate>Thu, 24 Jun 2004 14:09:00 -0800</pubDate>
	<lastBuildDate>Thu, 24 Jun 2004 14:09:00 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Can an SWF file read the filename of the XHTML file that loaded it?</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it</link>	
		<description>Actionscript: Is there any way for a SWF file to read the name and/or path of the XHTML file that loaded it?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2004:site.8222</guid>
		<pubDate>Thu, 24 Jun 2004 13:02:37 -0800</pubDate>
		<dc:creator>signal</dc:creator>
		
			<category>Actionscript</category>
		
			<category>Shockwave</category>
		
			<category>SWF</category>
		
			<category>Flash</category>
		
			<category>XHTML</category>
		
	</item> <item>
		<title>By: grumblebee</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160224</link>	
		<description>This is a great question, and I&apos;m sure it&apos;s possible. I will try to cobble something together, but for now I&apos;ll leave you with these thoughts:&lt;br&gt;
&lt;br&gt;
-- there ISN&apos;T an actionscript command that does what you want (as far as I know).&lt;br&gt;
&lt;br&gt;
--BUT there IS a Javascript command that does it: try typing the following into your browser&apos;s URL field:&lt;br&gt;
&lt;br&gt;
javascript:alert(window.loation.href)&lt;br&gt;
&lt;br&gt;
You should get an popup window telling you the URL of the current page.&lt;br&gt;
&lt;br&gt;
-- So this means that you could write a javascript function THAT LIVES ON THE WEBPAGE -- NOT IN THE SWF -- that detects the current URL.&lt;br&gt;
&lt;br&gt;
-- there&apos;s and Actionscript command called FSCommand that can run Javascript functions on the webpage that houses the swf. So you could get the flash movie to run the Javascript function that returns the url.&lt;br&gt;
&lt;br&gt;
-- then you&apos;ve have to get this data back into the flash movie. It&apos;s possible to do that too, but I forget how. As I said, I&apos;ll work on it.&lt;br&gt;
&lt;br&gt;
--Meanwhile, here&apos;s some info from Flash&apos;s help system about fscommand:&lt;br&gt;
&lt;br&gt;
In the HTML page that embeds the SWF file, add the following JavaScript code: &lt;br&gt;
function theMovie_DoFSCommand(command, args) {&lt;br&gt;
  if (command == &quot;messagebox&quot;) {&lt;br&gt;
    alert(args);&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
If you publish your SWF file using the Flash with FSCommand template in the HTML Publish Settings dialog box, this code is inserted automatically. The SWF file&apos;s NAME and ID attributes will be the filename. For example, for the file myMovie.fla, the attributes would be set to myMovie. (For more information about publishing, see Publishing.)&lt;br&gt;
&lt;br&gt;
Alternatively, for Microsoft Internet Explorer applications, you can attach an event handler directly in the  tag, as shown in this example:&lt;br&gt;
&lt;br&gt;
[Script Language = &quot;JavaScript&quot; event=&quot;FSCommand (command, args)&quot; for= &quot;theMovie&quot;]&lt;br&gt;
...&lt;br&gt;
[/Script]&lt;br&gt;
&lt;br&gt;
In the Flash document, add the fscommand() function to a button, as shown in this example: &lt;br&gt;
on(press) {&lt;br&gt;
  fscommand(&quot;messagebox&quot;, &quot;This is a message box invoked from within Flash.&quot;);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
You can also use expressions for fscommand() and parameters, as in this example:&lt;br&gt;
&lt;br&gt;
fscommand(&quot;messagebox&quot;, &quot;Hello, &quot; + name + &quot;, welcome to our website!&quot;)&lt;br&gt;
&lt;br&gt;
Select File \ Publish Preview \ HTML to test the document.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160224</guid>
		<pubDate>Thu, 24 Jun 2004 14:09:00 -0800</pubDate>
		<dc:creator>grumblebee</dc:creator>
	</item><item>
		<title>By: signal</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160235</link>	
		<description>that is such a good answer. I will be very, very grateful if you &quot;work on it&quot; and help me fix this issue. I am working on a &lt;a href=&quot;http://www.morgan.cl&quot;&gt;website&lt;/a&gt; with a flash-based menu, and an unnatractive, not very efficient sharedobject-based system to keep track of where the user is in the navigation. Problem is, when you get to a page via an html link, or a back button, the menu doesn&apos;t change to reflect this.&lt;br&gt;
&lt;br&gt;
One question, would it be possible to pass a variable to flash in the EMBED tag, and have said variable be generated by the javascript window.location.href property?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160235</guid>
		<pubDate>Thu, 24 Jun 2004 14:26:05 -0800</pubDate>
		<dc:creator>signal</dc:creator>
	</item><item>
		<title>By: signal</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160286</link>	
		<description>Ok, this works:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;script LANGUAGE=&quot;JavaScript&quot;&amp;gt; --&amp;gt;&lt;br&gt;&lt;br&gt;
  document.write(&apos;&amp;lt;object classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0&quot; width=&quot;720&quot; height=&quot;125&quot;&amp;gt; &amp;lt;param name=quality value=high /&amp;gt;&amp;lt;param name=&quot;movie&quot; value=&quot;Menu.swf?topicname=&apos;+window.location.href+&apos;&quot; /&amp;gt;&amp;lt;embed src=&quot;Menu.swf&quot; quality=&quot;high&quot; pluginspage=&quot;http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;720&quot; height=&quot;125&quot;&amp;gt;&amp;lt;/embed&amp;gt; &amp;lt;/object&amp;gt;&apos;);&lt;br&gt;&lt;br&gt;
&amp;lt;/script&amp;gt;&lt;br&gt;
&lt;/code&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160286</guid>
		<pubDate>Thu, 24 Jun 2004 15:54:01 -0800</pubDate>
		<dc:creator>signal</dc:creator>
	</item><item>
		<title>By: signal</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160287</link>	
		<description>Notice the &quot;window.location.href&quot; in the middle of that jumble.&lt;br&gt;
&lt;br&gt;
One remaining question,  how would I make sure that non-javascript browsers still see the flash file? I&apos;m sure this is trivial, but I have next to no javascript experience.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160287</guid>
		<pubDate>Thu, 24 Jun 2004 15:55:29 -0800</pubDate>
		<dc:creator>signal</dc:creator>
	</item><item>
		<title>By: mrgavins</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160316</link>	
		<description>Put your EMBED (without the javascript &quot;window.location.href&quot;) in a noscript tag after your script.&lt;br&gt;
&lt;br&gt;
Example:&lt;br&gt;
&lt;br&gt;
&lt; script&gt;&lt;br&gt;
... what you have above ...&lt;br&gt;
&lt; / script&gt;&lt;br&gt;
&lt; noscript&gt;&lt;br&gt;
... standard object/embed ....&lt;br&gt;
&lt; / noscript&gt;&lt;br&gt;
&lt;br&gt;
Of course, the navigation thing still won&apos;t work without javascript.&lt;/&gt;&lt;/&gt;&lt;/&gt;&lt;/&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160316</guid>
		<pubDate>Thu, 24 Jun 2004 17:28:12 -0800</pubDate>
		<dc:creator>mrgavins</dc:creator>
	</item><item>
		<title>By: sad_otter</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160343</link>	
		<description>Are you really that concerned about non-JavaScript browsers? I mean, your nav is in Flash to begin with, which will probably already rules out the Luddite crowd.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160343</guid>
		<pubDate>Thu, 24 Jun 2004 19:24:52 -0800</pubDate>
		<dc:creator>sad_otter</dc:creator>
	</item><item>
		<title>By: holloway</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160349</link>	
		<description>Non-Javascript... maybe he wants search engines?&lt;br&gt;
&lt;br&gt;
&lt;small&gt;ps. Only rotters hunt otters.&lt;/small&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160349</guid>
		<pubDate>Thu, 24 Jun 2004 19:39:01 -0800</pubDate>
		<dc:creator>holloway</dc:creator>
	</item><item>
		<title>By: signal</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160370</link>	
		<description>in case anybody cares, here&apos;s the&lt;a href=&quot;http://altamira.cl/test/morgan/webCOLOR/index.htm&quot;&gt; test site&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
After you get past the entrance, the menu should show you where you are in the navigation (only the first 3 topics have sub-topics, though).&lt;br&gt;
&lt;br&gt;
sad_otter: some people might surf with javascript turned off, no? Just covering as many bases as possible.3&lt;br&gt;
&lt;br&gt;
Please let me know if it doesn&apos;t work on your platform/browser combo.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160370</guid>
		<pubDate>Thu, 24 Jun 2004 21:14:51 -0800</pubDate>
		<dc:creator>signal</dc:creator>
	</item><item>
		<title>By: sad_otter</title>
		<link>http://ask.metafilter.com/8222/Can-an-SWF-file-read-the-filename-of-the-XHTML-file-that-loaded-it#160424</link>	
		<description>&lt;i&gt;Non-Javascript... maybe he wants search engines?&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
Will a search bot parse a SWF to navigate? I doubt it.&lt;br&gt;
&lt;br&gt;
I was just pointing out that the Flash-enabled + JavaScript-disabled crowd is probably pretty small (and used to things not working quite right). But, yeah, adding a noscript is pretty trivial.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2004:site.8222-160424</guid>
		<pubDate>Fri, 25 Jun 2004 07:42:31 -0800</pubDate>
		<dc:creator>sad_otter</dc:creator>
	</item>
	</channel>
</rss>
