<?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>nariyu memo</title>
	<atom:link href="http://nariyu.playwell.jp/feed/" rel="self" type="application/rss+xml" />
	<link>http://nariyu.playwell.jp</link>
	<description>メモ</description>
	<lastBuildDate>Thu, 04 Mar 2010 16:01:38 +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>Twitter クライアント始めました。</title>
		<link>http://nariyu.playwell.jp/2009/10/twitter-client-saezuri/</link>
		<comments>http://nariyu.playwell.jp/2009/10/twitter-client-saezuri/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 11:25:22 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Saezuri]]></category>
		<category><![CDATA[Twitter client]]></category>

		<guid isPermaLink="false">http://nariyu.playwell.jp/?p=487</guid>
		<description><![CDATA[Saezuri（さえずり）といいます。
Flex と Adobe AIR でこつこつ作っています。
http://www.playwell.jp/trac/Saezuri
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.playwell.jp/trac/Saezuri"><img alt="" src="http://www.playwell.jp/trac/Saezuri/chrome/site/app_image.png" title="Saezuri" class="alignnone" width="400" height="400" /></a></p>
<p>Saezuri（さえずり）といいます。<br />
Flex と Adobe AIR でこつこつ作っています。</p>
<p><a href="http://www.playwell.jp/trac/Saezuri">http://www.playwell.jp/trac/Saezuri</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/10/twitter-client-saezuri/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flex と Twitter と Google Maps と</title>
		<link>http://nariyu.playwell.jp/2009/09/tweets-map/</link>
		<comments>http://nariyu.playwell.jp/2009/09/tweets-map/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 12:30:58 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=446</guid>
		<description><![CDATA[Flex, Twitter, Google Maps を組み合わせる練習。











大きく表示
ホントは Google Maps 上につぶやきをポップアップ表示したかったけど、つぶやきの座標はとれないみたい [...]]]></description>
			<content:encoded><![CDATA[<p>Flex, Twitter, Google Maps を組み合わせる練習。</p>
<p>
<object width="600" height="400">
<param name="movie" value="http://blog.playwell.jp/nariyu/samples/TweetsMapApp.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowFullScreen" value="true"></param>
<embed type="application/x-shockwave-flash" width="600" height="400" src="http://blog.playwell.jp/nariyu/samples/TweetsMapApp.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" allowFullScreen="true" ></embed>
</object>
</p>
<p><a href="http://blog.playwell.jp/nariyu/samples/TweetsMapApp.html?ll=35.680811393281914,139.7672886669922&#038;z=12&#038;r=10km">大きく表示</a></p>
<p><del>ホントは Google Maps 上につぶやきをポップアップ表示したかったけど、つぶやきの座標はとれないみたい（プライバシー保護的にあたりまえ）なので、右のエリアに表示します。</del> 緯度経度情報のあるつぶやきだけ地図上に載せました（2009/9/17 追記）</p>
<p>地図をドラッグすると周囲のつぶやきを表示します。</p>
<p><del>コメント中の「@ユーザ名」とか URL とかをリンクにする処理は省略。</del> つけました（2009/9/15 追記）</p>
<p>なんだか途中で飽きてしまってとっても中途半端で意味のないものになったけど、せっかくなので載せておく。</p>
<p><strong>[2009/9/15 追記]</strong><br />
検索範囲を示す円を描いてみた。<br />
そして地図のポイントをブックマークできるようにした。（<a href="http://blog.playwell.jp/nariyu/samples/TweetsMapApp.html?ll=35.61995885738201,139.7281927883911&#038;z=13&#038;r=5km">大崎半径5km以内のつぶやき</a>）</p>
<p><strong>[2009/9/16 追記]</strong><br />
経度／緯度情報のあるつぶやきだけ地図上にアイコンをマッピングしてみたよ。</p>
<p><strong>[2009/9/17 追記]</strong><br />
地図内につぶやきを表示するようにしたよ。<br />
検索もできるようにしたよ。（<a href="http://blog.playwell.jp/nariyu/samples/TweetsMapApp.html?ll=35.61908670776326,139.72969482543945&#038;z=9&#038;r=50km&#038;q=flash">大崎半径50km以内の「falsh」を含むつぶやき</a>）<br />
ジオコーディングを使って経度緯度情報がなくてもアイコンが出せるようになったよ。わお！</p>
<p><strong>[2009/9/18 追記]</strong><br />
地図のリンクを使いやすくしたよ。</p>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/09/tweets-map/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Flex Builder のワークスペースの履歴を削除する方法</title>
		<link>http://nariyu.playwell.jp/2009/09/how-to-delete-workspace-history-of-flex-builder/</link>
		<comments>http://nariyu.playwell.jp/2009/09/how-to-delete-workspace-history-of-flex-builder/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 01:00:17 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Flex Builder]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=431</guid>
		<description><![CDATA[Flex Builder （というか Eclipse）ではメニューの「ファイル」 &#8211; 「ワークスペースの切り替え&#8230;」で簡単にワークスペースを分けることができる。
これはプロジェクト毎やプロジェクト [...]]]></description>
			<content:encoded><![CDATA[<p>Flex Builder （というか Eclipse）ではメニューの「ファイル」 &#8211; 「ワークスペースの切り替え&#8230;」で簡単にワークスペースを分けることができる。</p>
<p>これはプロジェクト毎やプロジェクトのバージョン毎に環境を切り替える場合にすごく便利だ。</p>
<p>でも不要になったワークスペースのフォルダを削除しても、メニューの履歴にはずっと残ってしまって、選択すると新しくワークスペースが作られてしまう。</p>
<p>この履歴はどうやらメニューから簡単に消せないようで、面倒だけど設定ファイルを直接編集するしかないらしい。</p>
<p>デフォルトのワークスペースフォルダの「configuration/.settings/org.eclipse.ui.ide.prefs」をテキストエディタで開いて、「RECENT_WORKSPACES」を編集すればOK。</p>
<p>Mac の場合: ~/Documents/Flex Builder 3/configuration/.settings/org.eclipse.ui.ide.prefs<br />
Windows の場合: マイドキュメント/Flex Builder 3/configuration/.settings/org.eclipse.ui.ide.prefs</p>
<p>これできれいさっぱり履歴から削除される。</p>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/09/how-to-delete-workspace-history-of-flex-builder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex 4 でボタンにアイコンを表示する</title>
		<link>http://nariyu.playwell.jp/2009/09/how-to-use-a-button-with-icon-in-flex4-like-mac-mail/</link>
		<comments>http://nariyu.playwell.jp/2009/09/how-to-use-a-button-with-icon-in-flex4-like-mac-mail/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 03:50:31 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[Flex 4 (Gumbo)]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Button]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[Spark]]></category>
		<category><![CDATA[SparkSkin]]></category>
		<category><![CDATA[スキン]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=401</guid>
		<description><![CDATA[Flex 4 (Gumbo) フレームワークのスキンにも少し慣れてきたので、Mac の Mail のようなツールバーをスキンで作ってみる。
見た目はちょっと手抜きだけど、出来上がりはこんな感じ↓











割 [...]]]></description>
			<content:encoded><![CDATA[<p>Flex 4 (Gumbo) フレームワークのスキンにも少し慣れてきたので、Mac の Mail のようなツールバーをスキンで作ってみる。</p>
<p>見た目はちょっと手抜きだけど、出来上がりはこんな感じ↓<br />

<object width="600" height="150">
<param name="movie" value="http://blog.playwell.jp/nariyu/wp-content/uploads/2009/09/ToolBarSkin.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowFullScreen" value="true"></param>
<embed type="application/x-shockwave-flash" width="600" height="150" src="http://blog.playwell.jp/nariyu/wp-content/uploads/2009/09/ToolBarSkin.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" allowFullScreen="true" ></embed>
</object>
</p>
<p>割と似たものが簡単にできたかな。</p>
<p>ソースは以下。</p>
<p><span id="more-401"></span></p>
<p>まずは、spark.components.Button を継承して、ToolBarButton っていうクラスを作ります。<br />
このクラスではメタタグで「icon」スタイルを定義して、スキンクラスを指定しているだけ。</p>
<p>アイコンをスキンファイルに直接記述するなら新しくボタンのサブクラスを作る必要はないんだけど、スキンは汎用的じゃなきゃ意味がないので、今回は専用のクラスを作ります。</p>
<p>jp/playwell/controls/ToolBarButton.as</p>

<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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> jp.playwell.controls
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">import</span> jp.playwell.skins.ToolBarButtonSkin;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">import</span> spark.components.Button;
&nbsp;
    <span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;icon&quot;</span>, <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;Class&quot;</span>, inherit=<span style="color: #990000;">&quot;no&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> ToolBarButton extends Button
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ToolBarButton<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;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;skinClass&quot;</span>, ToolBarButtonSkin<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>で、次にこのクラスのスキンを作ります。<br />
おなじみの spark.skins.SparkSkin を継承した MXML ファイルです。</p>
<p>jp/playwell/skins/ToolBarButtonSkin.mxml</p>

<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
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SparkSkin</span></span>
<span style="color: #000000;">    xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">    xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">    minWidth=<span style="color: #ff0000;">&quot;21&quot;</span> minHeight=<span style="color: #ff0000;">&quot;21&quot;</span></span>
<span style="color: #000000;">    alpha.disabled=<span style="color: #ff0000;">&quot;0.5&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- states --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;up&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;over&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;down&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;disabled&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- host component --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>
        [HostComponent(&quot;jp.playwell.controls.ToolBarButton&quot;)]
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            static private const exclusions:Array = <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;labelElement&quot;</span><span style="color: #66cc66;">&#93;</span>;</span>
&nbsp;
<span style="color: #000000;">            override public function get colorizeExclusions<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Array <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                return exclusions;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- layer 1: fill --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> height=<span style="color: #ff0000;">&quot;23&quot;</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> width=<span style="color: #ff0000;">&quot;45&quot;</span></span>
<span style="color: #000000;">            radiusX=<span style="color: #ff0000;">&quot;11.5&quot;</span> radiusY=<span style="color: #ff0000;">&quot;11.5&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LinearGradient</span> rotation=<span style="color: #ff0000;">&quot;90&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0xE6E7E8&quot;</span></span>
<span style="color: #000000;">                        alpha=<span style="color: #ff0000;">&quot;1&quot;</span> alpha.over=<span style="color: #ff0000;">&quot;0.7&quot;</span> alpha.down=<span style="color: #ff0000;">&quot;0.4&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0xC7CBCE&quot;</span></span>
<span style="color: #000000;">                        alpha=<span style="color: #ff0000;">&quot;1&quot;</span> alpha.over=<span style="color: #ff0000;">&quot;0.7&quot;</span> alpha.down=<span style="color: #ff0000;">&quot;0.4&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0xD9DCE0&quot;</span></span>
<span style="color: #000000;">                        alpha=<span style="color: #ff0000;">&quot;1&quot;</span> alpha.over=<span style="color: #ff0000;">&quot;0.7&quot;</span> alpha.down=<span style="color: #ff0000;">&quot;0.4&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:LinearGradient</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- layer 2: border --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> top=<span style="color: #ff0000;">&quot;1&quot;</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;45&quot;</span> height=<span style="color: #ff0000;">&quot;23&quot;</span></span>
<span style="color: #000000;">            radiusX=<span style="color: #ff0000;">&quot;11.5&quot;</span> radiusY=<span style="color: #ff0000;">&quot;11.5&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColorStroke</span> color=<span style="color: #ff0000;">&quot;0xFFFFFF&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.4&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;45&quot;</span> height=<span style="color: #ff0000;">&quot;23&quot;</span></span>
<span style="color: #000000;">            radiusX=<span style="color: #ff0000;">&quot;11.5&quot;</span> radiusY=<span style="color: #ff0000;">&quot;11.5&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LinearGradientStroke</span> rotation=<span style="color: #ff0000;">&quot;90&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0x000000&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.4&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0x000000&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.1&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:LinearGradientStroke</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- layer 3: icon --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BitmapImage</span> source=<span style="color: #ff0000;">&quot;{hostComponent.getStyle('icon')}&quot;</span></span>
<span style="color: #000000;">        horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> top=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- layer 4: text --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SimpleText</span></span>
<span style="color: #000000;">        fontSize=<span style="color: #ff0000;">&quot;11.5&quot;</span></span>
<span style="color: #000000;">        textAlign=<span style="color: #ff0000;">&quot;center&quot;</span> color=<span style="color: #ff0000;">&quot;#FFFFFF&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.4&quot;</span></span>
<span style="color: #000000;">        horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> text=<span style="color: #ff0000;">&quot;{hostComponent.label}&quot;</span></span>
<span style="color: #000000;">        left=<span style="color: #ff0000;">&quot;10&quot;</span> right=<span style="color: #ff0000;">&quot;10&quot;</span> top=<span style="color: #ff0000;">&quot;29&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SimpleText</span> id=<span style="color: #ff0000;">&quot;labelElement&quot;</span></span>
<span style="color: #000000;">        fontSize=<span style="color: #ff0000;">&quot;11.5&quot;</span></span>
<span style="color: #000000;">        textAlign=<span style="color: #ff0000;">&quot;center&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">        left=<span style="color: #ff0000;">&quot;10&quot;</span> right=<span style="color: #ff0000;">&quot;10&quot;</span> top=<span style="color: #ff0000;">&quot;28&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:SparkSkin</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>ちょっと長いけど、アイコンに関係してるのは66行目だけ。ここでアイコンを適用しています。</p>
<p>これで完成！</p>
<p>後は、ToolBarButton を使うだけ。例えば MXML ならこんな感じで使えます↓</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;controls:ToolBarButton</span> label=<span style="color: #ff0000;">&quot;Get Mail&quot;</span> icon=<span style="color: #ff0000;">&quot;@Embed(source='assets/mail.png')&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;controls:ToolBarButton</span> label=<span style="color: #ff0000;">&quot;New Message&quot;</span> icon=<span style="color: #ff0000;">&quot;@Embed(source='assets/mail_new.png')&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;controls:ToolBarButton</span> label=<span style="color: #ff0000;">&quot;Delete&quot;</span> icon=<span style="color: #ff0000;">&quot;@Embed(source='assets/delete.png')&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;controls:ToolBarButton</span> label=<span style="color: #ff0000;">&quot;Junk&quot;</span> icon=<span style="color: #ff0000;">&quot;@Embed(source='assets/mail_junk.png')&quot;</span><span style="color: #7400FF;">/&gt;</span></span></pre></td></tr></table></div>

<p>それにしても Flex 4 のサンプルコードってまだまだ少ないな。<br />
ネットで探しても古いベータ版の Flex 4 SDK を元にしてたりしてなかなか参考になる情報がない。<br />
この記事も次のベータではまったく使えなくなるかもしれないけど。</p>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/09/how-to-use-a-button-with-icon-in-flex4-like-mac-mail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex 4 でコンテナにスクロールバーを表示する</title>
		<link>http://nariyu.playwell.jp/2009/09/how-to-add-a-scrollbar-to-containe/</link>
		<comments>http://nariyu.playwell.jp/2009/09/how-to-add-a-scrollbar-to-containe/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 10:15:35 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[Flex 4 (Gumbo)]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[Scroller]]></category>
		<category><![CDATA[Spark]]></category>
		<category><![CDATA[SparkSkin]]></category>
		<category><![CDATA[スキン]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=361</guid>
		<description><![CDATA[Flex 4 (Gumbo) フレームワークでは、コンテナ内にたくさんの子コンポーネントを配置しても自動的にスクロールバーを表示する処理を行いません。
コンテナにスクロールバーを表示させるためには次の二つの方法があります [...]]]></description>
			<content:encoded><![CDATA[<p>Flex 4 (Gumbo) フレームワークでは、コンテナ内にたくさんの子コンポーネントを配置しても自動的にスクロールバーを表示する処理を行いません。</p>
<p>コンテナにスクロールバーを表示させるためには次の二つの方法があります。</p>
<p><span id="more-361"></span></p>
<h3>方法1）スキンを利用する。</h3>
<p>スクロールバーを表示するためにはコンテナのスキンに spark.components.Scroller を追加します。</p>
<p>まずは MXML でスキンを作成します。</p>
<p>skins/ApplicationSkin.mxml</p>

<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
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SparkSkin</span></span>
<span style="color: #000000;">    xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">    xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">    alpha.disabled=<span style="color: #ff0000;">&quot;0.5&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>
        [HostComponent(&quot;spark.components.Application&quot;)]
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- ビューステート --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;normal&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;disabled&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- 背景とか --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> bottom=<span style="color: #ff0000;">&quot;0&quot;</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColor</span> color=<span style="color: #ff0000;">&quot;{hostComponent.backgroundColor as uint}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- コンテナを Scroller でラップ --&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Scroller</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> bottom=<span style="color: #ff0000;">&quot;0&quot;</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
        <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- 子コンポーネントを内包するためのコンテナ --&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> id=<span style="color: #ff0000;">&quot;contentGroup&quot;</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> bottom=<span style="color: #ff0000;">&quot;0&quot;</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Scroller</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:SparkSkin</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>これはデフォルトのスキン「spark.skins.ApplicationSkin」に &lt;s:Scroller&gt; を追加しているだけです。（25行目、29行目）</p>
<p>あとは、Application にスキンを適用するだけ。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span></span>
<span style="color: #000000;">    xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">    xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">    skinClass=<span style="color: #ff0000;">&quot;skins.ApplicationSkin&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        ・
        ・
        ・
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>これで子コンポーネントが多い場合にはスクロールバーが表示されます。</p>
<h3>方法2）スキンを使わずコンテナに Scroller を追加して、その中に子コンポーネントを配置する</h3>
<p>こちらは手っ取り早くスキンを使わないで、コンテナに Scroller を直接配置する方法です。</p>

<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
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span></span>
<span style="color: #000000;">    xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">    xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Scroller</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            ・
            ・
            ・
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Scroller</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>やっていることは方法1と同じですが、こうすると1段 DisplayObject の階層が深くなるのでスキンを利用する方がベターかなと思います。</p>
<p>Flex 3 まではスクロールバーが必要なくても内部的には実装されてたけど、Flex 4 は必要な場合には自分で追加するって感じ。</p>
<p>標準のコンポーネントから余分なコードがなくなってちょっとすっきりしたかな。</p>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/09/how-to-add-a-scrollbar-to-containe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex でビュー（デザイン）とロジックの分離</title>
		<link>http://nariyu.playwell.jp/2009/09/separation-of-view-and-logic/</link>
		<comments>http://nariyu.playwell.jp/2009/09/separation-of-view-and-logic/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 03:31:34 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[オフロスキー]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=311</guid>
		<description><![CDATA[呼んだ？呼んだよね？
さあ今日はね。 Flex アプリでレイアウトや配色などのデザイン（ビュー）とロジックを分離するやり方を考えてみようよ。
なに？大丈夫だよ。絶対できるって。
じゃあ始めるよ。
すごく簡単なウェブアプリ [...]]]></description>
			<content:encoded><![CDATA[<p>呼んだ？呼んだよね？<br />
さあ今日はね。 Flex アプリでレイアウトや配色などのデザイン（ビュー）とロジックを分離するやり方を考えてみようよ。</p>
<p>なに？大丈夫だよ。絶対できるって。<br />
じゃあ始めるよ。</p>
<p>すごく簡単なウェブアプリなら「 Flex ってこんなに簡単にできちゃうよー」ってサンプルを紹介するサイトなんかにあるように MXML だけでもできちゃうことがあるけど、ちょっと複雑になってくるとそうはいかないよね。</p>
<p>ってゆうか、そんな「MXML だけで作れちゃうウェブアプリ」のサンプルはエラーハンドリングを実装していない場合がほとんどだしね。<br />
だって Flex を布教するためにはエラーハンドリングみたいな地味で面白くもない技術を紹介してもしょうがないもん。<br />
仕方ないよね。うん。</p>
<p>・・・で、ちょっと複雑になると &lt;mx:Script&gt; タグを使って MXML に実装を書くこともあるけど、規模が大きくなってくると「やっぱりビューとロジックは分けるべきじゃない？」って言い出す人がいるよね。</p>
<p>面倒だけど仕方ないよ。</p>
<p>そんな訳でここらへんでビューとロジックの分離方法についておさらいしておこうね。</p>
<p>やり方はたくさんあると思うけど、今回はよく使われる二つの方法を復習するよ。<br />
いいかい。ちゃんとついてきてよ。</p>
<p><span id="more-311"></span></p>
<h3>方法1）IMXMLObject を使ったビューとロジックの分離</h3>
<p>IMXMLObject は Flex SDK に含まれる Adobe が推奨する方法（？）だね。</p>
<p>パッケージ名を含む完全なクラス名は <strong>mx.core.IMXMLObject</strong> だよ。<br />
mx.core！ なんか大切そうな感じだね。</p>
<p>でも中身はかなりシンプルなんだ。コメントを除くとこれだけだよ↓</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> mx.core
<span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> interface IMXMLObject
<span style="color: #000000;">&#123;</span>
    <span style="color: #339966; font-weight: bold;">function</span> initialized<span style="color: #000000;">&#40;</span>document<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, id<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</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;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>これの使い方は簡単。<br />
まずは views/MyCustomComponent.mxml っていうファイルを作って、こんな風に書く↓</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span></span>
<span style="color: #000000;">    xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">    width=<span style="color: #ff0000;">&quot;400&quot;</span> height=<span style="color: #ff0000;">&quot;300&quot;</span></span>
<span style="color: #000000;">    horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> id=<span style="color: #ff0000;">&quot;button&quot;</span> label=<span style="color: #ff0000;">&quot;ボタン&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>これはただの白い四角形の中にボタンが置いてあるだけの簡単なカスタムコンポーネントだよ。<br />
これがレイアウトや配色等のデザイン、つまり「<strong>ビュー</strong>」ってことになるんだ。</p>
<p>で、このボタンをクリックするとメッセージが表示されるようにロジックを実装してみるよ。</p>
<p>そのためにさっき出てきた IMXMLObject を実装したクラスを作る。ここではこれをヘルパーと呼ぶことにしよう。</p>
<p>ファイル名は views/helpers/MyCustomComponentHelper.as という ActionScrtipt ファイルだ。<br />
そこに次のように書く↓</p>

<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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> views.helpers
<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;">MouseEvent</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Alert;
    <span style="color: #0033ff; font-weight: bold;">import</span> mx.core.IMXMLObject;
    <span style="color: #0033ff; font-weight: bold;">import</span> mx.events.FlexEvent;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">import</span> views.MyCustomComponent;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyCustomComponentHelper implements IMXMLObject
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> view<span style="color: #000000; font-weight: bold;">:</span>MyCustomComponent;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MyCustomComponentHelper<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> initialized<span style="color: #000000;">&#40;</span>document<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, id<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</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>
            view = document <span style="color: #0033ff; font-weight: bold;">as</span> MyCustomComponent;
            view.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>FlexEvent.CREATION_COMPLETE,
                creationCompleteHandler<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> creationCompleteHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>FlexEvent<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>
            view.button.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>,
                button_clickHandler<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> button_clickHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
            Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;ボタンがクリックされたよ&quot;</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>急に長くなってきたけど、これだけではまだ動かないから最初に作った MXML ファイルにこのヘルパーを追記するよ。</p>
<p>こんな感じだ。</p>
<p>views/MyCustomComponent.mxml</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span></span>
<span style="color: #000000;">    xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">    xmlns:helpers=<span style="color: #ff0000;">&quot;views.helpers.*&quot;</span></span>
<span style="color: #000000;">    width=<span style="color: #ff0000;">&quot;400&quot;</span> height=<span style="color: #ff0000;">&quot;300&quot;</span></span>
<span style="color: #000000;">    horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;helpers:MyCustomComponentHelper</span> id=<span style="color: #ff0000;">&quot;helper&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> id=<span style="color: #ff0000;">&quot;button&quot;</span> label=<span style="color: #ff0000;">&quot;ボタン&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>4行目と7行目が追加されたヘルパーだ。</p>
<p>これでカスタムコンポーネントが完成した。ビューである MyCustomCompoent.mxml にはロジックは書かれていない。</p>
<p>ここまでのパッケージ構成はこんな感じになる↓</p>
<p><img src="http://blog.playwell.jp/nariyu/wp-content/uploads/2009/09/separate-of-view-and-logic-1.png" alt="separate-of-view-and-logic-1" title="separate-of-view-and-logic-1" width="326" height="108" class="alignnone size-full wp-image-325" /></p>
<p>あとは、アプリケーションにビューを追加すればOK。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span></span>
<span style="color: #000000;">    xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">    xmlns:views=<span style="color: #ff0000;">&quot;views.*&quot;</span></span>
<span style="color: #000000;">    layout=<span style="color: #ff0000;">&quot;absolute&quot;</span></span>
<span style="color: #000000;">    <span style="color: #7400FF;">&lt;views:MyCustomComponent</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>これで目的は達成できたね。</p>
<p>だけど、ちょっと待って。ヘルパーの中に「view.addEventListener(ほにゃらら」とか 「view.button.addEventListener(ほにゃらら」ってのが出てきてる。</p>
<p>規模が大きくなってくるとなんだかいちいち「view.」って書くのが面倒だよね。</p>
<p>それに別のクラスからヘルパーのメソッドを呼ぶときには「myCustomComponent.helper.メソッド()」って書かなきゃいけない。<br />
「myCustomComponent.helper.ほにゃらら」ってなにそれ長い！面倒！</p>
<p>そこで最近よく使っているのが次の方法なんだ。</p>
<h3>方法2）ロジックでビューを継承しちゃおうよ法（仮称）</h3>
<p>これはこの名前の通り、「ビューを規定クラスにして、ロジックをそのサブクラスとして実装する」っていう方法だ。</p>
<p>まずは規定クラスになる<strong>ビュー</strong>を <strong>MXML</strong> で作るよ。</p>
<p>views/mxml/MyCustomComponentView.mxml</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span></span>
<span style="color: #000000;">    xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">    width=<span style="color: #ff0000;">&quot;400&quot;</span> height=<span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> id=<span style="color: #ff0000;">&quot;button&quot;</span> label=<span style="color: #ff0000;">&quot;ボタン&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>これでビューは完成だよ。ヘルパーなんて面倒なものは書かなくていいよ。</p>
<p>次にロジックをビューのサブクラスとして ActionScript ファイルで作るんだ。</p>
<p>views/MyCustomComponent.as</p>

<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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> views
<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;">MouseEvent</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Alert;
    <span style="color: #0033ff; font-weight: bold;">import</span> mx.events.FlexEvent;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">import</span> views.mxml.MyCustomComponentView;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyCustomComponent extends MyCustomComponentView
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MyCustomComponent<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;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>FlexEvent.CREATION_COMPLETE,
                creationCompleteHandler<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> creationCompleteHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>FlexEvent<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>
            button.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>,
                button_clickHandler<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> button_clickHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
            Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;ボタンがクリックされたよ&quot;</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>これだけで完成だよ。簡単でしょ？簡単だよね？<br />
あとは MyCustomComponent をアプリケーションに追加すればいいよ。<br />
MXML ファイルのほうじゃなくて ActionScript ファイルのほうだよ。</p>
<p>このパッケージ構成はこんな感じになるよ↓</p>
<p><img src="http://blog.playwell.jp/nariyu/wp-content/uploads/2009/09/separate-of-view-and-logic-2.png" alt="separate-of-view-and-logic-2" title="separate-of-view-and-logic-2" width="332" height="108" class="alignnone size-full wp-image-334" /></p>
<p>これならロジックを実装したクラスに「view.ほにゃらら」とかつけなくてよくなりかなりすっきり！<br />
しかもビューのなかにヘルパーとか書かなくてもいい！行数も短くなってすっきりすっきり！</p>
<p>そしてこれの一番いいところは MXML の中に &lt;mx:Script&gt; タグでロジックを実装しちゃった昔の Flex アプリも簡単にビューとロジックを分離した構造に修正できるってことなんだ。<br />
つまり、規模が小さいうちは MXML の中にロジックを書いて、規模が大きくなってきたらビューとロジックを分離するっていうやりかたも比較的簡単にできちゃうってこと。</p>
<p>わお、ステキだね！</p>
<p>さあ君もやってみよう。</p>
<p>（オフロスキーって知ってますか？）</p>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/09/separation-of-view-and-logic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FastFingaの練習2</title>
		<link>http://nariyu.playwell.jp/2009/08/204830/</link>
		<comments>http://nariyu.playwell.jp/2009/08/204830/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 11:48:30 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[その他]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=308</guid>
		<description><![CDATA[iPhoneから送信
 
]]></description>
			<content:encoded><![CDATA[<div class="photo"><a href='http://blog.playwell.jp/nariyu/wp-content/uploads/2009/08/FastFingaAttachment_3.png' class="highslide" onclick="return hs.expand(this);" title='FastFingaAttachment_3'><img width="182" height="300" src="http://blog.playwell.jp/nariyu/wp-content/uploads/2009/08/FastFingaAttachment_3-182x300.png" class="attachment-medium" alt="FastFingaAttachment_3.png" title="FastFingaAttachment_3" /></a></div>
<p>iPhoneから送信</p>
<div class="photo-end"> </div>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/08/204830/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FastFinga でメール投稿できるようにしてみた</title>
		<link>http://nariyu.playwell.jp/2009/08/134417/</link>
		<comments>http://nariyu.playwell.jp/2009/08/134417/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 04:44:17 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[その他]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=298</guid>
		<description><![CDATA[iPhoneから送信
 
]]></description>
			<content:encoded><![CDATA[<div class="photo"><a href='http://blog.playwell.jp/nariyu/wp-content/uploads/2009/08/FastFingaAttachment_2.png' class="highslide" onclick="return hs.expand(this);" title='FastFingaAttachment_2'><img width="300" height="172" src="http://blog.playwell.jp/nariyu/wp-content/uploads/2009/08/FastFingaAttachment_2-300x172.png" class="attachment-medium" alt="FastFingaAttachment_2.png" title="FastFingaAttachment_2" /></a></div>
<p>iPhoneから送信</p>
<div class="photo-end"> </div>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/08/134417/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex でドラッグでリサイズできる Panel を作る</title>
		<link>http://nariyu.playwell.jp/2009/08/flex-resizable-panel/</link>
		<comments>http://nariyu.playwell.jp/2009/08/flex-resizable-panel/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 02:26:13 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Panel]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=259</guid>
		<description><![CDATA[Flex で mx.containers.Panel クラスを拡張してリサイズ可能なパネルを作ります。 Mac OS X のようにウィンドウの右下でのみリサイズできるように実装してみます。 完成形はこんな感じ。 ソースは以下。 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 [...]]]></description>
			<content:encoded><![CDATA[<p>Flex で mx.containers.Panel クラスを拡張してリサイズ可能なパネルを作ります。<br />
Mac OS X のようにウィンドウの右下でのみリサイズできるように実装してみます。</p>
<p>完成形はこんな感じ。</p>
<p>
<object width="600" height="400">
<param name="movie" value="http://blog.playwell.jp/nariyu/wp-content/uploads/2009/08/ResizablePanelTest.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowFullScreen" value="true"></param>
<embed type="application/x-shockwave-flash" width="600" height="400" src="http://blog.playwell.jp/nariyu/wp-content/uploads/2009/08/ResizablePanelTest.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" allowFullScreen="true" ></embed>
</object>
</p>
<p>ソースは以下。</p>
<p><span id="more-259"></span></p>

<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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> jp.playwell.containers
<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;">Graphics</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;">MouseEvent</span>;
    <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Rectangle</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">import</span> mx.containers.Panel;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ResizablePanel extends Panel
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> resizeHandle<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span>;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ResizablePanel<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;">super</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;">// resizable</span>
        <span style="color: #009900;">//--------------------------------------</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _resizable<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: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
        <span style="color: #000000;">&#91;</span>Inspectable<span style="color: #000000;">&#40;</span>category=<span style="color: #990000;">&quot;General&quot;</span>,
            enumeration=<span style="color: #990000;">&quot;true,false&quot;</span>, defaultValue=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #3f5fbf;">/**
         * resizable プロパティが true の場合、リサイズできます。
         * @default true
         */</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> resizable<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> _resizable;
        <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> resizable<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>
            _resizable = <span style="color: #004993;">value</span>;
            invalidateDisplayList<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;">// protected methods</span>
        <span style="color: #009900;">//--------------------------------------</span>
        override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> createChildren<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;">super</span>.createChildren<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</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>resizeHandle<span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                resizeHandle = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                resizeHandle.<span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0.6</span>;
&nbsp;
                <span style="color: #009900;">// ドラッグハンドルを描画</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> g<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Graphics</span> = resizeHandle.<span style="color: #004993;">graphics</span>;
                g.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xFFFFFF, <span style="color: #000000; font-weight:bold;">0.0</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">15</span>, <span style="color: #000000; font-weight:bold;">15</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>, 0x111111<span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3</span>, <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">14</span>, <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">7</span>, <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">14</span>, <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">11</span>, <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">14</span>, <span style="color: #000000; font-weight:bold;">11</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>, 0xFFFFFF<span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span>, <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">14</span>, <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">8</span>, <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">14</span>, <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">12</span>, <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000000;">&#41;</span>;
                g.<span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">14</span>, <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000000;">&#41;</span>;
&nbsp;
                rawChildren.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>resizeHandle<span style="color: #000000;">&#41;</span>;
&nbsp;
                resizeHandle.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_DOWN</span>,
                    resizeHandle_mouseDownHandler<span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> updateDisplayList<span style="color: #000000;">&#40;</span>unscaledWidth<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,
            unscaledHeight<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>
            <span style="color: #0033ff; font-weight: bold;">super</span>.updateDisplayList<span style="color: #000000;">&#40;</span>unscaledWidth, unscaledHeight<span style="color: #000000;">&#41;</span>;
&nbsp;
            resizeHandle.<span style="color: #004993;">visible</span> = resizable;
            resizeHandle.<span style="color: #004993;">x</span> = unscaledWidth <span style="color: #000000; font-weight: bold;">-</span> resizeHandle.<span style="color: #004993;">width</span>;
            resizeHandle.<span style="color: #004993;">y</span> = unscaledHeight <span style="color: #000000; font-weight: bold;">-</span> resizeHandle.<span style="color: #004993;">height</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #009900;">//--------------------------------------</span>
        <span style="color: #009900;">// ドラッグ処理</span>
        <span style="color: #009900;">//--------------------------------------</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dragData<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span>;
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> resizeHandle_mouseDownHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
            dragData = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseX</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseY</span>,
                unscaledWidth, unscaledHeight<span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_UP</span>, stage_mouseUpHandler<span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_MOVE</span>, stage_mouseMoveHandler<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stage_mouseUpHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
            dragData = <span style="color: #0033ff; font-weight: bold;">null</span>;
            <span style="color: #004993;">stage</span>.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_UP</span>, stage_mouseUpHandler<span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">stage</span>.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_MOVE</span>, stage_mouseMoveHandler<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stage_mouseMoveHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>resizable<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span>;
            <span style="color: #6699cc; font-weight: bold;">var</span> w<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = dragData.<span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseX</span> <span style="color: #000000; font-weight: bold;">-</span> dragData.<span style="color: #004993;">x</span>;
            <span style="color: #6699cc; font-weight: bold;">var</span> h<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = dragData.<span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseY</span> <span style="color: #000000; font-weight: bold;">-</span> dragData.<span style="color: #004993;">y</span>;
&nbsp;
            <span style="color: #004993;">width</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>maxWidth, <span style="color: #004993;">Math</span>.<span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>minWidth, resizeHandle.<span style="color: #004993;">width</span>, w<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">height</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>maxHeight, <span style="color: #004993;">Math</span>.<span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>minHeight, resizeHandle.<span style="color: #004993;">height</span>, h<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>いろいろ実装のやり方はあると思うけどかなりシンプルな方法でやってみました。</p>
<p><code>resizable</code> プロパティでリサイズのオン／オフができます。</p>
<p>解説するところが特にないほど簡単！</p>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/08/flex-resizable-panel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress の RSS を more で分割</title>
		<link>http://nariyu.playwell.jp/2009/06/wordpress-rss-split-by-more/</link>
		<comments>http://nariyu.playwell.jp/2009/06/wordpress-rss-split-by-more/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 03:18:40 +0000</pubDate>
		<dc:creator>nariyu</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[RSS]]></category>

		<guid isPermaLink="false">http://www.playwell.jp/blog/nariyu/?p=210</guid>
		<description><![CDATA[WordPress の RSS は全文表示にしていると、&#60;!-- more --&#62; があっても全文が表示されるようです。
なんか気持ち悪いので &#60;!-- more --&#62; の前までを出力するように [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress の RSS は全文表示にしていると、<code>&lt;!-- more --&gt;</code> があっても全文が表示されるようです。</p>
<p>なんか気持ち悪いので <code>&lt;!-- more --&gt;</code> の前までを出力するように修正してみる。</p>
<p>やり方は以下の通り。</p>
<p><span id="more-210"></span></p>
<p>wp-includes/feed-rss2.php の34行目あたり、</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>を以下のように修正します。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$more</span><span style="color: #339933;">;</span> <span style="color: #000088;">$more</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>それと、同じファイルの47行目あたり、</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;description&gt;&lt;![CDATA[<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt_rss<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]]&gt;&lt;/description&gt;</pre></div></div>

<p>を、以下のように修正します。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;description&gt;&lt;![CDATA[<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]]&gt;&lt;/description&gt;</pre></div></div>

<p>するとどうでしょう。<code>&lt;!-- more --&gt;</code> の後ろが「(続きを読む&#8230;)」 に見事に置き換えられたではありませんか。（正確には <code>__( '(more...)' )</code> 。）</p>
<p>これでまた一つ悩みが解決されました。</p>
<p>ただし、プラグイン等による修正ではないのでアップデートで消えてしまうかも。このエントリーはそのためのメモ。</p>
]]></content:encoded>
			<wfw:commentRss>http://nariyu.playwell.jp/2009/06/wordpress-rss-split-by-more/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
