<?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; AS3</title>
	<atom:link href="http://blog.yaimo.net/category/as3/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>asdoc クラスライブラリを除外する</title>
		<link>http://blog.yaimo.net/2009/09/09/972/</link>
		<comments>http://blog.yaimo.net/2009/09/09/972/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 10:29:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[asdoc]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=972</guid>
		<description><![CDATA[BetweenAS3 SoundManager サウンドまとめて管理の asdocを書きだそうとして四苦八苦したメモ。 FlashDevelopでasdocが簡単に書き出せる機能を使いました。 普段使わない人はなかなか気にとめないですよね。。 それで、今回問題になったのは、asdocを書きだそうとした際に、BetweenAS3を一緒に書きださないためのTips FlashDevelop3 RC3 から ASDoc を書き出すメモ をみながらサクサクっと簡単にasdocを書き出せたのはいいのですが、 今回作成したような~依存型のクラスファイルをasdocを書きだそうとしたのだけれども、 BetweenAS3も一緒に書き出されてしまいます。 BetweenAS3の文書は書き出さない方法は Project -&#62; Exclude classes で１つ１つファイルを除外 結果: 時間は大切にするべき Project -&#62; Exclude classes で&#8221; * &#8221; 使用してファイルを除外 結果: &#8221; * &#8221; によるファイル指定できず。 Extra optionsでAdobeの公式ページによると クラスの除外 doc-classes、doc-sources、および doc-namespaces オプションによって指定されるクラスは、次の例外を除いてすべて文書化されます。 * exclude-classes オプションを使用してクラスを指定した場合は、そのクラスは文書化されません。 * クラスの ASDoc コメントに @private タグが含まれる場合は、そのクラスは文書化されません。 * クラスが SWC で検出されると、そのクラスは文書化されません。 [...]]]></description>
			<content:encoded><![CDATA[<div>
<a href="http://blog.yaimo.net/2009/09/06/921/">BetweenAS3 SoundManager サウンドまとめて管理</a>の <strong>asdoc</strong>を書きだそうとして四苦八苦したメモ。<br />
<br />
FlashDevelopでasdocが簡単に書き出せる機能を使いました。<br />
<br />
<img class="aligncenter size-full wp-image-1011" title="5" src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/09/5.png" alt="5" width="454" height="111" />
<br />
<img class="aligncenter size-full wp-image-1010" title="6" src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/09/6.png" alt="6" width="547" height="355" />
<br />
普段使わない人はなかなか気にとめないですよね。。<br />
<br />
それで、今回問題になったのは、asdocを書きだそうとした際に、BetweenAS3を一緒に書きださないためのTips<br />
<br />
<strong><a href="http://blog.naggg.jp/2009/05/flashdevelop3-generates-asdoc.html">FlashDevelop3 RC3 から ASDoc を書き出すメモ</a></strong><br />
<br />
をみながらサクサクっと簡単にasdocを書き出せたのはいいのですが、<br />
<br />
今回作成したような<strong><span style="color: #ff0000;">~依存型のクラスファイルをasdocを書きだそうとした</span></strong>のだけれども、<br />
<br />
BetweenAS3も一緒に書き出されてしまいます。<br />
<br />
<img class="aligncenter size-full wp-image-1003" title="4d" src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/09/4d.png" alt="4d" width="473" height="359" />
<br />
BetweenAS3の文書は書き出さない方法は<br />
<ol>
	<li>Project -&gt; Exclude classes で１つ１つファイルを除外<br />
結果:<del datetime="2009-09-08T14:19:42+00:00"> <span style="color: #ff0000;">時間は大切にするべき</span></del></li>
<br />
	<li>Project -&gt; Exclude classes で&#8221; <strong>*</strong> &#8221; 使用してファイルを除外<br />
結果: &#8221; <strong>*</strong> &#8221; によるファイル指定できず。</li>
<br />
	<li>Extra optionsで<a href="http://livedocs.adobe.com/flex/3_jp/html/help.html?content=asdoc_9.html">Adobeの公式ページ</a>によると<br />
</p>
<blockquote><p>クラスの除外<br />
<br />
doc-classes、doc-sources、および doc-namespaces オプションによって指定されるクラスは、次の例外を除いてすべて文書化されます。<br />
<br />
* exclude-classes オプションを使用してクラスを指定した場合は、そのクラスは文書化されません。<br />
* クラスの ASDoc コメントに @private タグが含まれる場合は、そのクラスは文書化されません。<br />
* <strong>クラスが <span style="color: #ff0000;">SWC</span> で検出されると、そのクラスは文書化されません。</strong></p></blockquote>
<p>
さらに、さらに、<br />
</p>
<blockquote><p>コンパイル用として、SWC ファイルとして表されるライブラリファイルをアプリケーションが必要とする場合もあります。次の例では、-library-path オプションを使用して、<strong>SWC ファイルが格納されているディレクトリを指定</strong>します。<br />
asdoc -source-path . -doc-classes myComponents.BlueButton  <strong><span style="color: #0000ff;">-library-path C:¥myLibs</span></strong></p></blockquote>
<p>
<br />
<strong><span style="color: #ff0000;">明示的にSWCファイルをコンパイルオプションに入れてやれば、文書化されないようになる！！</span></strong><br />
<br />
<span style="color: #0000ff;"><strong>-library-path</strong></span> を使用してswcのあるフォルダを指定してやるとこうなります。<br />
<br />
<img class="aligncenter size-full wp-image-978" title="2" src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/09/2.png" alt="2" width="555" height="358" />
<br />
結果:<br />
<br />
<img class="aligncenter size-full wp-image-979" title="3" src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/09/3.png" alt="3" width="331" height="249" />
</li>
</ol>
ふひひ。できた!!<br />
SWCじゃないライブラリをフォルダでasdocの対象にならない指定ができたら便利なのに。。</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li>関連する投稿はありません。</li>
	</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/09/09/972/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BetweenAS3 SoundManager サウンドまとめて管理</title>
		<link>http://blog.yaimo.net/2009/09/06/921/</link>
		<comments>http://blog.yaimo.net/2009/09/06/921/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 07:52:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[sound、BetweenAS3]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=921</guid>
		<description><![CDATA[実用的(開発中のBetweenAS3 alpha を使ってる時点でアレだけど)な BetweenAS3依存のSoundManagerを作ってみました。 内部でBetweenAS3によるSoundのフェードアウト、インを実装しています。 モチベーションは、 ClockさんのQ-filmのソースを覗いていたらSoundManagerクラスがあって、 このSound管理の仕方がすごく勉強になったこと。 今まではSoundのON/OFFのTweenはTweenerを使用していましたが、これからBetweenAS3に移行していくつもりなので、１つのプロジェクトでTween系のライブラリを２つ使用するのは、なにかスッキリしなかった。 BetweenAS3がただ単に使いたかった。 SingltonクラスでSoundをまとめて管理しているので、一度初期化すればどこでも使えるのでとっても簡単。 実際のFlashでの案件のBGMやクリック音は大体1個ずつだから複数登録できなくても平気 SparkProjectに参加してみたい 【主な機能】 BGMのON/OFFと自動ループ再生,停止位置からの途中再生,自動Tween再生 BGMのボリューム変更,ボリューム自動保存機能,自動Tween変更 ボタン音のON/OFFとミュート機能 【使い方】 import SoundManagerをimportする。 import SoundManager SoundManager.instance.init()でSoundManagerにSoundインスタンスを割り当てる (初期化以降はクラスが変わっても省略可能) SoundManager.instance.init&#40;new BGM&#40;&#41;, new ClickSound&#40;&#41;, new OverSound&#40;&#41;&#41;; こんな感でも初期化可能 SoundManager.instance.bgm = new BGM&#40;&#41;; SoundManager.instanceを通してSoundのコントロール //BGMのコントロール &#160; //初期ボリュームの設定 SoundManager.instance.setBgmVol&#40;0.8&#41;; &#160; //再生(roop=true がデフォルトなので自動ループしてくれます) SoundManager.instance.playBGM&#40;&#41;; &#160; //ボリュームの変更 SoundManager.instance.setBgmVol&#40;0.9&#41;; &#160; //停止 SoundManager.instance.stopBGM&#40;&#41;; &#160; //再生位置(0)、ボリューム(0)から現在のボリューム(0.9)にTweenしながら再生(3秒) SoundManager.instance.playBGM&#40;0,true,3&#41;; &#160; //ボリューム0.5にTween処理しながら変更 [...]]]></description>
			<content:encoded><![CDATA[<div>
実用的(<del datetime="2009-09-06T08:42:44+00:00">開発中のBetweenAS3 alpha を使ってる時点でアレだけど</del>)な<br />
<br />
<strong>BetweenAS3依存のSoundManager</strong>を作ってみました。<br />
<br />
内部でBetweenAS3によるSoundのフェードアウト、インを実装しています。<br />
<br />
モチベーションは、<br />
<ol>
	<li><a href="http://clockmaker.jp/blog/2009/02/source_qfilms/">ClockさんのQ-filmのソース</a>を覗いていたらSoundManagerクラスがあって、<br />
このSound管理の仕方がすごく勉強になったこと。</li>
<br />
	<li>今まではSoundのON/OFFのTweenはTweenerを使用していましたが、これからBetweenAS3に移行していくつもりなので、１つのプロジェクトでTween系のライブラリを２つ使用するのは、なにかスッキリしなかった。</li>
<br />
<li>BetweenAS3がただ単に使いたかった。</li>
<br />
	<li>SingltonクラスでSoundをまとめて管理しているので、一度初期化すればどこでも使えるのでとっても簡単。<br />
<del datetime="2009-09-05T18:30:47+00:00">実際のFlashでの案件のBGMやクリック音は大体1個ずつだから複数登録できなくても平気</del><br />
</li>
<br />
<li>SparkProjectに参加してみたい</li>
</ol>
<strong>【主な機能】</strong><br />
<br />
<ul>
	<li><strong>BGMのON/OFFと自動ループ再生,停止位置からの途中再生,自動Tween再生</strong></li>
<br />
	<li><strong>BGMのボリューム変更,ボリューム自動保存機能,自動Tween変更</strong></li>
<br />
	<li><strong>ボタン音のON/OFFとミュート機能</strong></li>
</ul>
<br />
<span id="more-921"></span><br />
<br />
<strong>【使い方】</strong><br />
<ol>
	<li>import SoundManagerをimportする。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> SoundManager</pre></div></div>

<br />
<br />
</li>
	<li>SoundManager.instance.init()でSoundManagerにSoundインスタンスを割り当てる<br />
(初期化以降はクラスが変わっても省略可能)<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">SoundManager.instance.<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> BGM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #0033ff; font-weight: bold;">new</span> ClickSound<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #0033ff; font-weight: bold;">new</span> OverSound<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
<br />
こんな感でも初期化可能<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">SoundManager.instance.bgm = <span style="color: #0033ff; font-weight: bold;">new</span> BGM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
<br />
</li>
	<li>SoundManager.instanceを通してSoundのコントロール<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900;">//BGMのコントロール</span>
&nbsp;
<span style="color: #009900;">//初期ボリュームの設定</span>
SoundManager.instance.setBgmVol<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.8</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//再生(roop=true がデフォルトなので自動ループしてくれます)</span>
SoundManager.instance.playBGM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//ボリュームの変更</span>
SoundManager.instance.setBgmVol<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.9</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//停止</span>
SoundManager.instance.stopBGM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//再生位置(0)、ボリューム(0)から現在のボリューム(0.9)にTweenしながら再生(3秒)</span>
SoundManager.instance.playBGM<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #0033ff; font-weight: bold;">true</span>,<span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//ボリューム0.5にTween処理しながら変更</span>
SoundManager.instance.setBgmVol<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.5</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//現在のボリューム(0.5)から、ボリューム(0)にTweenしながら停止(2秒)</span>
SoundManager.instance.stopBGM<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span>,<span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//前回停止位置からの再生,ボリュームは(0)ではなく、前回停止したボリューム(0.5)で再生</span>
SoundManager.instance.playBGM<span style="color: #000000;">&#40;</span>SoundManager.instance.stopPosition<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//ボタン音のコントロール</span>
&nbsp;
<span style="color: #009900;">//ボタン音再生</span>
SoundManager.instance.playBtnOverSound<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
SoundManager.instance.playBtnClickSound<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//ボタン音のミュート設定</span>
SoundManager.instance.btnMute = <span style="color: #0033ff; font-weight: bold;">false</span>;</pre></div></div>

<br />
<br />
</li></ol>の3つが基本的な使い方の流れになっています。<br />
<br />
<strong>【その他】</strong><br />
<br />
<ul>
	<li>使用するSoundを一度割り当ててしまえば、クラスが変更した場合でも1,3のみでの操作が可能になります。<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> SoundManager
SoundManager.instance.playBtnOverSound<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
</li>
<br />
<br />
	<li>BGMだけはplayBGM,stopBGM()を2回以上連続した場合は、重複して再生されません。<br />
(状態が再生、停止状態ならばstop,play が実行可能)<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">SoundManager.instance.playBGM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//無視</span>
SoundManager.instance.playBGM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
</li>
<br />
<br />
	<li>Tween処理中に、playBGM,stopBGM,setBgmVolで上書きをした場合は、上書きが優先されます。<br />
(状態が再生、停止状態ならばstop,play の上書き可能)<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">SoundManager.instance.stopBGM<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//TweenのstopBGM()処理が中断され、BGMのボリューム(0.5)に変更します。</span>
SoundManager.instance.setBgmVol<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
</li>
<br />
</ul>
<br />
<br />
<hr /><br />
<br />
<a href="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/09/SoundManager.zip">Sound Managerダウンロード</a><br />
<br />
全ソース<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
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> net.yaimo.sound
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">Sound</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">SoundChannel</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">SoundTransform</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.libspark.betweenas3.BetweenAS3;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.libspark.betweenas3.core.easing.EaseNone;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.libspark.betweenas3.core.easing.IEasing;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.libspark.betweenas3.easing.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.libspark.betweenas3.events.TweenEvent;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.libspark.betweenas3.tweens.ITween;
&nbsp;
	<span style="color: #3f5fbf;">/**
	 * @author yaimo(yaimo.net)
	 * BetweenAS3依存のSingletonのSoundManagerクラスです。
	 * 一度初期化を行うことにより、SoundManagerをimportすることにより、どこでも使用することができます。
	 *
	 * @example
	 * import SoundManager
	 *
	 * //Soundの初期化
	 * SoundManager.instance.init(new BGM(), new ClickSound(), new OverSound());
	 *
	 * //BGMのコントロール
	 * SoundManager.instance.setBgmVol(0.8);//初期ボリュームの設定
	 * SoundManager.instance.playBGM();//再生
	 * SoundManager.instance.setBgmVol(0.2);//ボリュームの変更
	 * SoundManager.instance.stopBGM();//停止
	 *
	 * //ボタン音の再生
	 * SoundManager.instance.playBtnOverSound();
	 * SoundManager.instance.playBtnClickSound();
	 * SoundManager.instance.btnMute = false;//ボタン音のミュート設定
	 */</span>
&nbsp;
	<span style="color: #009900;">//将来的な機能memo</span>
	<span style="color: #009900;">//TODO 最大音量と最少音量設定にする@2009/09/01 21:16 - yaimo</span>
	<span style="color: #009900;">//TODO 全体のボリュームもコントロールできるようにできたらいい? @2009/09/03 18:01 - yaimo</span>
	<span style="color: #009900;">//TODO 将来的にsetBGM=0にしたときに自動でstop,playするかの機能？ @2009/09/03 18:28 - yaimo</span>
	<span style="color: #009900;">//TODO stopTween終了、playTween終了後の関数を登録できるようにする @2009/09/06 2:31 - yaimo</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SoundManager
	<span style="color: #000000;">&#123;</span>
		<span style="color: #3f5fbf;">/*** Tween関連 ***/</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> iTween<span style="color: #000000; font-weight: bold;">:</span>ITween;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> remainderTime<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
BGMを設定、取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> bgm<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _bgm; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> bgm<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</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>_bgm = <span style="color: #004993;">value</span>;<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span>	<span style="color: #6699cc; font-weight: bold;">var</span> _bgm<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
BGMが再生している場合、BGMのSoundChannelプロパティを取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> bgmChannel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">SoundChannel</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _bgmChannel; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span>	<span style="color: #6699cc; font-weight: bold;">var</span> _bgmChannel<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">SoundChannel</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
Click音を設定、取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> btnClick<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _btnClick; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> btnClick<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</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>_btnClick = <span style="color: #004993;">value</span>;<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span>	<span style="color: #6699cc; font-weight: bold;">var</span> _btnClick<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
Over音を設定、取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> btnOver<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _btnOver; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> btnOver<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</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> _btnOver = <span style="color: #004993;">value</span>; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span>	<span style="color: #6699cc; font-weight: bold;">var</span> _btnOver<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
ボタンのミュート状態を設定、取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> btnMute<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _btnMute; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> btnMute<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</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> _btnMute = <span style="color: #004993;">value</span>; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _btnMute<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
BGMをloopするかどうかを設定、取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> <span style="color: #004993;">loop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _loop; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">loop</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</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>_loop = <span style="color: #004993;">value</span>;<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _loop<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
BGM再生後のボリュームを取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> nextBgmVol<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _nextBgmVol; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span>	<span style="color: #6699cc; font-weight: bold;">var</span> _nextBgmVol<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
BGM再生中のボリュームを取得します。
&nbsp;
		 */</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> bgmVol<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _bgmChannel.<span style="color: #004993;">soundTransform</span>.<span style="color: #004993;">volume</span>; <span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
BGMが再生中かどうかをBoolean型で取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> isPlayingBGM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _isPlayingBGM; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _isPlayingBGM<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
BGMを停止した位置を取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> stopPosition<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _stopPosition; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _stopPosition<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
Tween中かどうかをBooleanで取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> isTween<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _isTween; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _isTween<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
stopBGMのTween中かどうかをBooleanで取得します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> isStopTween<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _isStopTween; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _isStopTween<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
Tweenに使用するEasingを設定します。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> easing<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>IEasing <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _easing; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> easing<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span>IEasing<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>_easing = <span style="color: #004993;">value</span>;<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _easing<span style="color: #000000; font-weight: bold;">:</span>IEasing;
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
すべてのメソッド、プロパティにアクセスするためのSoundManagerインスタンス
&nbsp;
		 */</span>
		static <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _instance<span style="color: #000000; font-weight: bold;">:</span>SoundManager = <span style="color: #0033ff; font-weight: bold;">new</span> SoundManager<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
        static <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> instance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>SoundManager <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _instance; <span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*======================================================================*/</span><span style="color: #3f5fbf;">/**
		 *
&nbsp;
SoundManagerはインスタンスできません。
&nbsp;
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> SoundManager<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_instance<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ArgumentError</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Singleton クラスは外部からインスタンス化できません.&quot;</span><span style="color: #000000;">&#41;</span>; <span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * @param BGMを指定
		 * @param Click音を指定
		 * @param Over音を指定
		 * @example
		 * SoundManager.instance.init(new BGM(), new ClickSound(), new OverSound());
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>bgm<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span>=<span style="color: #0033ff; font-weight: bold;">null</span>,btnClick<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span>=<span style="color: #0033ff; font-weight: bold;">null</span>,btnOver<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span>=<span style="color: #0033ff; font-weight: bold;">null</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;">this</span>.bgm = bgm;
			<span style="color: #0033ff; font-weight: bold;">this</span>.btnClick = btnClick;
			<span style="color: #0033ff; font-weight: bold;">this</span>.btnOver = btnOver;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">//--------------------------------------------------------------------------</span>
		<span style="color: #009900;">//</span>
		<span style="color: #009900;">// BtnSound</span>
		<span style="color: #009900;">//</span>
		<span style="color: #009900;">//--------------------------------------------------------------------------</span>
		<span style="color: #3f5fbf;">/**
		 * play RollOver sound
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> playBtnOverSound<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;">if</span> <span style="color: #000000;">&#40;</span>_btnMute<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>btnOver<span style="color: #000000;">&#41;</span> btnOver.<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * play Click sound
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> playBtnClickSound<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;">if</span> <span style="color: #000000;">&#40;</span>_btnMute<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>btnClick<span style="color: #000000;">&#41;</span> btnClick.<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900;">//--------------------------------------------------------------------------</span>
		<span style="color: #009900;">//</span>
		<span style="color: #009900;">// BgmSound</span>
		<span style="color: #009900;">//</span>
		<span style="color: #009900;">//--------------------------------------------------------------------------</span>
		<span style="color: #3f5fbf;">/**
		 * Play BGM
		 * @param 	startPosition		再生位置(ミリ秒)
		 * @param 	tween		ボリューム0からTween再生するかどうかをBoolean型で設定
		 * @param	tweenTime 		Tween時間(秒)
		 * @example
		 * SoundManager.instance.playBGM();//再生
		 * SoundManager.instance.playBGM(0,true);//ボリューム0からTweenしながら再生
		 * SoundManager.instance.playBGM(SoundManager.instance.stopPosition);//停止位置からの再生
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> playBGM<span style="color: #000000;">&#40;</span>startPosition<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span>, tween<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span>, tweenTime<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</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>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_isPlayingBGM<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span>;
			_isPlayingBGM = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
			<span style="color: #3f5fbf;">/*** stopTweenの中断処理 ***/</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_isStopTween<span style="color: #000000;">&#41;</span> _isStopTween = <span style="color: #0033ff; font-weight: bold;">false</span>;
			<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
				_bgmChannel = bgm.<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span>startPosition<span style="color: #000000;">&#41;</span>;<span style="color: #009900;">//BGMの再生</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_loop<span style="color: #000000;">&#41;</span> _bgmChannel.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">SOUND_COMPLETE</span>, BGMLoopHandler<span style="color: #000000;">&#41;</span>;<span style="color: #009900;">//BGMのループ処理をする場合</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #3f5fbf;">/*** ボリューム処理 ***/</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>tween<span style="color: #000000;">&#41;</span> setTweenVolume<span style="color: #000000;">&#40;</span>_nextBgmVol, <span style="color: #000000; font-weight:bold;">0</span>, tweenTime<span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">else</span> setVolume<span style="color: #000000;">&#40;</span>_nextBgmVol<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * BGMのループ処理関数
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> BGMLoopHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</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>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> currentVol<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = bgmVol; <span style="color: #009900;">//現在のボリュームを次のボリュームに引き継ぐ</span>
			<span style="color: #3f5fbf;">/*** bgmのループ再生処理 ***/</span>
			_bgmChannel.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">SOUND_COMPLETE</span>, BGMLoopHandler<span style="color: #000000;">&#41;</span>;
			_bgmChannel = <span style="color: #0033ff; font-weight: bold;">null</span>;
			_bgmChannel = bgm.<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_bgmChannel.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">SOUND_COMPLETE</span>, BGMLoopHandler<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #3f5fbf;">/*** ボリューム処理 ***/</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_isTween<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				remainderTime	= <span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>remainderTime <span style="color: #000000; font-weight: bold;">-</span> iTween.<span style="color: #004993;">position</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">10</span>;<span style="color: #009900;">//小数点第一まで減らす。</span>
&nbsp;
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_isStopTween<span style="color: #000000;">&#41;</span> setTweenVolume<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>, currentVol, remainderTime <span style="color: #000000;">&#41;</span>;
				<span style="color: #0033ff; font-weight: bold;">else</span> setTweenVolume<span style="color: #000000;">&#40;</span>_nextBgmVol, currentVol, remainderTime<span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">else</span> setVolume<span style="color: #000000;">&#40;</span>currentVol<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * BGMのストップ処理(すでにstop中だったら無視
		 * @param 	tween		ボリューム0にTween再生するかどうかをBoolean型で設定
		 * @param 	tweenTime		Tween時間(秒)
		 * @example
		 * SoundManager.instance.stopBGM();//再生
		 * SoundManager.instance.stopBGM(true);//ボリューム0にTweenしながら停止
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> stopBGM<span style="color: #000000;">&#40;</span>tween<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span>, tweenTime<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</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>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>_isPlayingBGM<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span>;
			_isPlayingBGM = <span style="color: #0033ff; font-weight: bold;">false</span>;
&nbsp;
			<span style="color: #3f5fbf;">/*** ボリューム処理 ***/</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>tween<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_isStopTween<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span>;
				_isStopTween = <span style="color: #0033ff; font-weight: bold;">true</span>;
				setTweenVolume<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>, bgmVol, tweenTime <span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
				removeTween<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				stopFunc<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * BGMをstop()させる際の処理をまとめた関数
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stopFunc<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>
&nbsp;
			<span style="color: #3f5fbf;">/*** 再生をstopした場所を保持 ***/</span>
			_stopPosition = _bgmChannel.<span style="color: #004993;">position</span>;
			_bgmChannel.<span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #3f5fbf;">/*** 状態の変更 ***/</span>
			_isStopTween = <span style="color: #0033ff; font-weight: bold;">false</span>;
&nbsp;
			<span style="color: #3f5fbf;">/*** BGMのループ処理が登録されている場合 ***/</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_bgmChannel.<span style="color: #004993;">hasEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">SOUND_COMPLETE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> _bgmChannel.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">SOUND_COMPLETE</span>, BGMLoopHandler<span style="color: #000000;">&#41;</span>;
			_bgmChannel = <span style="color: #0033ff; font-weight: bold;">null</span>;
		<span style="color: #000000;">&#125;</span>;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Bgmのボリューム変更
		 * @param 	volume		変更するボリュームを指定
		 * @param 	tween		Tweenでのボリューム変更するかどうかをBoolean型で設定
		 * @param 	tweenTime		Tweenさせる時間を指定
		 * @param
		 * SoundManager.instance.setBgmVol(0.5);//ボリュームを0.5に変更
		 *	SoundManager.instance.setBgmVol(0.5,true);//ボリューム0.5にTween処理しながら変更
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> setBgmVol<span style="color: #000000;">&#40;</span><span style="color: #004993;">volume</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,tween<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span>,tweenTime<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">1</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>
&nbsp;
			<span style="color: #3f5fbf;">/*** ボリュームの保持***/</span>
			_nextBgmVol = <span style="color: #004993;">volume</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_isPlayingBGM<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #3f5fbf;">/*** stopTweenの中断処理 ***/</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_isStopTween<span style="color: #000000;">&#41;</span> _isStopTween = <span style="color: #0033ff; font-weight: bold;">false</span>;
				<span style="color: #3f5fbf;">/*** ボリューム処理 ***/</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>tween<span style="color: #000000;">&#41;</span> setTweenVolume<span style="color: #000000;">&#40;</span><span style="color: #004993;">volume</span>, bgmVol, tweenTime<span style="color: #000000;">&#41;</span>;
				<span style="color: #0033ff; font-weight: bold;">else</span> setVolume<span style="color: #000000;">&#40;</span><span style="color: #004993;">volume</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900;">//--------------------------------------------------------------------------</span>
		<span style="color: #009900;">//</span>
		<span style="color: #009900;">// VolumeController</span>
		<span style="color: #009900;">//</span>
		<span style="color: #009900;">//--------------------------------------------------------------------------</span>
		<span style="color: #3f5fbf;">/**
		 * Tween&quot;なし&quot;でのボリューム設定
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> setVolume<span style="color: #000000;">&#40;</span><span style="color: #004993;">volume</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</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>
&nbsp;
			<span style="color: #3f5fbf;">/*** Tween初期化 ***/</span>
			removeTween<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #3f5fbf;">/*** ボリュームをセット ***/</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">soundTransform</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">SoundTransform</span> = _bgmChannel.<span style="color: #004993;">soundTransform</span>;
			<span style="color: #004993;">soundTransform</span>.<span style="color: #004993;">volume</span> = <span style="color: #004993;">volume</span>;
			_bgmChannel.<span style="color: #004993;">soundTransform</span> = <span style="color: #004993;">soundTransform</span>;
			<span style="color: #004993;">soundTransform</span> = <span style="color: #0033ff; font-weight: bold;">null</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Tween&quot;あり&quot;でのボリューム設定
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> setTweenVolume<span style="color: #000000;">&#40;</span>toVol<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, fromVol<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, tweenTime<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</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>
&nbsp;
			<span style="color: #3f5fbf;">/*** Tween初期化 ***/</span>
			removeTween<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #3f5fbf;">/*** Tween作成 ***/</span>
			iTween = BetweenAS3.tween<span style="color: #000000;">&#40;</span>_bgmChannel, <span style="color: #000000;">&#123;</span> <span style="color: #004993;">soundTransform</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#123;</span> <span style="color: #004993;">volume</span><span style="color: #000000; font-weight: bold;">:</span> toVol <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span>, <span style="color: #000000;">&#123;</span> <span style="color: #004993;">soundTransform</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#123;</span> <span style="color: #004993;">volume</span><span style="color: #000000; font-weight: bold;">:</span> fromVol <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span>, tweenTime,_easing <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #3f5fbf;">/*** 開始関数 ***/</span>
			iTween.onPlay = <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>
				_isTween = <span style="color: #0033ff; font-weight: bold;">true</span>;
				remainderTime = tweenTime;<span style="color: #009900;">//残り時間の初期化</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #3f5fbf;">/*** 終了関数 ***/</span>
			iTween.onComplete = <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>
				_isTween = <span style="color: #0033ff; font-weight: bold;">false</span>;
				iTween = <span style="color: #0033ff; font-weight: bold;">null</span>;
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_isStopTween<span style="color: #000000;">&#41;</span> stopFunc<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<span style="color: #009900;">//ストップのtweenだったらstopする。</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #3f5fbf;">/*** Tween開始 ***/</span>
			iTween.<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Tween最中だった場合、Tweenを止めて削除する関数
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> removeTween<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;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>_isTween<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span>;
			<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
				iTween.<span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				_isTween = <span style="color: #0033ff; font-weight: bold;">false</span>;
				iTween = <span style="color: #0033ff; font-weight: bold;">null</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>関連する投稿はありません。</li>
	</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/09/06/921/feed/</wfw:commentRss>
		<slash:comments>1</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>Bitmap と Particle (6)　花火</title>
		<link>http://blog.yaimo.net/2009/07/02/682/</link>
		<comments>http://blog.yaimo.net/2009/07/02/682/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 09:22:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Particle]]></category>
		<category><![CDATA[Wonderfl]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=682</guid>
		<description><![CDATA[実家から帰ってきて腕がうでがなまっていたのでHANABIの勉強をしてみました。夏ですしね。パーティクルおもしろいです！ wonderfulの注釈をみながらやってみてください。むちゃくちゃ楽しいです。 以下のエントリーがすばらすぃ。わかりやすい注釈ありがとうございます。 forked from: HANABI（初級者がコードに注釈をつけてみた） 初心者の僕にとってハチャメチャ勉強になりました。 ColorTrasnformによる色の減色はClockさんの以下のエントリーを先にみておくとわかりやすいです。 Flashで残像エフェクト (フレームアクションで簡単に) この方がsqrt()の意味がわからないと書いていたので自分なりに補足: Math.randam()は0(限りなく0に近い)~1の値をとりますが、 もし0.1だった場合、0.1=1/10 -> sqrt(1/10)となり、(sqrt(10)=3.16&#8230;..なので)1/3.16 = 0.316になる 同様に、1/sqrt(2) = 0.707 のように計算していくと、 0 ~ 0.1 ~ 0.25 ~ 0.5 ~ 1 0 ~ 0.316 ~ 0.5 ~ 0.707 ~ 1 となるので、0.3以下の値がでにくくなるんじゃないかと思われます。 こんな方法があったのか！！他の方のコードってとっても勉強になります。 今回一番面白かったのが、unlock(),とlock()でしたね。 リファレンスを見てた時、どーやって実際につかったりするのかな？なんて思ってましたが解決しました。 関連する投稿 Bitmap と Particle (5)　BitmapData.perlinNoise Bitmap と Particle (4)　BitmapData.draw Bitmap と Particle [...]]]></description>
			<content:encoded><![CDATA[<div>
実家から帰ってきて腕がうでがなまっていたので<a href="http://wonderfl.net/code/13dbc50eb48b0bfd6920540c228e8ba9ae75b601">HANABI</a>の勉強をしてみました。夏ですしね。パーティクルおもしろいです！<br />
wonderfulの注釈をみながらやってみてください。むちゃくちゃ楽しいです。<br />
<br />
<a  rel="shadowbox;width=680;height=480" href="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/07/Partcile0.swf"><img src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/07/2.png" alt="" /></a><br />
<br />
<br />
以下のエントリーがすばらすぃ。わかりやすい注釈ありがとうございます。<br />
<a href="http://wonderfl.net/code/03190641c00b157abc0dbe7d6a513fa80ec987db">forked from: HANABI（初級者がコードに注釈をつけてみた）</a><br />
<br />
初心者の僕にとってハチャメチャ勉強になりました。<br />
<br />
ColorTrasnformによる色の減色はClockさんの以下のエントリーを先にみておくとわかりやすいです。<br />
<a href="http://clockmaker.jp/blog/2009/04/zanzou-ken/">Flashで残像エフェクト (フレームアクションで簡単に)</a><br />
<br />
この方がsqrt()の意味がわからないと書いていたので自分なりに補足:<br />
Math.randam()は0(限りなく0に近い)~1の値をとりますが、<br />
もし0.1だった場合、0.1=1/10 -> sqrt(1/10)となり、(sqrt(10)=3.16&#8230;..なので)1/3.16 = 0.316になる<br />
同様に、1/sqrt(2) = 0.707 のように計算していくと、<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight:bold;">0</span>  <span style="color: #000000; font-weight: bold;">~</span>    <span style="color: #000000; font-weight:bold;">0.1</span>     <span style="color: #000000; font-weight: bold;">~</span>   <span style="color: #000000; font-weight:bold;">0.25</span>   <span style="color: #000000; font-weight: bold;">~</span>    <span style="color: #000000; font-weight:bold;">0.5</span>      <span style="color: #000000; font-weight: bold;">~</span> <span style="color: #000000; font-weight:bold;">1</span>
<span style="color: #000000; font-weight:bold;">0</span>  <span style="color: #000000; font-weight: bold;">~</span>    <span style="color: #000000; font-weight:bold;">0.316</span>  <span style="color: #000000; font-weight: bold;">~</span>  <span style="color: #000000; font-weight:bold;">0.5</span>     <span style="color: #000000; font-weight: bold;">~</span>    <span style="color: #000000; font-weight:bold;">0.707</span>   <span style="color: #000000; font-weight: bold;">~</span> <span style="color: #000000; font-weight:bold;">1</span></pre></div></div>

<br />
<br />
<br />
となるので、0.3以下の値がでにくくなるんじゃないかと思われます。<br />
こんな方法があったのか！！他の方のコードってとっても勉強になります。<br />
<br />
今回一番面白かったのが、unlock(),とlock()でしたね。<br />
リファレンスを見てた時、どーやって実際につかったりするのかな？なんて思ってましたが解決しました。<br />
<br />
</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/2009/06/23/651/" title="Bitmap と Particle (5)　BitmapData.perlinNoise (2009 年 6 月 23 日)">Bitmap と Particle (5)　BitmapData.perlinNoise</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/21/636/" title="Bitmap と Particle (4)　BitmapData.draw (2009 年 6 月 21 日)">Bitmap と Particle (4)　BitmapData.draw</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/20/614/" title="Bitmap と Particle (3)　Matrix (2009 年 6 月 20 日)">Bitmap と Particle (3)　Matrix</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/19/596/" title="Bitmap と Particle (2)　ColorTransform (2009 年 6 月 19 日)">Bitmap と Particle (2)　ColorTransform</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/18/588/" title="Bitmap と Particle (1)　ColorMatrixFilter (2009 年 6 月 18 日)">Bitmap と Particle (1)　ColorMatrixFilter</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/07/02/682/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bitmap と Particle (5)　BitmapData.perlinNoise</title>
		<link>http://blog.yaimo.net/2009/06/23/651/</link>
		<comments>http://blog.yaimo.net/2009/06/23/651/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 06:52:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Particle]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=651</guid>
		<description><![CDATA[BitmapData.perlinNoiseのperlinNoiseを知っておくと今後のパーティクルにとっても役に立つらしい。 まだわからないけどｗ [勉強]perlinNoiseを動かす（の解説を初級者がしてみる） ここがとてもいい解説。]]></description>
			<content:encoded><![CDATA[<div>
BitmapData.perlinNoiseのperlinNoiseを知っておくと今後のパーティクルにとっても役に立つらしい。<br />
まだわからないけどｗ<br />
<br />
<a href="http://wonderfl.net/code/cafcb78df40b35b0c0d571dc8fd8f1bda791e4b4"><br />
[勉強]perlinNoiseを動かす（の解説を初級者がしてみる）</a><br />
<br />
ここがとてもいい解説。<br />
<a width=320;height=240" href="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/Perlin.swf" rel="shadowbox[post-651];width=640;height=385;"><br />
<img src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/11.png" alt="" />
</a><br />
<br />
Pointはaddした方が遅い気がしなくもない。PerlinNoiseおもたいなぁｗ<br />
より軽くするために精進します。<br />
<span id="more-651"></span><br />
<br />

<div class="wp_syntax"><div 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;">Bitmap</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">BitmapData</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> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">BitmapDataChannel</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Point</span>;
	<span style="color: #3f5fbf;">/**
	 * ...
	 * @author yaimo
	 */</span>
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;320&quot;</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;240&quot;</span>, <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;0xFFFFFF&quot;</span>, <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;24&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main 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> <span style="color: #004993;">bitmapData</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> baseX<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> baseY<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> Octaves<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ramdomSeed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> stitch<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> fractal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> channel<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> grey<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> offsetPointArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<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;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ADDED_TO_STAGE</span>, <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span> = <span style="color: #0033ff; font-weight: bold;">null</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;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ADDED_TO_STAGE</span>, <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// entry point</span>
			<span style="color: #004993;">bitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">320</span>, <span style="color: #000000; font-weight:bold;">240</span>, <span style="color: #0033ff; font-weight: bold;">false</span>, 0xFFFFFFFF<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> bitmap<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">bitmapData</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			bmpDataInit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bitmap<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, enterFrameHandler<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> enterFrameHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</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> Octaves; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
			<span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">offset</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = <span style="color: #004993;">offset</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>offsetPointArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #004993;">bitmapData</span>.<span style="color: #004993;">perlinNoise</span><span style="color: #000000;">&#40;</span>baseX, baseY, Octaves, ramdomSeed, stitch, fractal, channel, grey,<span style="color: #004993;">offset</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> bmpDataInit<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>
			baseX = <span style="color: #000000; font-weight:bold;">200</span>;
			baseY = <span style="color: #000000; font-weight:bold;">200</span>;
			Octaves = <span style="color: #000000; font-weight:bold;">6</span>;
			ramdomSeed = <span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> 0xFFFF<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>ramdomSeed<span style="color: #000000;">&#41;</span>;
			stitch = <span style="color: #0033ff; font-weight: bold;">false</span>;
			fractal = <span style="color: #0033ff; font-weight: bold;">true</span>;
			channel = <span style="color: #004993;">BitmapDataChannel</span>.<span style="color: #004993;">RED</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #004993;">BitmapDataChannel</span>.<span style="color: #004993;">GREEN</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #004993;">BitmapDataChannel</span>.<span style="color: #004993;">BLUE</span>;
			grey = <span style="color: #0033ff; font-weight: bold;">false</span>;
			<span style="color: #004993;">offset</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span>Octaves<span style="color: #000000;">&#41;</span>;
			offsetPointArray = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span>Octaves<span style="color: #000000;">&#41;</span>;
&nbsp;
&nbsp;
			<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> Octaves; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
			<span style="color: #000000;">&#123;</span>
				offsetPointArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">10</span>, <span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">offset</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">200</span> , <span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #004993;">bitmapData</span>.<span style="color: #004993;">perlinNoise</span><span style="color: #000000;">&#40;</span>baseX, baseY, Octaves, ramdomSeed, stitch, fractal, channel, grey,<span style="color: #004993;">offset</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></div></div>

<br />
</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/2009/07/02/682/" title="Bitmap と Particle (6)　花火 (2009 年 7 月 2 日)">Bitmap と Particle (6)　花火</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/21/636/" title="Bitmap と Particle (4)　BitmapData.draw (2009 年 6 月 21 日)">Bitmap と Particle (4)　BitmapData.draw</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/20/614/" title="Bitmap と Particle (3)　Matrix (2009 年 6 月 20 日)">Bitmap と Particle (3)　Matrix</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/19/596/" title="Bitmap と Particle (2)　ColorTransform (2009 年 6 月 19 日)">Bitmap と Particle (2)　ColorTransform</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/18/588/" title="Bitmap と Particle (1)　ColorMatrixFilter (2009 年 6 月 18 日)">Bitmap と Particle (1)　ColorMatrixFilter</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/06/23/651/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bitmap と Particle (4)　BitmapData.draw</title>
		<link>http://blog.yaimo.net/2009/06/21/636/</link>
		<comments>http://blog.yaimo.net/2009/06/21/636/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 11:05:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[Particle]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=636</guid>
		<description><![CDATA[BitmapData.draw(source:IBitmapDrawable, matrix:Matrix = null, colorTransform:ColorTransform = null, blendMode:String = null, clipRect:Rectangle = null, smoothing:Boolean = false):void ブログ拝見してて、このエントリーみておれもコレやりたい！っておもってたんでBitmapDataの勉強にやってみました！ 最初はRectangleでもできる？の？って思ってRectangleでやってみたけど、スマートにできない感なのですっぱりやめて もとのmatrixを使っての方法で。 一枚の画像を分轄してそれをパーティクルのように移動させるには？ MatrixとRectangleの基準点はdraw(Displayobject)で読み込んだソースの基準点になるので注意が必要。 Matrixで変形後 -> colorTransformで色を変えて -> Rectangleで切り取るというイメージ 切り取りなどはちゃんと int 整数で切り取って扱う事、じゃないとサンプルのように線が見えてしまう。 【Rectangleの勘違い】 Rectangleでclipって書いてあるから、切り抜いて(0,0)の場所に書き込むのだと思っていたけど違うらしい。 BitmapData:青い短径領域 DisplayObject:画像 Rectangle:赤い四角 もしBitmapDataの領域とDisplayObjectが対応している場所(赤い部分)をRectangleで切り抜いた場合 その同じ場所に相応するBitmapDataが書き込まれる BitmapDataの領域とDisplayObjectが対応していない場所(紫の部分)をRectangleで切り抜いた場合 書き込まれない！? 無駄にソースコード増やしてゴメンナサイ。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [...]]]></description>
			<content:encoded><![CDATA[<div>
BitmapData.draw(source:IBitmapDrawable, matrix:Matrix = null, colorTransform:ColorTransform = null,<br />
 blendMode:String = null, clipRect:Rectangle = null, smoothing:Boolean = false):void<br />
<br />
ブログ拝見してて、このエントリーみておれもコレやりたい！っておもってたんでBitmapDataの勉強にやってみました！<br />
最初はRectangleでもできる？の？って思ってRectangleでやってみたけど、スマートにできない感なのですっぱりやめて<br />
もとのmatrixを使っての方法で。<br />
<br />
<a href="http://musiclifenolife.blog10.fc2.com/blog-entry-122.html">一枚の画像を分轄してそれをパーティクルのように移動させるには？</a><br />
<br />
<ol>
	<li>MatrixとRectangleの基準点はdraw(Displayobject)で読み込んだソースの基準点になるので注意が必要。</li>
<br />
	<li>Matrixで変形後 -> colorTransformで色を変えて -> Rectangleで切り取るというイメージ</li>
<br />
<li>切り取りなどはちゃんと int 整数で切り取って扱う事、じゃないとサンプルのように線が見えてしまう。</li>
</ol>
<a  rel="shadowbox;width=640;height=512" href="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/BitmapData.swf"><img src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/1.png" alt="" /></a><br />
<span id="more-636"></span><br />
【Rectangleの勘違い】<br />
<br />
<img src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/bitmapdata1.jpg" alt="" />
<br />
<br />
Rectangleでclipって書いてあるから、切り抜いて(0,0)の場所に書き込むのだと思っていたけど違うらしい。<br />
<br />
<ul>
	<li>BitmapData:青い短径領域</li>
<br />
	<li>DisplayObject:画像</li>
<br />
	<li>Rectangle:赤い四角</li>
</ul>
もしBitmapDataの領域とDisplayObjectが対応している場所(赤い部分)をRectangleで切り抜いた場合<br />
<ul>
その同じ場所に相応するBitmapDataが書き込まれる</ul>
BitmapDataの領域とDisplayObjectが対応していない場所(紫の部分)をRectangleで切り抜いた場合<br />
<ul>
書き込まれない！?</ul>
<br />
無駄にソースコード増やしてゴメンナサイ。<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
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
</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;">Bitmap</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">BitmapData</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">DisplayObject</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Loader</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> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">TimerEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">ColorTransform</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Matrix</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Point</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Rectangle</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">URLRequest</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">Timer</span>;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;640&quot;</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;512&quot;</span>, <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;0xFFFFFF&quot;</span>, <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;24&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main extends <span style="color: #004993;">Sprite</span> 
	<span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> static const SEGMENT_W<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">10</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static const SEGMENT_H<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">10</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> imageArray<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>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> limegelocArray<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>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> currentPosX<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>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> currentPosY<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>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> flag<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<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;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ADDED_TO_STAGE</span>, <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span> = <span style="color: #0033ff; font-weight: bold;">null</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;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ADDED_TO_STAGE</span>, <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// entry point</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">loader</span>.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;hoge.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">loader</span>.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, imgLoadCompHander<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> imgLoadCompHander<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</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;">Loader</span> = e.<span style="color: #004993;">target</span>.<span style="color: #004993;">loader</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Loader</span>;
			<span style="color: #004993;">target</span>.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, imgLoadCompHander<span style="color: #000000;">&#41;</span>;
			splitImage<span style="color: #000000;">&#40;</span><span style="color: #004993;">DisplayObject</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> splitImage<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">DisplayObject</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> displayObj<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">DisplayObject</span> = <span style="color: #004993;">target</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> splitWidth<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = displayObj.<span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">/</span> SEGMENT_W;
			<span style="color: #6699cc; font-weight: bold;">var</span> splitHeight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = displayObj.<span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">/</span> SEGMENT_H;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> mat<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Matrix</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ColorTransform</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ColorTransform</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> clip<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</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>, splitWidth, splitHeight<span style="color: #000000;">&#41;</span>;
&nbsp;
			<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> SEGMENT_W; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
			<span style="color: #000000;">&#123;</span>
				imageArray.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
				limegelocArray.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
				currentPosX.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
				currentPosY.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
				<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> j<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; j <span style="color: #000000; font-weight: bold;">&lt;</span> SEGMENT_H; j<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
				<span style="color: #000000;">&#123;</span>
					mat.<span style="color: #004993;">tx</span> = <span style="color: #000000; font-weight: bold;">-</span>i <span style="color: #000000; font-weight: bold;">*</span> splitWidth;
					mat.<span style="color: #004993;">ty</span> = <span style="color: #000000; font-weight: bold;">-</span>j <span style="color: #000000; font-weight: bold;">*</span> splitHeight;
&nbsp;
					limegelocArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span>mat.<span style="color: #004993;">tx</span>, <span style="color: #000000; font-weight: bold;">-</span>mat.<span style="color: #004993;">ty</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
					<span style="color: #6699cc; font-weight: bold;">var</span> bmpData<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>splitWidth,splitHeight,<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
&nbsp;
					bmpData.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>displayObj, mat, <span style="color: #004993;">color</span>, <span style="color: #0033ff; font-weight: bold;">null</span>, clip, <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
&nbsp;
					<span style="color: #6699cc; font-weight: bold;">var</span> bitmap<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span>bmpData<span style="color: #000000;">&#41;</span>;
					bitmap.<span style="color: #004993;">x</span> = clip.<span style="color: #004993;">x</span>;
					bitmap.<span style="color: #004993;">y</span> = clip.<span style="color: #004993;">y</span>;
&nbsp;
					imageArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>bitmap<span style="color: #000000;">&#41;</span>;
&nbsp;
&nbsp;
					currentPosX<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>;
					currentPosY<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>;
&nbsp;
					<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>imageArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, onFrameHandler<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Timer</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Timer</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2000</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">timer</span>.<span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">timer</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">TimerEvent</span>.<span style="color: #004993;">TIMER</span>, timerEventHandler<span style="color: #000000;">&#41;</span>;
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> timerEventHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">TimerEvent</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>
			flag = <span style="color: #000000; font-weight: bold;">!</span>flag;
			<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: #6699cc; font-weight: bold;">var</span> j<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">int</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>flag<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i= <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> SEGMENT_W; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
				<span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>j = <span style="color: #000000; font-weight:bold;">0</span>; j <span style="color: #000000; font-weight: bold;">&lt;</span> SEGMENT_H; j<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
					<span style="color: #000000;">&#123;</span>
						currentPosX<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> = limegelocArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">x</span>;
						currentPosY<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> = limegelocArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">y</span>;
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> SEGMENT_W; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
				<span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>j = <span style="color: #000000; font-weight:bold;">0</span>; j <span style="color: #000000; font-weight: bold;">&lt;</span> SEGMENT_H; j<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
					<span style="color: #000000;">&#123;</span>
						currentPosX<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>;
						currentPosY<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</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>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onFrameHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</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> SEGMENT_W; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</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> j<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; j <span style="color: #000000; font-weight: bold;">&lt;</span> SEGMENT_H; j<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
				<span style="color: #000000;">&#123;</span>
					imageArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>currentPosX<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> <span style="color: #000000; font-weight: bold;">-</span> imageArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.3</span>;
					imageArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>currentPosY<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> <span style="color: #000000; font-weight: bold;">-</span> imageArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>.<span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.3</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<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/2009/06/20/614/" title="Bitmap と Particle (3)　Matrix (2009 年 6 月 20 日)">Bitmap と Particle (3)　Matrix</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/02/682/" title="Bitmap と Particle (6)　花火 (2009 年 7 月 2 日)">Bitmap と Particle (6)　花火</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/23/651/" title="Bitmap と Particle (5)　BitmapData.perlinNoise (2009 年 6 月 23 日)">Bitmap と Particle (5)　BitmapData.perlinNoise</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/19/596/" title="Bitmap と Particle (2)　ColorTransform (2009 年 6 月 19 日)">Bitmap と Particle (2)　ColorTransform</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/18/588/" title="Bitmap と Particle (1)　ColorMatrixFilter (2009 年 6 月 18 日)">Bitmap と Particle (1)　ColorMatrixFilter</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/06/21/636/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bitmap と Particle (3)　Matrix</title>
		<link>http://blog.yaimo.net/2009/06/20/614/</link>
		<comments>http://blog.yaimo.net/2009/06/20/614/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 08:23:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[Particle]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=614</guid>
		<description><![CDATA[いまさらながらMatrixをやってみようかと。。一応何となくやってたのですが、 そろそろちゃんと覚えようかと。。BitmapData.draw()の引数にMatrixがあるので覚えておくべき！ これも全部BitmapとParticleのため！がんばるぞ Matrixについての基本的な考えとかは、以下のエントリーがGood 第11回　マトリクスを使ってムービー上のインスタンスを移動・回転・拡大/縮小する 第12回　移動や変形に，慣れれば便利なマトリクスの仕組み それで色々注意した方がいいことは、 Matirxの基準点はstageの左上になっている。 translateメソッド，rotateメソッド，scaleメソッドはMatrixオブジェクトの各プロパティーの値を更新（追加) matrix.translate&#40;100, 0&#41;; matrix.translate&#40;100, 0&#41;; を行った場合、matrix.tx += 100;が2回行われるということになる。 つまり、元のプロパティーに対しての追加（新規に割り当てるわけではない） scaleに至っては、1.5などと指定すると 元の値*1.5 ということに注意 rotate -> transform と transform -> rotateでは実行結果が違うよ。 createBox()を使用した場合は、 identity() -> rotate() -> scale() -> translate() の各メソッドで実行されるっぽい なので rotate -> transform の実行結果をイメージ concat()で合成する場合は、clone()などで一時変数とかを利用したのを使った方がいい。 変形用のmatrixを合成concat()したら、無駄に計算されちゃうしね。 1 2 3 4 5 6 7 8 9 10 11 12 [...]]]></description>
			<content:encoded><![CDATA[<div>
いまさらながらMatrixをやってみようかと。。一応何となくやってたのですが、<br />
そろそろちゃんと覚えようかと。。BitmapData.draw()の引数にMatrixがあるので覚えておくべき！<br />
これも全部BitmapとParticleのため！がんばるぞ<br />
<br />
Matrixについての基本的な考えとかは、以下のエントリーがGood<br />
<br />
<ul>
	<li><a href="http://itpro.nikkeibp.co.jp/article/COLUMN/20080207/293292/?ST=swd-tech">第11回　マトリクスを使ってムービー上のインスタンスを移動・回転・拡大/縮小する </a></li>
<br />
	<li><a href="http://itpro.nikkeibp.co.jp/article/COLUMN/20080227/294927/?ST=swd-tech">第12回　移動や変形に，慣れれば便利なマトリクスの仕組み </a></li>
</ul>
<br />
それで色々注意した方がいいことは、<br />
<span id="more-614"></span><br />
<ol>
	<li>Matirxの基準点はstageの左上になっている。</li>
<br />
	<li>translateメソッド，rotateメソッド，scaleメソッドはMatrixオブジェクトの各プロパティーの値を更新（追加)<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">matrix</span>.<span style="color: #004993;">translate</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span>, <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">matrix</span>.<span style="color: #004993;">translate</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span>, <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<br />
を行った場合、matrix.tx += 100;が2回行われるということになる。<br />
つまり、元のプロパティーに対しての追加（新規に割り当てるわけではない）<br />
scaleに至っては、1.5などと指定すると 元の値*1.5 ということに注意<br />
<br />
</li>
	<li>rotate -> transform と transform -> rotateでは実行結果が違うよ。<br />
createBox()を使用した場合は、<br />
<strong>identity() -> rotate() -> scale() -> translate()</strong> の各メソッドで実行されるっぽい<br />
なので rotate -> transform の実行結果をイメージ</li>
<br />
	<li>concat()で合成する場合は、clone()などで一時変数とかを利用したのを使った方がいい。<br />
変形用のmatrixを合成concat()したら、無駄に計算されちゃうしね。<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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> BaseMatrix<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Matrix</span> =  BaseMatrix.<span style="color: #004993;">transform</span>.<span style="color: #004993;">matrix</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> DataMatrix<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Matrix</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//Dataの更新（追加）</span>
DataMatrix.<span style="color: #004993;">transform</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//合成用のマトリックスを使用。</span>
<span style="color: #6699cc; font-weight: bold;">var</span> tmp<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Matrix</span> = DataMatrix.<span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
tmp.<span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span>baseMat<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">//元のオブジェクトに適用</span>
 BaseMatrix.<span style="color: #004993;">transform</span>.<span style="color: #004993;">matrix</span> = mat;</pre></td></tr></table></div>

<br />
8,9,12の行を<br />
<br />

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">DataMatrix.<span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span>baseMat<span style="color: #000000;">&#41;</span>;
BaseMatrix.<span style="color: #004993;">transform</span>.<span style="color: #004993;">matrix</span> = DataMatrix;</pre></div></div>

<br />
で書き換えても可能だけれども、<br />
DataMatrixにはbaseMatの合成値が入るので次回使用する場合に無駄な計算が入る。</li>
</ol>
ここら辺を押さえておけばmatrixのことは大体大丈夫！！そして補足として、<br />
<br />
Matrix.deltaTransformPoint()とMatrix.transformPoint()は覚えておくと今後応用できそうなので覚えよう。<br />
<br />
</p>
<blockquote><p>Matrix オブジェクトで表現される図形変換を、指定されたポイントに適用したことによって値を返します。</p></blockquote>
<p>
<ul>
	<li>Matrix.transformPoint()は指定したポイントに対してMatrixで変換したポイントで返してくれるというもの</li>
<br />
	<li>Matrix.deltaTransformPoint()は指定したポイントに対してMatrix(<strong>tx,ty考慮しない</strong>)で変換したポイントで返してくれるというもの</li>
</ul>
<br />

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">matrix</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Matrix</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> point<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Point</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">50</span>,<span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//x,y 10倍の拡大</span>
<span style="color: #004993;">matrix</span>.<span style="color: #004993;">scale</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//x,y 100の移動</span>
<span style="color: #004993;">matrix</span>.<span style="color: #004993;">translate</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span>,<span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//50*10  (+100考慮しない) = 500</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">matrix</span>.<span style="color: #004993;">deltaTransformPoint</span><span style="color: #000000;">&#40;</span>point<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<span style="color: #009900;">//500,500</span>
<span style="color: #009900;">//50*10 + 100 = 500</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">matrix</span>.TransformPoint<span style="color: #000000;">&#40;</span>point<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<span style="color: #009900;">//600,600</span></pre></td></tr></table></div>

<br />
<br />
</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/2009/06/21/636/" title="Bitmap と Particle (4)　BitmapData.draw (2009 年 6 月 21 日)">Bitmap と Particle (4)　BitmapData.draw</a></li>
	<li><a href="http://blog.yaimo.net/2009/07/02/682/" title="Bitmap と Particle (6)　花火 (2009 年 7 月 2 日)">Bitmap と Particle (6)　花火</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/23/651/" title="Bitmap と Particle (5)　BitmapData.perlinNoise (2009 年 6 月 23 日)">Bitmap と Particle (5)　BitmapData.perlinNoise</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/19/596/" title="Bitmap と Particle (2)　ColorTransform (2009 年 6 月 19 日)">Bitmap と Particle (2)　ColorTransform</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/18/588/" title="Bitmap と Particle (1)　ColorMatrixFilter (2009 年 6 月 18 日)">Bitmap と Particle (1)　ColorMatrixFilter</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/06/20/614/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bitmap と Particle (2)　ColorTransform</title>
		<link>http://blog.yaimo.net/2009/06/19/596/</link>
		<comments>http://blog.yaimo.net/2009/06/19/596/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 07:19:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Particle]]></category>

		<guid isPermaLink="false">http://blog.yaimo.net/?p=596</guid>
		<description><![CDATA[カラーの勉強第2段！！次はColorTransformについて勉強！ ColorTransformについて、ColorMatrixFilterはあくまでフィルター、ColorTransformはプロパティ プロパティ->詳細->拡張効果の所と同じ場所。 ColorTransformにはややこしい所があって。 DisplayObjectのColorTransformとBitmapDataのColorTransformのでは設定の仕方と具合が少し違うという点 DisplayObjectのColorTransform DisplayObject.transform.colorTransform=colorTransformで代入 ColorTransform(1, 1, 1, 1, 0, 0, 0, 0) でDisplayObjectの元の色に戻すことは可能 BitmapDataのColorTransform colorTransform(rect:Rectangle, colorTransform:ColorTransform):void colorTransform() メソッドによるビットマップイメージの特定領域のカラー値を調整 ColorTransform(1, 1, 1, 1, 0, 0, 0, 0) で色に戻すことは不可能 以下のデモは、DisplayObjectとBitmapDataに対して、 ColorTransform(0.5, 0.5, 0.5)を適用したもの(以下コードのコメントアウト適用した場合) ColorTransform(0.5, 0.5, 0.5)を適用した後に、new ColorTransform(1, 1, 1)を行い色を元に戻そうとしたもの(コードのコメントアウトを取った場合) 以下コードのコメントアウト適用した場合 以下コードのコメントアウトを取った場合 【ColorMatrixFilterとColorTransformはどっちが速い？】 ColorTransformの方がはやい！！ 1 2 3 4 5 6 7 8 9 10 11 [...]]]></description>
			<content:encoded><![CDATA[<div>
カラーの勉強第2段！！次はColorTransformについて勉強！<br />
ColorTransformについて、ColorMatrixFilterはあくまでフィルター、ColorTransformはプロパティ<br />
プロパティ->詳細->拡張効果の所と同じ場所。<br />
ColorTransformにはややこしい所があって。<br />
DisplayObjectのColorTransformとBitmapDataのColorTransformのでは設定の仕方と具合が少し違うという点<br />
<br />
<ol>
<strong>DisplayObjectのColorTransform</strong><br />
<br />
<li>DisplayObject.transform.colorTransform=colorTransformで代入</li>
<br />
<li>ColorTransform(1, 1, 1, 1, 0, 0, 0, 0) でDisplayObjectの元の色に戻すことは可能</li>
</ol>
<ol>
<strong>BitmapDataのColorTransform</strong><br />
<br />
	<li>colorTransform(rect:Rectangle, colorTransform:ColorTransform):void<br />
colorTransform() メソッドによるビットマップイメージの特定領域のカラー値を調整</li>
<br />
	<li>ColorTransform(1, 1, 1, 1, 0, 0, 0, 0) で色に戻すことは不可能</li>
</ol>
<br />
以下のデモは、DisplayObjectとBitmapDataに対して、<br />
ColorTransform(0.5, 0.5, 0.5)を適用したもの(以下コードのコメントアウト適用した場合)<br />
ColorTransform(0.5, 0.5, 0.5)を適用した後に、new ColorTransform(1, 1, 1)を行い色を元に戻そうとしたもの(コードのコメントアウトを取った場合)<br />
<a  rel="shadowbox;width=780;height=300" href="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/Color2-1.swf"><img src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/2.JPG" alt="" />以下コードのコメントアウト適用した場合</a><br />
<a  rel="shadowbox;width=780;height=300" href="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/Color2.swf"><img src="http://blog.yaimo.net/wordpress/wp-content/uploads/2009/06/1.JPG" alt="" />以下コードのコメントアウトを取った場合</a><br />
<br />
【ColorMatrixFilterとColorTransformはどっちが速い？】<br />
<a href="http://wonderfl.kayac.com/code/6357f8e47de2365b1f8d090dbe9991d3579a4c89"><br />
ColorTransformの方がはやい！！<br />
<br />
<span id="more-596"></span><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
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
</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> adobe.utils.ProductManager;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Bitmap</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">BitmapData</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Loader</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</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> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">ColorTransform</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Rectangle</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">URLLoader</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">URLRequest</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.filters</span>.<span style="color: #004993;">ColorMatrixFilter</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">URLLoaderDataFormat</span>;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;780&quot;</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;300&quot;</span>, <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;0xFFFFFF&quot;</span>, <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;24&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ColorTransForm1 extends <span style="color: #004993;">Sprite</span>
	<span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ColorTransForm1<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> 
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ADDED_TO_STAGE</span>, <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span> = <span style="color: #0033ff; font-weight: bold;">null</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;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ADDED_TO_STAGE</span>, <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> loder<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			loder.<span style="color: #004993;">dataFormat</span> = <span style="color: #004993;">URLLoaderDataFormat</span>.<span style="color: #004993;">BINARY</span>;
			loder.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;jupm2.JPG&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			loder.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, loadCompHandler <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> loadCompHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</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>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> byteArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">data</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> loder1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			loder1.<span style="color: #004993;">loadBytes</span><span style="color: #000000;">&#40;</span>byteArray<span style="color: #000000;">&#41;</span>;
			loder1.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, imgLoadCompHandler<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> loder2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			loder2.<span style="color: #004993;">loadBytes</span><span style="color: #000000;">&#40;</span>byteArray<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>loder2<span style="color: #000000;">&#41;</span>;
			loder2.<span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">250</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> colortras<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ColorTransform</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ColorTransform</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.5</span>, <span style="color: #000000; font-weight:bold;">0.5</span>, <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">//var colortras2:ColorTransform = new ColorTransform(1, 1, 1);</span>
			loder2.<span style="color: #004993;">transform</span>.<span style="color: #004993;">colorTransform</span> = colortras;
			<span style="color: #009900;">//loder2.transform.colorTransform = colortras2;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> loder3<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			loder3.<span style="color: #004993;">loadBytes</span><span style="color: #000000;">&#40;</span>byteArray<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>loder3<span style="color: #000000;">&#41;</span>;
			loder3.<span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">500</span>;
			colortras.<span style="color: #004993;">color</span> = 0xFF0000;
			loder3.<span style="color: #004993;">transform</span>.<span style="color: #004993;">colorTransform</span> = colortras;
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> imgLoadCompHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</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> loder<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">target</span>.<span style="color: #004993;">loader</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> bData<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>loder.<span style="color: #004993;">width</span>, loder.<span style="color: #004993;">height</span>, <span style="color: #0033ff; font-weight: bold;">true</span>, 0x0000FF<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> colortras<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ColorTransform</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ColorTransform</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.5</span>, <span style="color: #000000; font-weight:bold;">0.5</span>, <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">//var colortras2:ColorTransform = new ColorTransform(1, 1, 1);</span>
&nbsp;
			bData.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>loder<span style="color: #000000;">&#41;</span>;
			bData.<span style="color: #004993;">colorTransform</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</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>, loder.<span style="color: #004993;">width</span>, loder.<span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span>, colortras<span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">//bData.colorTransform(new Rectangle(0, 0, loder.width, loder.height), colortras2);</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> bmp<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span>bData<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bmp<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<br />
<br />
</div>

	<h4>関連する投稿</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.yaimo.net/2009/07/02/682/" title="Bitmap と Particle (6)　花火 (2009 年 7 月 2 日)">Bitmap と Particle (6)　花火</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/23/651/" title="Bitmap と Particle (5)　BitmapData.perlinNoise (2009 年 6 月 23 日)">Bitmap と Particle (5)　BitmapData.perlinNoise</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/21/636/" title="Bitmap と Particle (4)　BitmapData.draw (2009 年 6 月 21 日)">Bitmap と Particle (4)　BitmapData.draw</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/20/614/" title="Bitmap と Particle (3)　Matrix (2009 年 6 月 20 日)">Bitmap と Particle (3)　Matrix</a></li>
	<li><a href="http://blog.yaimo.net/2009/06/18/588/" title="Bitmap と Particle (1)　ColorMatrixFilter (2009 年 6 月 18 日)">Bitmap と Particle (1)　ColorMatrixFilter</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.yaimo.net/2009/06/19/596/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
