<?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/"
	>

<channel>
	<title>YAIMO BLOG &#187; Progression</title>
	<atom:link href="http://blog.yaimo.net/category/progression/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yaimo.net</link>
	<description>会津の大食いFlasher!!　WordPress, iPhone, Progression, FlashDevelop他</description>
	<lastBuildDate>Thu, 29 Jul 2010 12:26:10 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Progression 作成記録(1)</title>
		<link>http://blog.yaimo.net/2009/08/29/882/</link>
		<comments>http://blog.yaimo.net/2009/08/29/882/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 11:33:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Progression]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=882</guid>
		<description><![CDATA[今更ながら、Progressionを使用して実験サイトの土台を作成してみました。 実際に案件で使う前に一度使いたかったのが大きな理由。 コンテンツなど何も今の所ないのですが、随時追加予定。 http://yaimo.net/&#62; 今回はメモリのことはあまり考えず実装、構築してみました。 ざっくり使用した感想は、 Progressionでのメモリなどのある程度幅広い知識がないと実際の案件では投入できない コマンドを使用したり、ｓｗｆを読み込んだ際のunLoad時にメモリをうまく解放できないというのがあるそうです。 検索すると色々な方がエントリーしているので、探してみてください。 Progressionでガベージコレクションされないのをどうにかしようとした記録 メモリだけではなく、swfaddressを使用したパーマリンクを実現する際にも注意が必要。 たまに、Progressionを使用したサイトに見るのですが、Progressionのイベントフローでの処理を理解していないと、アドレスを直接入力した際、Progressionの出力エラーが表示されることがあります。 制作フローを確立すれば、デザインなどの方に時間が割けるのでより良いものが作れる Progressionを使用することで、同じコンテンツを作成する場合、かなり時間が短縮できると感じました。 特に、ボタンの自動で有効/無効にしてくれるなどの機能や、シーンという概念が最初は理解しにくかったのですが、これがあることにより、とても作りやすくなりますね。 制作後の管理が容易 オレオレプログラムより、Progressionで管理したら、引き継ぎなどをする際も簡単なのでは？ 更新する際や、コンテンツ追加の際も、prmlをうまく利用すればとても素敵！！な予感がしました。 今回作成した際に、得たものをこれから、ちょっとずつエントリーしていきます。 とりあえずProgressionデビューだ！！！！ 関連する投稿 【Flash拡張】JSFL MXP まとめ Progression URLObject の使い道 Progression this の扱い(破) 無名関数, Func, function Progression this の扱い(序) 無名関数, Func, function Progression this の扱い(Q) 無名関数, Func, function]]></description>
			<content:encoded><![CDATA[<div>
今更ながら、Progressionを使用して実験サイトの土台を作成してみました。<br />
実際に案件で使う前に一度使いたかったのが大きな理由。<br />
<br />
コンテンツなど何も今の所ないのですが、随時追加予定。<br />
<br />
<a href="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/08/090829.png" rel="shadowbox[post-882];player=img;"><img class="aligncenter size-medium wp-image-881" title="090829" src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/08/090829-300x222.png" alt="" /></a><br />
<p style="text-align: center;"><a href="http://yaimo.net/">http://yaimo.net/&gt;</a></p>
<br />
今回はメモリのことはあまり考えず実装、構築してみました。<br />
ざっくり使用した感想は、<br />
<ol>
	<li><strong>Progressionでのメモリなどのある程度幅広い知識がないと実際の案件では投入できない</strong><br /><br />
コマンドを使用したり、ｓｗｆを読み込んだ際のunLoad時にメモリをうまく解放できないというのがあるそうです。<br />
検索すると色々な方がエントリーしているので、探してみてください。<a href="http://blog.nipx.jp/2009/08/progression%E3%81%A7%E3%82%AC%E3%83%99%E3%83%BC%E3%82%B8%E3%82%B3%E3%83%AC%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%95%E3%82%8C%E3%81%AA%E3%81%84%E3%81%AE%E3%82%92%E3%81%A9%E3%81%86%E3%81%AB%E3%81%8B.html"><br />
Progressionでガベージコレクションされないのをどうにかしようとした記録</a><br /><br />
メモリだけではなく、swfaddressを使用したパーマリンクを実現する際にも注意が必要。<br />
たまに、Progressionを使用したサイトに見るのですが、Progressionのイベントフローでの処理を理解していないと、アドレスを直接入力した際、Progressionの出力エラーが表示されることがあります。</li><br />
	<li><strong>制作フローを確立すれば、デザインなどの方に時間が割けるのでより良いものが作れる</strong><br /><br />
Progressionを使用することで、同じコンテンツを作成する場合、かなり時間が短縮できると感じました。<br />
特に、ボタンの自動で有効/無効にしてくれるなどの機能や、シーンという概念が最初は理解しにくかったのですが、これがあることにより、とても作りやすくなりますね。</li><br />
	<li><strong>制作後の管理が容易</strong><br /><br />
<span style="color: #ff0000;">オレオレプログラム</span>より、Progressionで管理したら、引き継ぎなどをする際も簡単なのでは？<br />
更新する際や、コンテンツ追加の際も、prmlをうまく利用すればとても素敵！！な予感がしました。</li>
</ol>
今回作成した際に、得たものをこれから、ちょっとずつエントリーしていきます。<br />
<br />
とりあえずProgressionデビューだ！！！！</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/jsflmxp/" title="【Flash拡張】JSFL MXP まとめ (2009 年 7 月 31 日)">【Flash拡張】JSFL MXP まとめ</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/13/703/" title="Progression URLObject の使い道 (2009 年 7 月 13 日)">Progression URLObject の使い道</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/19/746/" title="Progression this の扱い(破) 無名関数, Func, function (2009 年 7 月 19 日)">Progression this の扱い(破) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/18/730/" title="Progression this の扱い(序) 無名関数, Func, function (2009 年 7 月 18 日)">Progression this の扱い(序) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/20/770/" title="Progression this の扱い(Q) 無名関数, Func, function (2009 年 7 月 20 日)">Progression this の扱い(Q) 無名関数, Func, function</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/08/29/882/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Progression this の扱い(Q) 無名関数, Func, function</title>
		<link>http://blog.yaimo.net/2009/07/20/770/</link>
		<comments>http://blog.yaimo.net/2009/07/20/770/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 10:37:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Command]]></category>
		<category><![CDATA[Progression]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[ParallelList]]></category>
		<category><![CDATA[SerialList]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=770</guid>
		<description><![CDATA[Progression this の扱い(破) 無名関数, Func, functionの続き。 Progressionクラスを生成し、コンストラクタで&#8221;id&#8221;を指定します。 this.id = &#34;yaimo&#34;; trace&#40;&#34;クラスのid: &#34;+this.id&#41;; //出力:クラスのid: yaimo trace&#40;&#34;普通にthis: &#34;+this&#41;; //出力:[IndexScene sceneId=&#34;/index&#34; id=&#34;yaimo&#34; name=&#34;index&#34; group=&#34;null&#34;] 今回はSerialList.addCommand()内でのthisの扱いについて、全体のコードはこんな感じです。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 var sList:SerialList = new SerialList&#40;&#41;; sList.id = [...]]]></description>
			<content:encoded><![CDATA[<div>
Progression this の扱い(破) 無名関数, Func, functionの続き。<br />
<br />
Progressionクラスを生成し、<strong>コンストラクタで&#8221;id&#8221;を指定</strong>します。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;yaimo&quot;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;クラスのid: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//出力:クラスのid: yaimo</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;普通にthis: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//出力:[IndexScene sceneId=&quot;/index&quot; id=&quot;yaimo&quot; name=&quot;index&quot; group=&quot;null&quot;]</span></pre></div></div>

<br />
<br />
今回は<strong>SerialList</strong>.addCommand()内でのthisの扱いについて、全体のコードはこんな感じです。<br />
<br />

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> sList<span style="color: #000000; font-weight: bold;">:</span>SerialList = <span style="color: #0033ff; font-weight: bold;">new</span> SerialList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			sList.id = <span style="color: #990000;">&quot;sList&quot;</span>;
			sList.addCommand<span style="color: #000000;">&#40;</span>
				<span style="color: #009900;">//[		</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> Trace<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SerialList.addCommand内でのthis.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>,
				<span style="color: #0033ff; font-weight: bold;">new</span> Func<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
				<span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SerialList.addCommand内でのthis&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SerialList.addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;Function&quot;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SerialList.addCommand内でのthis.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>,
				<span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
				<span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SerialList.addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.insertCommand<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Trace<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;追加1&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
					insertCommand<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Trace<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;追加2&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>,
&nbsp;
				<span style="color: #000000;">&#91;</span><span style="color: #009900;">//ここからParallelList</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> Func<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
				<span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SerialList.addCommand内でのthis: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SerialList.addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>,
				<span style="color: #000000;">&#93;</span>,</pre></td></tr></table></div>

<br />
全体の出力結果です。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">SerialList.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000; font-weight: bold;">:</span> yaimo
&nbsp;
SerialList.addCommand<span style="color: #000000;">&#40;</span>コード<span style="color: #000000;">&#41;</span>での実験<span style="color: #000000; font-weight: bold;">------</span><span style="color: #0033ff; font-weight: bold;">new</span> Func<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">---------</span>
SerialList.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>Func id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_47&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
SerialList.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>SerialList id=<span style="color: #990000;">&quot;sList&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_42&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
SerialList.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Function</span>
<span style="color: #000000; font-weight: bold;">-------------------------------------------------------------</span>
&nbsp;
SerialList.addCommand<span style="color: #000000;">&#40;</span>コード<span style="color: #000000;">&#41;</span>での実験<span style="color: #000000; font-weight: bold;">-----</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">----------</span>
SerialList.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.parentsList
<span style="color: #000000; font-weight: bold;">-------------------------------------------------------------</span>
追加<span style="color: #000000; font-weight:bold;">1</span>
&nbsp;
SerialList.ddCommand<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>コード<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>での実験<span style="color: #000000; font-weight: bold;">-----</span><span style="color: #0033ff; font-weight: bold;">new</span> Func<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">----------</span>
SerialList.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#91;</span>Func id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_48&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
SerialList.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>ParallelList id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_54&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
<span style="color: #000000; font-weight: bold;">-------------------------------------------------------------</span></pre></div></div>

<br />
<br />
<hr /><br />
<br />
基本は前回とほとんど同じなので省きます。<br />
それで注目したいのが、10行目の<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SerialList.addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
での出力が<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">SerialList.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>SerialList id=<span style="color: #990000;">&quot;sList&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_42&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span></pre></div></div>

<br />
でthis.parentの参照がsListになることです。<br />
なので、19,20行目のthis.parentでsListにinsertCommandによる挿入を行わないと思ったとおりの実行をしてくれません。<br />
&#8220;追加１&#8221;の実行されるタイミングはfunctionのCommandが終わってから。<br />
&#8220;追加2&#8243;はおそらく、クラスに定義されているaddCommand()｛｝に登録されるんじゃないかと思われます。<br />
<br />
【まとめ】<br />
<ul>
	<li>new Func(function:void{}),function():void{}内での<strong>thisはFuncクラスを指す</strong>。</li>
<br />
	<li>SerialList.addCommand(){}の場合、function():void{this.parent}はSerialListを指す。</li>
</ul>
<br />
</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/2009/07/19/746/" title="Progression this の扱い(破) 無名関数, Func, function (2009 年 7 月 19 日)">Progression this の扱い(破) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/jsflmxp/" title="【Flash拡張】JSFL MXP まとめ (2009 年 7 月 31 日)">【Flash拡張】JSFL MXP まとめ</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/18/730/" title="Progression this の扱い(序) 無名関数, Func, function (2009 年 7 月 18 日)">Progression this の扱い(序) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/2009/08/29/882/" title="Progression 作成記録(1) (2009 年 8 月 29 日)">Progression 作成記録(1)</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/13/703/" title="Progression URLObject の使い道 (2009 年 7 月 13 日)">Progression URLObject の使い道</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/07/20/770/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Progression this の扱い(破) 無名関数, Func, function</title>
		<link>http://blog.yaimo.net/2009/07/19/746/</link>
		<comments>http://blog.yaimo.net/2009/07/19/746/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 08:11:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Command]]></category>
		<category><![CDATA[Progression]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[ParallelList]]></category>
		<category><![CDATA[SerialList]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=746</guid>
		<description><![CDATA[Progression this の扱い(序) 無名関数, Func, functionの続き。 Progressionクラスを生成し、コンストラクタで&#8221;id&#8221;を指定します。 this.id = &#34;yaimo&#34;; trace&#40;&#34;クラスのid: &#34;+this.id&#41;; //出力:クラスのid: yaimo trace&#40;&#34;普通にthis: &#34;+this&#41;; //出力:[IndexScene sceneId=&#34;/index&#34; id=&#34;yaimo&#34; name=&#34;index&#34; group=&#34;null&#34;] 今回はaddCommand()内でのthisの扱いについて、全体のコードはこんな感じです。 addCommand&#40; new Trace&#40;&#34;addCommand内でのthis.id: &#34; + this.id&#41;, new Func&#40;function &#40;&#41;:void &#123; trace&#40;&#34;addCommand内でのthis&#34; + this&#41;; trace&#40;&#34;addCommand内でのthis.parent&#34; + this.parent&#41;; this.id = &#34;Function&#34;; trace&#40;&#34;addCommand内でのthis.id: &#34; + this.id&#41;; trace&#40;&#34;addCommand内でのthis.parent.id: &#34; + this.parent.id&#41;; this.parent.id = &#34;parentはSerialList&#34;; trace&#40;&#34;addCommand内でのthis.parent&#34; + this.parent&#41;; [...]]]></description>
			<content:encoded><![CDATA[<div>
Progression this の扱い(序) 無名関数, Func, functionの続き。<br />
<br />
Progressionクラスを生成し、<strong>コンストラクタで&#8221;id&#8221;を指定</strong>します。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;yaimo&quot;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;クラスのid: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//出力:クラスのid: yaimo</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;普通にthis: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//出力:[IndexScene sceneId=&quot;/index&quot; id=&quot;yaimo&quot; name=&quot;index&quot; group=&quot;null&quot;]</span></pre></div></div>

<br />
<br />
今回はaddCommand()内でのthisの扱いについて、全体のコードはこんな感じです。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">addCommand<span style="color: #000000;">&#40;</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> Trace<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>,
				<span style="color: #0033ff; font-weight: bold;">new</span> Func<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;Function&quot;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id = <span style="color: #990000;">&quot;parentはSerialList&quot;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>,
				<span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;fuction&quot;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent.id: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>,
				<span style="color: #000000;">&#91;</span><span style="color: #009900;">//ここからParallelList</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> Func<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;Function&quot;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.id: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent.id: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>,
				<span style="color: #000000;">&#93;</span>
			<span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
<span id="more-746"></span><br />
全体の出力結果です。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">addCommand<span style="color: #000000;">&#40;</span>コード<span style="color: #000000;">&#41;</span>での実験<span style="color: #000000; font-weight: bold;">-----</span><span style="color: #0033ff; font-weight: bold;">new</span> Func<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">----------</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>Func id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_12&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>SerialList id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_4&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Function</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">null</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>SerialList id=<span style="color: #990000;">&quot;parentはSerialList&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_4&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
&nbsp;
addCommand<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>コード<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>での実験<span style="color: #000000; font-weight: bold;">-----</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">----------</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>Func id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_28&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>SerialList id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_4&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000; font-weight: bold;">:</span> fuction
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">null</span>
&nbsp;
addCommand<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>コード<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>での実験<span style="color: #000000; font-weight: bold;">-----</span><span style="color: #0033ff; font-weight: bold;">new</span> Func<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">----------</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>Func id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_19&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>ParallelList id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_29&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Function</span>
addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">null</span></pre></div></div>

<br />
<br />
<hr /><br />
実際にコードを細かく見ていきます。<br />
<br />
まず2行目の、<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">new</span> Trace<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span></pre></div></div>

<br />
<br />
これは普通にクラス変数なので&#8221;yaimo&#8221;の出力です。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000; font-weight: bold;">:</span> yaimo</pre></div></div>

<br />
<br />
5~11行目<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;Function&quot;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id = <span style="color: #990000;">&quot;parentはSerialList&quot;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;addCommand内でのthis.parent&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
出力は<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">1.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>Func id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_12&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
2.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>SerialList id=<span style="color: #990000;">&quot;null&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_4&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span>
3.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Function</span>
4.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">null</span>
5.addCommand内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#91;</span>SerialList id=<span style="color: #990000;">&quot;parentはSerialList&quot;</span> <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;command_4&quot;</span> group=<span style="color: #990000;">&quot;null&quot;</span><span style="color: #000000;">&#93;</span></pre></div></div>

<br />
<br />
1.thisはFuncコマンドを指すようです。<br />
2.Funcコマンドの親はクラス全体のことを指すと思ったのですが、<br />
どうやらaddCommandで登録したSerialListの方を指すようです。<br />
3.1より、this = Funcなのでidを登録して出力しました。<br />
4.2からわかるようにSerialListのidは&#8221;null&#8221;です。<br />
5.なので同様に、this.parent.idを登録して出力しました。<br />
<br />
<hr /><br />
<br />
■じゃぁ、function():void{}でやってみたらどうなるの？っていうのが15~19行目。<br />
同じですね。function():void{}はnew Func(){function():void{}}を省略した書き方だった気がします。<br />
<br />
■3つ目は、addCommand()内に&#8221;[]&#8220;を使用することによってParallelListを使ったらどうなるかという実験です。<br />
this.parentがParallelListを参照するようになりました。<br />
なるほど、insertで追加するタイミングではParallelListにもなるということですね。<br />
これは応用できそうです。　<br />
<br />
【まとめ】<br />
<ul>
	<li>new Func(function:void{}),function():void{}内での<strong>thisはFuncクラスを指す</strong>。</li>
<br />
	<li>this.parentがSerialListなどを指してるのが意外。<br />
スーパークラスでaddCommand()を定義してあるだろうSerialListを指すのはあたりまえか（?)<br />
insertCommandをfunction内で記述する際は、クラスに定義されているaddCommand()｛｝に登録に追加するというイメージ<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">addCommand<span style="color: #000000;">&#40;</span>
<span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
insertCommand<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Trace<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;this.addCommand()に追加&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
</li></ul>
<br />
これが次につながってくる。つづく。</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/2009/07/20/770/" title="Progression this の扱い(Q) 無名関数, Func, function (2009 年 7 月 20 日)">Progression this の扱い(Q) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/jsflmxp/" title="【Flash拡張】JSFL MXP まとめ (2009 年 7 月 31 日)">【Flash拡張】JSFL MXP まとめ</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/18/730/" title="Progression this の扱い(序) 無名関数, Func, function (2009 年 7 月 18 日)">Progression this の扱い(序) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/2009/08/29/882/" title="Progression 作成記録(1) (2009 年 8 月 29 日)">Progression 作成記録(1)</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/13/703/" title="Progression URLObject の使い道 (2009 年 7 月 13 日)">Progression URLObject の使い道</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/07/19/746/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Progression this の扱い(序) 無名関数, Func, function</title>
		<link>http://blog.yaimo.net/2009/07/18/730/</link>
		<comments>http://blog.yaimo.net/2009/07/18/730/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 07:04:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Progression]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=730</guid>
		<description><![CDATA[ProgressionのCommand時におけるthisの参照の違いと、無名関数におけるブロックスコープとthisの参照について考える。 Progressionクラスを生成し、コンストラクタで&#8221;id&#8221;を指定します。 this.id = &#34;yaimo&#34;; trace&#40;&#34;クラスのid: &#34;+this.id&#41;; //出力:クラスのid: yaimo trace&#40;&#34;普通にthis: &#34;+this&#41;; //出力:[IndexScene sceneId=&#34;/index&#34; id=&#34;yaimo&#34; name=&#34;index&#34; group=&#34;null&#34;] まずはじめに無名関数におけるthisの扱いから、 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 private function hoge&#40;&#41;:void &#123; var target:MovieClip = new MovieClip&#40;&#41;; trace&#40;&#34;普通の関数内でのthis.id: &#34;+this.id&#41;; &#160; target.addEventListener&#40;MouseEvent.MOUSE_OUT,function &#40;&#41;:void &#123; trace&#40;&#34;無名関数内でのtarget: &#34;+target&#41;; trace&#40;&#34;単純にthis: &#34; + this&#41;; trace&#40;&#34;ではthis.parent: &#34; [...]]]></description>
			<content:encoded><![CDATA[<div>
ProgressionのCommand時におけるthisの参照の違いと、無名関数におけるブロックスコープとthisの参照について考える。<br />
<br />
Progressionクラスを生成し、<strong>コンストラクタで&#8221;id&#8221;を指定</strong>します。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;yaimo&quot;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;クラスのid: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//出力:クラスのid: yaimo</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;普通にthis: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//出力:[IndexScene sceneId=&quot;/index&quot; id=&quot;yaimo&quot; name=&quot;index&quot; group=&quot;null&quot;]</span></pre></div></div>

<br />
まずはじめに無名関数におけるthisの扱いから、<br />
<br />

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> hoge<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">target</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MovieClip</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">MovieClip</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;普通の関数内でのthis.id: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">target</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_OUT</span>,<span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;無名関数内でのtarget: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;単純にthis: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;ではthis.parent: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;無名関数内でのthis.id: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;無名関数内でのthis.target: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #0033ff; font-weight: bold;">this</span>.id = <span style="color: #990000;">&quot;this.idは無名関数内のidとして登録されています。&quot;</span>;
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;登録後のthis: &quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<br />
<span id="more-730"></span>出力結果は以下の通り<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">1.無名関数内での<span style="color: #004993;">target</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#91;</span>object <span style="color: #004993;">MovieClip</span><span style="color: #000000;">&#93;</span>
2.単純に<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#91;</span>object <span style="color: #004993;">global</span><span style="color: #000000;">&#93;</span>
3.では<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">undefined</span>
4.無名関数内での<span style="color: #0033ff; font-weight: bold;">this</span>.id<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">undefined</span>
5.無名関数内での<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">target</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">undefined</span>
6.登録後の<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">this</span>.idは無名関数内のidとして登録されています。</pre></div></div>

<br />
<br />
では、無名関数のthisはいったいどこを参照することになるんだろうか。<br />
予想だとthis = function()である無名関数を指してるんだと思う。<br />
<br />
<ol>
	<li>ActionScriptでは<a href="http://d.hatena.ne.jp/nitoyon/20090122/block_scope_abc">ブロックスコープ</a>というものがないので無名関数を使用した場合、hoge()のtargetが参照できる。<br />
(外側のローカル変数を参照できる)</li>
<br />
	<li>this: [object global] global?Functionクラスってグローバルクラスとして生成されるの？</li>
<br />
	<li>もし、this.parentがMovieClipならfunctionはtargetの下に存在し、this=fuction()のことだと思ったけどなんか違うみたい。</li>
<br />
	<li>無名関数がクラス全体を指してるなら&#8221;yaimo&#8221;と出るはずだけどもちろん出ない。</li>
<br />
	<li>もちろんでない。(this=hoge()??なんていう考えを疑った)</li>
<br />
	<li>グローバルクラスなので、変数をつけ足せちゃうみたい！へんな発見をした。</li>
</ol>
<br />
【まとめ】<br />
無名関数ではthis の正体はなんなのかわかったような分からないような結果だったけど、<br />
無名関数で this 使うとやけどする!!<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">無名関数での<span style="color: #0033ff; font-weight: bold;">this</span>扱いとしては、
<span style="color: #990000;">&quot;this=クラスの参照&quot;</span>を実装する時は、無名関数の外でローカル変数を定義し、無名関数での使用を推奨。</pre></div></div>

<br />
<br />
<br />
つづく。</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/jsflmxp/" title="【Flash拡張】JSFL MXP まとめ (2009 年 7 月 31 日)">【Flash拡張】JSFL MXP まとめ</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/19/746/" title="Progression this の扱い(破) 無名関数, Func, function (2009 年 7 月 19 日)">Progression this の扱い(破) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/20/770/" title="Progression this の扱い(Q) 無名関数, Func, function (2009 年 7 月 20 日)">Progression this の扱い(Q) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/2009/08/29/882/" title="Progression 作成記録(1) (2009 年 8 月 29 日)">Progression 作成記録(1)</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/13/703/" title="Progression URLObject の使い道 (2009 年 7 月 13 日)">Progression URLObject の使い道</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/07/18/730/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Progression URLObject の使い道</title>
		<link>http://blog.yaimo.net/2009/07/13/703/</link>
		<comments>http://blog.yaimo.net/2009/07/13/703/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 08:02:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Progression]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=703</guid>
		<description><![CDATA[Progression URLObject ってデータベースのやりとりに便利？な予感。AIRとか。 その他にもURL指定してあげれば url.navigateTo&#40;&#34;_blank&#34;&#41;; navigateToURLみたいに使えます。 flash on 2009-7-13 &#8211; wonderfl build flash online 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [...]]]></description>
			<content:encoded><![CDATA[<div>
Progression URLObject ってデータベースのやりとりに便利？な予感。AIRとか。<br />
その他にもURL指定してあげれば<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">url</span>.navigateTo<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;_blank&quot;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
navigateToURLみたいに使えます。<br />
<br />
<div style="text-align:center;width:465px;"><iframe title="flash on 2009-7-13 - wonderfl build flash online" scrolling="no" src="http://wonderfl.net/blogparts/eb5c1154f5d59357d3271f755703e0a03d45081b" width="465" height="490" style="border:1px black solid;"></iframe><a href="http://wonderfl.net/code/eb5c1154f5d59357d3271f755703e0a03d45081b" title="flash on 2009-7-13 - wonderfl build flash online">flash on 2009-7-13 &#8211; wonderfl build flash online</a></div>
<br />

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
    <span style="color: #0033ff; font-weight: bold;">import</span> jp.nium.net.<span style="color: #000000; font-weight: bold;">*</span>;
    <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<span style="color: #000000; font-weight: bold;">*</span>;
    <span style="color: #0033ff; font-weight: bold;">import</span> jp.nium.external.<span style="color: #000000; font-weight: bold;">*</span>;
&nbsp;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> FlashTest extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> textList<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> =<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span>;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> FlashTest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
            <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span>URLObject = <span style="color: #0033ff; font-weight: bold;">new</span> URLObject<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://asdoc.progression.jp/test.swf&quot;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #6699cc; font-weight: bold;">var</span> url2<span style="color: #000000; font-weight: bold;">:</span>URLObject = <span style="color: #0033ff; font-weight: bold;">new</span> URLObject<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://localhost:8081/yaimo&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #004993;">url</span>.password = <span style="color: #990000;">&quot;password&quot;</span>;
            <span style="color: #004993;">url</span>.user = <span style="color: #990000;">&quot;me&quot;</span>;
            textinit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #004993;">url</span>.<span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #004993;">url</span>.host;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #004993;">url</span>.password;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #004993;">url</span>.<span style="color: #004993;">url</span>;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #004993;">url</span>.fileExtension;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">+</span>URLObject.validate<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;URLOBjectととはなんぞや&quot;</span><span style="color: #000000;">&#41;</span>;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #004993;">url</span>.fileName;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = url2.port;
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #004993;">url</span>.user;
&nbsp;
            <span style="color: #009900;">//URLRequestでかえってくるのでとりあえずURLはURLObjectに入れとけば管理しやすいとか？</span>
            textList<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">9</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">text</span> = <span style="color: #004993;">url</span>.toURLRequest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #009900;">//Flash Player のコンテナを含むアプリケーション（通常はブラウザ）でウィンドウを開くか、置き換えます。</span>
            <span style="color: #009900;">//コメントをはずすと指定URLに飛びます。</span>
            <span style="color: #009900;">//user設定してあるとuserでログインしたりもできる。</span>
            <span style="color: #009900;">//url.navigateTo(&quot;_blank&quot;);</span>
&nbsp;
            <span style="color: #009900;">//あとはデータベースと連動するときに役に立ちそうな予感(AIRとか)</span>
            <span style="color: #009900;">//指定URLに飛んだりするのが便利だった！！</span>
&nbsp;
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> textinit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; i<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">10</span>;i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">text</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #004993;">text</span>.<span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">300</span>;
                <span style="color: #004993;">text</span>.<span style="color: #004993;">y</span> = i<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">20</span>;
                <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span>;
                textList.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<br />
</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/jsflmxp/" title="【Flash拡張】JSFL MXP まとめ (2009 年 7 月 31 日)">【Flash拡張】JSFL MXP まとめ</a></li>
	<li><a href="http://blog.yaimo.net/2009/08/29/882/" title="Progression 作成記録(1) (2009 年 8 月 29 日)">Progression 作成記録(1)</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/19/746/" title="Progression this の扱い(破) 無名関数, Func, function (2009 年 7 月 19 日)">Progression this の扱い(破) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/18/730/" title="Progression this の扱い(序) 無名関数, Func, function (2009 年 7 月 18 日)">Progression this の扱い(序) 無名関数, Func, function</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/20/770/" title="Progression this の扱い(Q) 無名関数, Func, function (2009 年 7 月 20 日)">Progression this の扱い(Q) 無名関数, Func, function</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/07/13/703/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Progression SWF Profiler デバック やってみた</title>
		<link>http://blog.yaimo.net/2009/04/22/263/</link>
		<comments>http://blog.yaimo.net/2009/04/22/263/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 12:43:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Progression]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[SWFProfiler]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=263</guid>
		<description><![CDATA[Progressionのindex.asでSWF Profilerを以下のように書き込んで使ってやるとうまくいかなかったのでどうにかならないかやってみた。 SWFProfiler.init&#40;stage, this&#41;; 原因はおそらく Progressionのオブジェクトが右クリックの対象の場合、Progressionの自分で作ったコンテキストメニューにうまく追加ができない（自分の力不足） SWFProfiler.init(stage, this);のthisでのProgressionオブジェクトの登録がよろしくない。 コンテキストメニューを登録したProgression以外のオブジェクトより上にProgressionオブジェクトの設置 1の方法でSWF Profilerのコンテキストメニューの参照を Progressionのコンテキストメニューにいれてやろうかと思ったけど、CastMovieClip.contextMenu できるかなとおもったけどできなかったので保留。 Progressionでコンテキストメニュー追加はどうやるのかと、別の疑問が。。 var menu_item:ContextMenuItem = new ContextMenuItem&#40;&#34;Test&#34;,false,true,true&#41;; var menu_cm:ContextMenu = new ContextMenu &#40;&#41;; menu_cm.customItems = &#91;menu_item&#93;; CastMovieClip.contextMenu = menu_cm;//ここおかしいだろ 2の方法は、Progressionオブジェクトを SWF Profiler に渡すとうまくいかない。SWF Profilerの中身をのぞいてみると第2引数の &#40;swf : Stage, context : InteractiveObject&#41; と記述されておりProgressionのオブジェクトの参照がうまくいかなそうな予感がしなくもない。 3の方法は、上にあるので上にある方を参照してしまうだろうのでいい。 で解決案として、SWF Profiler用のオブジェクトを作成し、そいつに割り当ててやればいいんじゃないかと思います。 // SWF Profiler用のスプライト var shape:Sprite = new Sprite&#40;&#41;; stage.addChild&#40;shape&#41;; [...]]]></description>
			<content:encoded><![CDATA[<div>
Progressionのindex.asで<a href="http://www.lostinactionscript.com/blog/index.php/2008/10/06/as3-swf-profiler/">SWF Profiler</a>を以下のように書き込んで使ってやるとうまくいかなかったのでどうにかならないかやってみた。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">SWFProfiler.<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>, <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
<br />
原因はおそらく<br />
<ol>
	<li>Progressionのオブジェクトが右クリックの対象の場合、Progressionの自分で作ったコンテキストメニューにうまく追加ができない（自分の力不足）</li>
	<li>SWFProfiler.init(stage, this);のthisでのProgressionオブジェクトの登録がよろしくない。</li>
	<li>コンテキストメニューを登録したProgression以外のオブジェクトより上にProgressionオブジェクトの設置</li>
</ol>
<span id="more-263"></span><br />
<hr />1の方法でSWF Profilerのコンテキストメニューの参照を Progressionのコンテキストメニューにいれてやろうかと思ったけど、CastMovieClip.contextMenu できるかなとおもったけどできなかったので保留。<br />
Progressionでコンテキストメニュー追加はどうやるのかと、別の疑問が。。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> menu_item<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ContextMenuItem</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ContextMenuItem</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Test&quot;</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #0033ff; font-weight: bold;">true</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> menu_cm<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ContextMenu</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ContextMenu</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
menu_cm.<span style="color: #004993;">customItems</span> = <span style="color: #000000;">&#91;</span>menu_item<span style="color: #000000;">&#93;</span>;
CastMovieClip.<span style="color: #004993;">contextMenu</span> = menu_cm;<span style="color: #009900;">//ここおかしいだろ</span></pre></div></div>

<br />
<br />
2の方法は、Progressionオブジェクトを SWF Profiler に渡すとうまくいかない。SWF Profilerの中身をのぞいてみると第2引数の<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000;">&#40;</span>swf <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Stage</span>, context <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">InteractiveObject</span><span style="color: #000000;">&#41;</span></pre></div></div>

<br />
<br />
と記述されておりProgressionのオブジェクトの参照がうまくいかなそうな予感がしなくもない。<br />
<br />
3の方法は、上にあるので上にある方を参照してしまうだろうのでいい。<br />
<br />
<hr /><br />
で解決案として、SWF Profiler用のオブジェクトを作成し、そいつに割り当ててやればいいんじゃないかと思います。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900;">// SWF Profiler用のスプライト</span>
<span style="color: #6699cc; font-weight: bold;">var</span> shape<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">stage</span>.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>shape<span style="color: #000000;">&#41;</span>;
shape.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span> <span style="color: #000000;">&#40;</span> 0xFF9999 , <span style="color: #000000; font-weight:bold;">0.8</span> <span style="color: #000000;">&#41;</span>;
shape.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span>;
shape.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//shapeのコンテキストメニューにSWFProfilerを登録してやる。</span>
SWFProfiler.<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>, shape<span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/jsflmxp/" title="【Flash拡張】JSFL MXP まとめ (2009 年 7 月 31 日)">【Flash拡張】JSFL MXP まとめ</a></li>
	<li><a href="http://blog.yaimo.net/2009/04/06/52/" title="WordPress プラグイン WP-Syntax コード を貼りたい (1) (2009 年 4 月 6 日)">WordPress プラグイン WP-Syntax コード を貼りたい (1)</a></li>
	<li><a href="http://blog.yaimo.net/2009/08/29/882/" title="Progression 作成記録(1) (2009 年 8 月 29 日)">Progression 作成記録(1)</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/13/703/" title="Progression URLObject の使い道 (2009 年 7 月 13 日)">Progression URLObject の使い道</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/19/746/" title="Progression this の扱い(破) 無名関数, Func, function (2009 年 7 月 19 日)">Progression this の扱い(破) 無名関数, Func, function</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/04/22/263/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
