<?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>unbland.org blog &#187; muta244@admin</title>
	<atom:link href="http://unbland.org/blog/author/admin/feed" rel="self" type="application/rss+xml" />
	<link>http://unbland.org/blog</link>
	<description>発見の日々の備忘録。主に Web にまつまる技術ネタ。</description>
	<lastBuildDate>Wed, 18 Nov 2009 03:31:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SWFProfiler を複数クライアント対応化とバグ修正</title>
		<link>http://unbland.org/blog/2009/08/20/333.html</link>
		<comments>http://unbland.org/blog/2009/08/20/333.html#comments</comments>
		<pubDate>Thu, 20 Aug 2009 12:21:32 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Flash (ActionScript)]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[SWFProfiler]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=333</guid>
		<description><![CDATA[SWFProfiler をアップデートしました。
リリースノート
・モニタリングする対象 SWF をリストから選択出来るように機能を追加しました。
・不要なデータが混ざるのを防ぐため、サーバー  クライアント間のデータの [...]]]></description>
			<content:encoded><![CDATA[<p>SWFProfiler をアップデートしました。</p>
<p><strong>リリースノート</strong></p>
<p>・モニタリングする対象 SWF をリストから選択出来るように機能を追加しました。<br />
・不要なデータが混ざるのを防ぐため、サーバー <-> クライアント間のデータのやり取りをリモーティングからメッセージングを使ったものに変更しました。<br />
・上記に伴い、サーバーを Jetty から自前サーバーに変更しました。<br />
・サンプリングがおかしかった所を修正しました。</p>
<p><strong>ダウンロード</strong></p>
<p><del datetime="2009-11-18T03:31:20+00:00"><a href="http://unbland.org/blog/wp-content/uploads/2009/08/SWFProfiler-0.0.3.zip" target="_blank">SWFProfiler.zip (Ver. 0.0.3)</a></del><br />
<a href="http://unbland.org/blog/wp-content/uploads/2009/08/SWFProfiler-0.0.4.zip" target="_blank">SWFProfiler.zip (Ver. 0.0.4)</a></p>
<p><strong>使い方</strong></p>
<p>・SWFProfiler.jar を実行します。<br />
・監視したい対象 SWF をブラウザ上でもローカル上でもいいので開きます。<br />
・リストから対象 SWF のファイル名を選択します。</p>
<p>以上の手順でプロファイリングが可能です。</p>
<p><strong>使用に関して</strong></p>
<p>・実行には JRE 1.6+ が必要です。<br />
・FlashPlayer はデバックバージョンを使用する必要があります。<br />
・SWF はデバッグリリースされている必要があります。</p>
<p><strong>ソースコード</strong></p>
<p><a href="http://bitbucket.org/muta244/swfprofiler/" target="_blank">http://bitbucket.org/muta244/swfprofiler/</a> で bitbucket にて管理しています。</p>
<p>今回のアップデートでだいぶ使えるものになったんじゃないかと思います。ただ、バグやおかしな点もまだまだあるかと思いますので、これからもマイペースに更新していきます。ご意見・ご要望はコメント欄、もしくは bitbucket にチケット登録をお願いします。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/08/20/333.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SWFProfiler の機能追加・バグ修正をしました</title>
		<link>http://unbland.org/blog/2009/08/16/322.html</link>
		<comments>http://unbland.org/blog/2009/08/16/322.html#comments</comments>
		<pubDate>Sat, 15 Aug 2009 16:41:06 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Flash (ActionScript)]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SWFProfiler]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[Tool]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=322</guid>
		<description><![CDATA[
先日リリースした SWFProfiler ですが、みなさん動いてなかったかと思います（ですよね？）。なので、修正版をリリースしました。ついでにモニター結果のフィルタリング機能と、定期的にガベージコレクションを自動で行う [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://unbland.org/blog/wp-content/uploads/2009/08/SWFProfiler_Capture02.jpg" alt="SWFProfiler_Capture02" title="SWFProfiler_Capture02" width="500" height="435" class="alignnone size-full wp-image-323" /></p>
<p>先日リリースした SWFProfiler ですが、みなさん動いてなかったかと思います（ですよね？）。なので、修正版をリリースしました。ついでにモニター結果のフィルタリング機能と、定期的にガベージコレクションを自動で行う機能を追加しています。</p>
<p><strong>ダウンロード</strong></p>
<p><del datetime="2009-11-18T03:29:12+00:00"><a href="http://unbland.org/blog/wp-content/uploads/2009/08/SWFProfiler-0.0.2.zip" target="_blank">SWFProfiler.zip (Ver. 0.0.2)</a><br />
<strong>＊ リンク先を間違えていたので修正しました。（&#8217;09.08.16）</strong></del><br />
<a href="http://unbland.org/blog/wp-content/uploads/2009/08/SWFProfiler-0.0.4.zip" target="_blank">SWFProfiler.zip (Ver. 0.0.4)</a><br />
<strong>＊ バグ修正版。（&#8217;09.11.18）</strong></p>
<p>あと、ブラウザ版にしろ、ローカル版にしろ、Flash Player はデバッグ版がインストールされている必要があります。それと、SWF 自体もデバッグモードで書き出されている必要がありますので、この点だけご注意下さい。</p>
<p>不明な点やバグ報告などありましたら、ぜひコメント欄へお願いします！</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/08/16/322.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SWFProfiler を試しに公開してみます</title>
		<link>http://unbland.org/blog/2009/08/13/314.html</link>
		<comments>http://unbland.org/blog/2009/08/13/314.html#comments</comments>
		<pubDate>Thu, 13 Aug 2009 13:52:14 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Flash (ActionScript)]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SWFProfiler]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[Tool]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=314</guid>
		<description><![CDATA[Flex Builder が無くてもデバッグ環境が必要だと思うので作りました。今の機能は Flex Builder プロファイラのライブオブジェクト相当のみです。Windows, Mac, Linux 全てで使用出来ます [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_313" class="wp-caption alignnone" style="width: 510px"><img src="http://unbland.org/blog/wp-content/uploads/2009/08/SWFProfilerCapture01.jpg" alt="SWFProfiler のキャプチャ画像" title="SWFProfilerCapture01" width="500" height="421" class="size-full wp-image-313" />
<p class="wp-caption-text">SWFProfiler のキャプチャ画像（nium さんの kujaku を勝手にプロファイリングw）</p>
</div>
<p>Flex Builder が無くてもデバッグ環境が必要だと思うので作りました。今の機能は Flex Builder プロファイラのライブオブジェクト相当のみです。Windows, Mac, Linux 全てで使用出来ますが、Swing で開発してるので <a href="http://java.com/ja/" target="_blank">JRE 1.6+</a> が必要です。</p>
<p><strong>ダウンロード</strong></p>
<p><del datetime="2009-08-16T05:13:41+00:00">SWFProfiler.zip (Ver. 0.0.1)</del></p>
<p>※ <strong>このバージョンは正しく動作しませんので、<a href="http://unbland.org/blog/2009/08/16/322.html">新しいバージョンをリリース</a>しました。そちらをお使い下さい。</strong></p>
<p><strong>使い方</strong></p>
<p>SWFProfiler.jar を起動した後、監視対象の SWF を開く（ブラウザ上でも可）と監視が始まります。現状では、複数の SWF を同時に開いているとおかしな事になるので、SWF は監視対象一つのみを開くようにして下さい。<a href="http://labs.anthill.jp/2009/03/flaprofiler_02.html" target="_blank">FlaProfiler</a> とほぼ同じです。</p>
<p><strong>今後の予定</strong></p>
<p>・複数の SWF 対応<br />
・モニター結果のフィルタリング機能<br />
・コンソール機能<br />
・メモリ使用状況のグラフ表示<br />
・国際化</p>
<p>あとは Mac で文字列なカラムでソートすると、何故かちらつくんですよね。Win だと大丈夫。Swing の問題だとは思うんだけど、対処法がないか模索中。</p>
<p>さて、どこまで出来るかな。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/08/13/314.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac では Swing で SingleFrameApplication#shutdown() が呼ばれない時がある</title>
		<link>http://unbland.org/blog/2009/08/11/309.html</link>
		<comments>http://unbland.org/blog/2009/08/11/309.html#comments</comments>
		<pubDate>Tue, 11 Aug 2009 13:47:47 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=309</guid>
		<description><![CDATA[Swing のメモ。
Swing を使ったアプリでは SingleFrameApplication#shutdown() をオーバーライドして終了処理を記述する。この時、Windows ではクローズボタンで終わろうが、A [...]]]></description>
			<content:encoded><![CDATA[<p>Swing のメモ。</p>
<p>Swing を使ったアプリでは SingleFrameApplication#shutdown() をオーバーライドして終了処理を記述する。この時、Windows ではクローズボタンで終わろうが、Alt+F4 で終わろうが、強制終了で終わろうが、ちゃんと shutdown() が最後に呼び出される。しかし、Mac だと正しく shutdown() が呼び出されない時がある。File -> Exit で終了した時など GUI 上で終了させた時は問題ないが、Cmd+Q や強制終了で JVM ごと終わらせた時には shutdown() が呼び出されず、終了処理が行えない。</p>
<p>そんな時の対処法が以下。</p>
<div style="position:relative;top:18px;margin-top:-18px;"><small><strong>Java</strong></small>
</div>
<pre name="code" class="java" style="margin:18px 0;">
@Override
protected void startup()
{
    Runtime.getRuntime().addShutdownHook(new Thread()
    {
        public void run()
        {
            if (!shutdowned) {
                shutdown();
            }
        }

        // 通常の起動処理
        ...
    });
}

@Override
protected void shutdown()
{
    if (shutdowned) {
        return;
    }

    super.shutdown();

    shutdowned = true;
}
</pre>
<p>このやり方が正しいのかは分からないけど、Runtime#addShutdownHook() なら Mac でも shutdown() を呼び出せるので終了処理がきちんと行える。Swing はシステム関係無くアプリ開発出来ることを謳ってるので、結構この問題はクリティカルだと思う。Sun さんの修正を期待。</p>
<p>こんなエントリー、ActionScript と関係無さそうだけど、Flash 開発のために必要なことをやっているのです&#8230;。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/08/11/309.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jar Bundler を使った .jar -&gt; .app 時のメモ</title>
		<link>http://unbland.org/blog/2009/07/31/304.html</link>
		<comments>http://unbland.org/blog/2009/07/31/304.html#comments</comments>
		<pubDate>Fri, 31 Jul 2009 09:48:09 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=304</guid>
		<description><![CDATA[個人的なメモ。
Jar Bundler で .jar を .app にパッケージングする際の注意点。

この画面で &#8220;Use Macintosh Menu Bar&#8221; にチェック入れてても、Swin [...]]]></description>
			<content:encoded><![CDATA[<p>個人的なメモ。</p>
<p>Jar Bundler で .jar を .app にパッケージングする際の注意点。</p>
<p><img class="alignnone size-full wp-image-303" title="Jar Bundler のキャプチャ 1" src="http://unbland.org/blog/wp-content/uploads/2009/07/2bfc96a45921677282a36721a07709ca.png" alt="Jar Bundler のキャプチャ 1" width="500" height="462" /></p>
<p>この画面で &#8220;Use Macintosh Menu Bar&#8221; にチェック入れてても、Swing を使ったアプリケーションだとウインドウ上部にメニューが表示されず、フレーム内部に表示されてしまう。対処法は以下。</p>
<p><img class="alignnone size-full wp-image-305" title="Jar Bundler のキャプチャ 2" src="http://unbland.org/blog/wp-content/uploads/2009/07/427feeba2c3a5b495c286f27ae1fdcc3.png" alt="Jar Bundler のキャプチャ 2" width="500" height="462" /></p>
<p>この画面の一番下でしているように、プロパティに &#8220;apple.laf.useScreenMenuBar&#8221; を true に設定して書き出せばスクリーン上部にメニューが表示されるようになる。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/07/31/304.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>前回の四分木 (Quad Tree) の続き</title>
		<link>http://unbland.org/blog/2009/07/22/292.html</link>
		<comments>http://unbland.org/blog/2009/07/22/292.html#comments</comments>
		<pubDate>Wed, 22 Jul 2009 12:18:16 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Flash (ActionScript)]]></category>
		<category><![CDATA[unbland as3 library]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=292</guid>
		<description><![CDATA[前回の四分木 (Quad Tree) の続き。
前回のデモは、衝突の可能性があるオブジェクト同士の関係を確認出来るものでしたが、今回は実際に接触しているかをチェックしています。こっちの方がイメージが湧き易いかな。
四分木 [...]]]></description>
			<content:encoded><![CDATA[<p>前回の<strong>四分木 (Quad Tree) </strong>の続き。</p>
<p>前回のデモは、衝突の可能性があるオブジェクト同士の関係を確認出来るものでしたが、今回は実際に接触しているかをチェックしています。こっちの方がイメージが湧き易いかな。</p>
<p><strong><a class="wpGallery mceItem" title="() の中のキーボードで色々と操作出来ます" rel="shadowbox[Mixed];width=640;height=360" href="http://unbland.org/blog/wp-content/uploads/2009/07/quadtree02.swf">四分木のデモ（※ 要 FlashPlayer 9）</a></strong></p>
<p>通常は灰色なオブジェクトが、他のオブジェクトに接触するとオレンジ色になります。</p>
<p>使い方はまたまた、今度・・・。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/07/22/292.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>四分木で 2D の衝突判定を最適化</title>
		<link>http://unbland.org/blog/2009/07/21/274.html</link>
		<comments>http://unbland.org/blog/2009/07/21/274.html#comments</comments>
		<pubDate>Tue, 21 Jul 2009 14:27:10 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Flash (ActionScript)]]></category>
		<category><![CDATA[unbland as3 library]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=274</guid>
		<description><![CDATA[今回は四分木 (Quad Tree) について。
オブジェクト同士の衝突判定を行う際、みなさんはどうしていますか？
一番最初に思い付く方法は衝突対象のオブジェクトを配列にでも入れて、総当たりで Sprite#hitTes [...]]]></description>
			<content:encoded><![CDATA[<p>今回は<strong>四分木 (Quad Tree) </strong>について。</p>
<p>オブジェクト同士の衝突判定を行う際、みなさんはどうしていますか？</p>
<p>一番最初に思い付く方法は衝突対象のオブジェクトを配列にでも入れて、総当たりで Sprite#hitTestObject() なんかで判定してしまおうという方法だと思います。この方法でも、対象のオブジェクト数が少なければ特に問題にはなりません。しかし対象のオブジェクト数が多かった場合、<strong>総当たりで計算を行うという方法では計算量が膨大</strong>になってしまい、とても現実的とは言えません。</p>
<p>Sprite#hitTestObject() などの衝突判定を行う前に、どうにか衝突の可能性があるオブジェクトを限定出来ないか？</p>
<p>そんな時には四分木を使えば計算量が減らせます。<br />
概念的には <strong><a href="http://yamasv.blog92.fc2.com/blog-entry-60.html">miscellaneous さんの「四分木」エントリー</a></strong>が参考になります。</p>
<p>四分木を構築する方法で一般的（？）なものは、空間全体をルートとし、2 x 2 の空間に分割しながらノードを構築するというもの。しかしながらこの方法、必ずしも計算量が減るわけではありません。なぜなら、<strong>衝突対象のオブジェクトを探すためにルートから該当部までノードをたどる必要があり、検索にもまた、計算コストが掛かってしまう</strong>からです。</p>
<p>じゃあ、どうすればいいのか？</p>
<p>その計算量を減らすため、四分木の構築方法は色々な方法が考え出されているようで、その中の一つに<strong>線形四分木</strong>というものがあります。概念的なものは、<strong><a href="http://marupeke296.com/COL_2D_No8_QuadTree.html">マルペケつくろードットコムさんの「その８ 4分木空間分割を最適化する！（理屈編）」</a></strong>がとても参考になります。このエントリーで書いてあることもほぼ受け売りです。</p>
<p>で、本題。今回自作ライブラリに線形四分木用のクラスを追加しました。これを使えば、<strong>四分木がどうこう考えなくても計算対象のオブジェクトを限定</strong>することが出来ます。その限定したオブジェクトに対して Sprite#hitTestObject() なんかを行えば、計算量も下がります。</p>
<p><strong><a class="wpGallery mceItem" title="() の中のキーボードで色々と操作出来ます" rel="shadowbox[Mixed];width=640;height=360" href="http://unbland.org/blog/wp-content/uploads/2009/07/quadtree01.swf">四分木のデモ（※ 要 FlashPlayer 9）</a></strong></p>
<p><strong>※ 描画部分は四分木とはまた別の部分なので最適化していません。あんまり円を増やしすぎると、総当たりに切り替えた時にかなり重くなりますので注意してください。</strong></p>
<p>デモはキーボードで各種操作を行え、四分木 <-> 総当たりの計算量比較が出来ます。オブジェクト同士を繋ぐ線は、衝突判定が必要なことを表しています。計算量がどれだけ減ったかを確認してみて下さい。</p>
<p>ソースは <strong><a href="http://bitbucket.org/muta244/unbland-as3-library/src/tip/examples/collision/src/classes/">Bitbucket に一式</a></strong>上げてますので、興味の有る方はどうぞ。<br />
使い方は後日、時間がある時にでも&#8230;。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/07/21/274.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UITextArea クラスを作成</title>
		<link>http://unbland.org/blog/2009/05/24/270.html</link>
		<comments>http://unbland.org/blog/2009/05/24/270.html#comments</comments>
		<pubDate>Sun, 24 May 2009 05:04:21 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Flash (ActionScript)]]></category>
		<category><![CDATA[unbland as3 library]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=270</guid>
		<description><![CDATA[前回の UITextField に引き続き、自作ライブラリに今度は UITextArea クラスを追加しました。
テキストエリアのデモ（※ 要 FlashPlayer 9）
前回の UITextField クラスのラッパ [...]]]></description>
			<content:encoded><![CDATA[<p>前回の UITextField に引き続き、自作ライブラリに今度は UITextArea クラスを追加しました。</p>
<p><a class="wpGallery mceItem" title="テキストエリア" rel="shadowbox[Mixed];width=460;height=260" href="http://unbland.org/blog/wp-content/uploads/2009/05/uitextarea.swf">テキストエリアのデモ（※ 要 FlashPlayer 9）</a></p>
<p>前回の UITextField クラスのラッパークラスで、スクロールが可能な UI を作成できます。</p>
<p>扱い方はサンプル [<a href="http://bitbucket.org/muta244/unbland-as3-library/src/ed0c709d5908/examples/ui/src/classes/UITextAreaDocument.as">ドキュメントコード</a> | <a href="http://bitbucket.org/muta244/unbland-as3-library/src/ed0c709d5908/examples/ui/src/classes/ui/TextArea.as">TextArea 実装コード</a> ] や <a href="http://unbland.org/library/as3/docs/org/unbland/ui/UITextArea.html">UITextArea の ASDoc</a> をご覧下さい。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/05/24/270.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自作ライブラリに UITextField クラスを追加</title>
		<link>http://unbland.org/blog/2009/05/19/263.html</link>
		<comments>http://unbland.org/blog/2009/05/19/263.html#comments</comments>
		<pubDate>Tue, 19 May 2009 14:08:52 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Flash (ActionScript)]]></category>
		<category><![CDATA[unbland as3 library]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=263</guid>
		<description><![CDATA[自作ライブラリに UITextField クラスを追加しました。
テキストフィールドのデモ（※ 要 FlashPlayer 9）
このクラスを使用して、コンポーネントでいうところの TextInput と Label が [...]]]></description>
			<content:encoded><![CDATA[<p>自作ライブラリに UITextField クラスを追加しました。</p>
<p><a class="wpGallery mceItem" title="テキストフィールド" rel="shadowbox[Mixed];width=460;height=260" href="http://unbland.org/blog/wp-content/uploads/2009/05/uitextfield.swf">テキストフィールドのデモ（※ 要 FlashPlayer 9）</a></p>
<p>このクラスを使用して、コンポーネントでいうところの TextInput と Label が作成出来ます。標準コンポーネントでは、ダブルクリックやトリプルクリックした際のテキスト選択がおかしいですが、このクラスを使用して作成した UI では、内部で拡張したテキストフィールドを用いる事により、ダブルクリックで単語、トリプルクリックで段落を選択するように拡張されています。その他にもクリックやタブなどで最初にフォーカスが移った際にテキストを全選択する機能や、IME を制御する機能なども備えています。</p>
<p>詳しい扱い方はサンプル [<a href="http://bitbucket.org/muta244/unbland-as3-library/src/tip/examples/ui/src/UITextFieldDocument.as">ドキュメントコード</a> | <a href="http://bitbucket.org/muta244/unbland-as3-library/src/tip/examples/ui/src/ui/TextInput.as">TextInput 実装コード</a> | <a href="http://bitbucket.org/muta244/unbland-as3-library/src/tip/examples/ui/src/ui/Label.as">Label 実装コード</a> ] や <a href="http://unbland.org/library/as3/docs/org/unbland/ui/UITextField.html">UITextField の ASDoc</a> をご覧下さい。また、使ってみて変な所があれば、<a href="http://bitbucket.org/muta244/unbland-as3-library/issues/new/">Issue</a> にぜひ登録してください。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/05/19/263.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript の最適化 Tips を wonderfl に投稿しました</title>
		<link>http://unbland.org/blog/2009/05/17/250.html</link>
		<comments>http://unbland.org/blog/2009/05/17/250.html#comments</comments>
		<pubDate>Sun, 17 May 2009 14:28:06 +0000</pubDate>
		<dc:creator>muta244@admin</dc:creator>
				<category><![CDATA[Flash (ActionScript)]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://unbland.org/blog/?p=250</guid>
		<description><![CDATA[ActionScript の最適化って色々なサイトに載っていますが、wonderfl にまとめて載っておくとコードと動きを同時に確認できるし、自分のためにも便利だと思って色々と投稿しました。コードへのリンクに個人的な私見 [...]]]></description>
			<content:encoded><![CDATA[<p>ActionScript の最適化って色々なサイトに載っていますが、wonderfl にまとめて載っておくとコードと動きを同時に確認できるし、自分のためにも便利だと思って色々と投稿しました。コードへのリンクに個人的な私見を加えてご紹介します。ただ、人によって意見が異なるかもしれないので、コードと動きを直接確認しておくことをお勧めします。この処理はおかしいんじゃないか？とかありましたらコメントください。</p>
<p><strong><a href="http://wonderfl.kayac.com/code/49f45692cecb031be5f851a5fb138c780896cf9b" target="_blank">変数名の長さによる処理速度の違い</a></strong></p>
<p>変数名の長さによる違いはありません。ですので変数名は、他の人が見やすい・自分が後で確認しても分かり易いような名前を付けておいた方が良いです。</p>
<p><strong><a href="http://wonderfl.kayac.com/code/1609eff6ec801f5674c69ef5178a8a72f5de6766" target="_blank">変数を参照する際の処理速度の違い</a></strong></p>
<p>上のコードでは _getPi <<< Math.PI <<< MyMath.PI = Main.PI < PI = _pi = ns::_pi = pi という結果で、ビルトインクラスのプロパティアクセスは若干重いので、ループ内で大量に参照する場合は変数に格納しておく方が良いです。また、getter アクセスの実態は関数ですので結構重いみたいです。MyMath.PI や Main.PI は、他の参照方法に比べると一階層下がるので若干重いですが、100 万回もループしての結果なので、あまり気にする必要はないんじゃないかと思います。ただ、注意事項が一つありますので「色々な整数化手段での処理速度の違い」も目を通しておいて下さい。</p>
<p><strong><a href="http://wonderfl.kayac.com/code/58b9fe83203fb49db603a1df15f39c6692219fdb" target="_blank">if &#8230; else と switch での処理速度の違い</a></strong></p>
<p>if &#8230; else 文は比較回数が少ない場合は軽いですが、比較回数が増えると switch 文の方が高速です。ただ、100 万回も処理させて数ミリ秒の違いですので、臨機応変に見やすい方を記述しておけば良いんじゃないかと思います。</p>
<p><strong><a href="http://wonderfl.kayac.com/code/2948ee85b515eec960753d311b1f9a6856d90474" target="_blank">色々な整数化手段での処理速度の違い</a></strong></p>
<p>Math.floor() が重いのは周知の事実。ただ、ローカル変数に格納したもので計算した場合は軽くなりそうなものの、逆に重くなるというのは以外だったと思います。これは先の「変数を参照する際の処理速度の違い」で Math.PI のようなプロパティを変数に格納しておく Tips と反して、ビルトインクラスのメソッドは逆に負担になりますので注意が必要です。そして本題の整数化では、n >> 0 などのビット演算で整数化する方が多いのですが、int(n) の方が高速だし見やすいのでお勧めです。</p>
<p><strong><a href="http://wonderfl.kayac.com/code/38488a88c1ecdfb66503b05c486106284bd1d39b" target="_blank">Array, Vector 走査時のイテレーション方法による処理速度の違い</a></strong></p>
<p>forEach は関数を実行するコストが掛かるのでやはり重いです。ただ、for each よりも for の方が高速なのは自分的にもビックリでした。倍速近い差が出るので、大量な処理の中で走査処理が必要な場合は for の方が良いかもしれません。もちろん、Array より Vector の方が高速です。</p>
<p><strong><a href="http://wonderfl.kayac.com/code/167a46753bdeff961d8a7c714df0b47c2aedda98" target="_blank">Array, Vector 走査時に加算を行う際の処理速度の違い</a></strong></p>
<p>これももちろん、Array より Vector の方が高速という結果に。ただ、Vector の長さを固定している方が高速になるかと思いきや、固定していなくても参照速度に差はないようです。</p>
<p><strong><a href="http://wonderfl.kayac.com/code/758263b96e8f2724f709020d1e561d43aad7d64a" target="_blank">オブジェクト生成による処理速度の違い</a></strong></p>
<p>new Object() より {}、new Array() より [] が高速というのは周知だと思います。あと、Vector の長さを指定すると最初に要素の初期化処理が入るようで、生成コストが高くなります。あとは Sprite の生成コストは当たり前のように高いです。独自クラスの生成は、処理が少なければ Object を生成するのとあまり変わりません。</p>
<p><strong><a href="http://wonderfl.kayac.com/code/6081e568795e00272a7da8c716e54341b478c009" target="_blank">サイン・コサインの取得方法による処理速度の違い</a></strong></p>
<p>予めサインテーブルを生成した後、ラジアンをテーブルのインデックスに変換して近似値を参照するというもの。かなりの高速化が期待できますが、取得できる値は近似値だという点に注意が必要です。3D での頂点処理などで大量のループ処理を行う際などに効果が期待できるかと思います。</p>
<p>今のところ試したコードはこんな感じです。これからも、他の最適化を思い付いたら wonderfl に投稿した後、ブログにエントリーしていきます。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/05/17/250.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.520 seconds -->
