<?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; unbland as3 library</title>
	<atom:link href="http://unbland.org/blog/category/flash-actionscript/unbland-as3-library/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>前回の四分木 (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>自作ライブラリのスクロールペインをバージョンアップ</title>
		<link>http://unbland.org/blog/2009/04/15/237.html</link>
		<comments>http://unbland.org/blog/2009/04/15/237.html#comments</comments>
		<pubDate>Wed, 15 Apr 2009 14:56:54 +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=237</guid>
		<description><![CDATA[以前紹介したスクロールペインをホイール標準対応にしました。内部で JSModifier というクラスを使用することにより Mac のホイールにも標準対応しています。
今回のスクロールペインのデモ（※ 要 FlashPla [...]]]></description>
			<content:encoded><![CDATA[<p>以前紹介したスクロールペインをホイール標準対応にしました。内部で JSModifier というクラスを使用することにより Mac のホイールにも標準対応しています。</p>
<p><a class="wpGallery mceItem" title="今回のスクロールペイン" rel="shadowbox[Mixed];width=460;height=260" href="http://unbland.org/blog/wp-content/uploads/2009/04/uiscrollpaneexample02.swf">今回のスクロールペインのデモ（※ 要 FlashPlayer 9）</a></p>
<p>Firefox や Opera だと前回のものは、バーやコーナーをドラッグしたまま swf の領域外に持っていった状態でマウスボタンをリリースすると、領域内に戻っても引っ付いたままになってしまっていましたが、これも JSModifier クラスによって改善されています。前回のものも掲載しておきますので、両方を試してみて下さい。</p>
<p><a class="wpGallery mceItem" title="前回のスクロールペイン" rel="shadowbox[Mixed];width=460;height=260" href="http://unbland.org/blog/wp-content/uploads/2009/04/uiscrollpaneexample.swf">前回のスクロールペインのデモ（※ 要 FlashPlayer 9）</a></p>
<p>ちなみに JSModifier というクラスは何かというと、Mac のホイールを認識しない問題や、wmode を使用した際の不具合、その他ブラウザに起因する問題を JavaScript を用いて改善するクラスで、使い方は JSModifier.initialize(stage) するだけです。</p>
<p><a href="http://unbland.org/library/as3/docs/">ASDoc</a> をアップロードしてますので、どういった問題が改善されるかなどの詳しい情報は <a href="http://unbland.org/library/as3/docs/org/unbland/core/external/JSModifier.html">JSModifier の項</a>を参照して下さい。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/04/15/237.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ActionScript 上で DOM 操作を行う</title>
		<link>http://unbland.org/blog/2009/04/06/230.html</link>
		<comments>http://unbland.org/blog/2009/04/06/230.html#comments</comments>
		<pubDate>Sun, 05 Apr 2009 15:22: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=230</guid>
		<description><![CDATA[unbland as3 library の機能で ActionScript 上で JavaScript の DOM 操作やイベントハンドリングを行う機能があります。そんな機能の紹介です。
]]></description>
			<content:encoded><![CDATA[<p><a href="http://bitbucket.org/muta244/unbland-as3-library/wiki/Home" target="_blank">unbland as3 library</a> の機能で ActionScript 上で JavaScript の DOM 操作やイベントハンドリングを行う機能があります。そんな機能の紹介です。</p>
<div style="position:relative;top:18px;margin-top:-18px;"><small><strong>ActionScript</strong></small>
</div>
<pre name="code" class="actionscript" style="margin:18px 0;">
package {

import flash.display.Sprite;
import org.unbland.core.events.JSEvent;
import org.unbland.core.external.JavaScript;
import org.unbland.core.external.JSObject;

public class Example extends Sprite
{
    public function Example():void
    {
        // JS が利用できない環境なら終了
        if (!JavaScript.enabled) {
            return;
        }

        // JavaScript.proxy で JS 操作用のオブジェクトを取得
        var document:JSObject = JavaScript.proxy.document;
        var body:JSObject = document.body;

        // 最初は赤色に
        body.style.backgroundColor = &quot;#FF0000&quot;;

        // ドキュメント領域をクリックしたらイベントを発生させる
        document.addEventListener(JSEvent.CLICK, function (e:JSEvent):void
        {
            // イベントが発生したら黄色に
            body.style.backgroundColor = &quot;#FFFF00&quot;;

            // イベントの詳細情報をアラート
            var temp:String = &quot;&quot;;
            for (var key:String in e.info) {
                temp += &quot;key : &quot; + key + &quot; / value : &quot; + e.info[key] + &quot;\n&quot;;
            }
            JavaScript.alert(temp);
        });
    }

}

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/04/06/230.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自作ライブラリを公開しました</title>
		<link>http://unbland.org/blog/2009/04/01/221.html</link>
		<comments>http://unbland.org/blog/2009/04/01/221.html#comments</comments>
		<pubDate>Wed, 01 Apr 2009 14:34:49 +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=221</guid>
		<description><![CDATA[
※ 09.04.16 追記:
バージョンアップしました。くわしくは &#8220;自作ライブラリのスクロールペインをバージョンアップ&#8221; をご覧下さい。
Bitbucket に自作ライブラリを一挙に公開しまし [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://unbland.org/blog/wp-content/uploads/2009/04/uiscrollpaneexample.jpg" alt="アイキャッチ画像" width="460" height="260" /></p>
<p><strong>※ 09.04.16 追記:</strong><br />
バージョンアップしました。くわしくは &#8220;<a href="http://unbland.org/blog/2009/04/15/237.html">自作ライブラリのスクロールペインをバージョンアップ</a>&#8221; をご覧下さい。</p>
<p>Bitbucket に自作ライブラリを一挙に公開しました。<a href="http://bitbucket.org/muta244/unbland-as3-library/wiki/Home" target="_blank">unbland as3 library</a> といいます。現在開発中ではありますが、公開記念に UI 作成用のクラスを紹介したいと思います。</p>
<p><a class="wpGallery mceItem" title="gallery" rel="shadowbox[Mixed];width=460;height=260" href="http://unbland.org/blog/wp-content/uploads/2009/04/uiscrollpaneexample.swf">スクロールペインのデモ（※ 要 FlashPlayer 9）</a></p>
<p>「コンポーネントを使えば？」なんて声が聞こえてきそうですが、標準のコンポーネントはスクロールのイージングに対応していなかったり、スキンのカスタマイズがものすごく面倒くさかったり、拡張性が低かったり、バグが多かったりと問題が多い（扱ったことがある方なら分かって頂けるかと思います）ので自分で実装してみました。</p>
<p>出来るだけ拡張性を持たせ、且つ見た目のカスタマイズなどが簡単に行えるように作成しているつもりです。具体的には、Flash IDE 上でデザインしたオブジェクトにインスタンス名を付け、抽象クラスを継承させたクラスで各種設定を記述するだけで簡単に作成出来ます。</p>
<p>その他にも色々な機能を実装していますので、興味の有る方は <a href="http://bitbucket.org/muta244/unbland-as3-library/wiki/Home" target="_blank">unbland as3 library Wiki</a> をご覧になって遊んでみて下さい。サンプルなんかも置いています。今後は TextInput, TextArea, ComboBox など、最近の Flash 案件で良く使うようになってきた UI については実装していきたいなーと思っています。</p>
]]></content:encoded>
			<wfw:commentRss>http://unbland.org/blog/2009/04/01/221.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

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