<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>PmTea &#187; Flash</title>
	<atom:link href="http://pmtea.net/blog/category/tips/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://pmtea.net/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 06 Feb 2010 16:50:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://pmtea.net/blog/category/tips/flash/feed/" />
		<item>
		<title>_URL　SWFの自分の自身のパス位置を取得する。</title>
		<link>http://pmtea.net/blog/2008/12/07/_url%e3%80%80swf%e3%81%ae%e8%87%aa%e5%88%86%e3%81%ae%e8%87%aa%e8%ba%ab%e3%81%ae%e3%83%91%e3%82%b9%e4%bd%8d%e7%bd%ae%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e3%80%82/</link>
		<comments>http://pmtea.net/blog/2008/12/07/_url%e3%80%80swf%e3%81%ae%e8%87%aa%e5%88%86%e3%81%ae%e8%87%aa%e8%ba%ab%e3%81%ae%e3%83%91%e3%82%b9%e4%bd%8d%e7%bd%ae%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e3%80%82/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 16:36:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://pmtea.net/blog/?p=7</guid>
		<description><![CDATA[FlashでSWFの位置とHTMLの位置が違う場合で、外部読み込みや相対パスなどでSWFの外部へ読み込みにいく場合、相対パスがうまく取れず、取得できないことがある。
FlashはHTMLから読んだ位置からパス位置を見るの [...]]]></description>
			<content:encoded><![CDATA[<p>FlashでSWFの位置とHTMLの位置が違う場合で、外部読み込みや相対パスなどでSWFの外部へ読み込みにいく場合、相対パスがうまく取れず、取得できないことがある。<br />
FlashはHTMLから読んだ位置からパス位置を見るので、SWFを読み込むHTMLの位置が変わってしまえば、うまく読み込めないのだ。</p>
<p>フルパスで記述してやれば解決する話なのだけど、プレビューしたときにフルパスにしてやるとうまく見れない。<br />
そこで、Flash自身に自分のファイル位置を取得してやるということになる。</p>
<p>_url　は　自分自身のフルパスを取得してくる。</p>
<p><a href="http://pmtea.net/blog/wp-content/uploads/2010/02/4-url1.swf">4-url</a></p>
<p>ファイルを取得したい場合は、後ろのurl.swfが必要なくなる。<br />
自分自身の名前を決めうちする場合は、<a href="http://help.adobe.com/ja_JP/FlashLite/2.0_FlashLiteAPIReference2/WS5b3ccc516d4fbf351e63e3d118ccf9c47f-7b90.html">lastIndexOf()</a>で&#8221;/&#8221;までを取得させる。<br />
&#8220;/&#8221;はたくさんあるので、Math.<a href="http://help.adobe.com/ja_JP/FlashLite/2.0_FlashLiteAPIReference2/WS5b3ccc516d4fbf351e63e3d118ccf9c47f-7d5c.html">max()</a>で/の一番最後の/をとってくる。<br />
取得してきたものに、<a href="http://help.adobe.com/ja_JP/FlashLite/2.0_FlashLiteAPIReference2/WS5b3ccc516d4fbf351e63e3d118ccf9c47f-7fba.html">substr</a>()で後ろを除去した形で取得する。<br />
&#8220;/&#8221;より前になるので、substrを使うときにmaxで取得してきたモノに+1して&#8221;/&#8221;を含めて取得してやる。<br />
var swfUrl = this._url;<br />
var checkNum = Math.max(swfUrl.lastIndexOf(&#8220;/&#8221;), swfUrl.lastIndexOf(&#8220;¥¥&#8221;));<br />
var swfPath = swfUrl.substr(0, checkNum+1);</p>
<p>これで、自分自身のパス位置を取得することができる。</p>
]]></content:encoded>
			<wfw:commentRss>http://pmtea.net/blog/2008/12/07/_url%e3%80%80swf%e3%81%ae%e8%87%aa%e5%88%86%e3%81%ae%e8%87%aa%e8%ba%ab%e3%81%ae%e3%83%91%e3%82%b9%e4%bd%8d%e7%bd%ae%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://pmtea.net/blog/2008/12/07/_url%e3%80%80swf%e3%81%ae%e8%87%aa%e5%88%86%e3%81%ae%e8%87%aa%e8%ba%ab%e3%81%ae%e3%83%91%e3%82%b9%e4%bd%8d%e7%bd%ae%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e3%80%82/" />
	</item>
	</channel>
</rss>
