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

<channel>
	<title>小薛部落格</title>
	<atom:link href="http://blog.shiue.net/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.shiue.net</link>
	<description>千江有水千江月 萬里無雲萬里天</description>
	<pubDate>Sat, 16 Jan 2010 17:58:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Embeded font</title>
		<link>http://blog.shiue.net/archives/1004</link>
		<comments>http://blog.shiue.net/archives/1004#comments</comments>
		<pubDate>Sat, 19 Dec 2009 08:24:27 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[一缽千家飯 孤身萬里遊]]></category>

		<category><![CDATA[embeded font]]></category>

		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=1004</guid>
		<description><![CDATA[常用的Embeded font 寫法，從Adobe手冊抄來的:
重點是: 用同一個Font Family Name 但是Embed不同的Font Face, 這樣可處理大部分的字型問題，不然，常常會有字形粗體時跑回Arial, Tahoma 的情況。
@font-face {
&#160; &#160; &#160; &#160; src:url(&#34;../assets/MyriadWebPro.ttf&#34;);
&#160; &#160; &#160; &#160; fontFamily: myFont;
&#160; &#160; &#160; &#160; advancedAntiAliasing: true;
&#160; &#160; &#160;}

&#160; &#160; &#160;@font-face {
&#160; &#160; &#160; &#160; /* Note the different filename for boldface. */
&#160; &#160; &#160; &#160; src:url(&#34;../assets/MyriadWebPro-Bold.ttf&#34;);
&#160; &#160; &#160; &#160; fontFamily: myFont; /* Notice that this [...]]]></description>
			<content:encoded><![CDATA[<p>常用的Embeded font 寫法，從Adobe手冊抄來的:<br />
重點是: 用同一個Font Family Name 但是Embed不同的Font Face, 這樣可處理大部分的字型問題，不然，常常會有字形粗體時跑回Arial, Tahoma 的情況。</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px;height:300px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">@font-face {<br />
&nbsp; &nbsp; &nbsp; &nbsp; src:url(&quot;../assets/MyriadWebPro.ttf&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fontFamily: myFont;<br />
&nbsp; &nbsp; &nbsp; &nbsp; advancedAntiAliasing: true;<br />
&nbsp; &nbsp; &nbsp;}<br />
<br />
&nbsp; &nbsp; &nbsp;@font-face {<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* Note the different filename for boldface. */<br />
&nbsp; &nbsp; &nbsp; &nbsp; src:url(&quot;../assets/MyriadWebPro-Bold.ttf&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fontFamily: myFont; /* Notice that this is the same alias. */<br />
&nbsp; &nbsp; &nbsp; &nbsp; fontWeight: bold;<br />
&nbsp; &nbsp; &nbsp; &nbsp; advancedAntiAliasing: true;<br />
&nbsp; &nbsp; &nbsp;}<br />
<br />
&nbsp; &nbsp; &nbsp;@font-face {<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* Note the different filename for italic face. */<br />
&nbsp; &nbsp; &nbsp; &nbsp; src:url(&quot;../assets/MyriadWebPro-Italic.ttf&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fontFamily: myFont; /* Notice that this is the same alias. */<br />
&nbsp; &nbsp; &nbsp; &nbsp; fontStyle: italic;<br />
&nbsp; &nbsp; &nbsp; &nbsp; advancedAntiAliasing: true;<br />
&nbsp; &nbsp; &nbsp;}</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/1004/feed</wfw:commentRss>
		</item>
		<item>
		<title>好用的Flash Builder 快速鍵( hotkey )</title>
		<link>http://blog.shiue.net/archives/1001</link>
		<comments>http://blog.shiue.net/archives/1001#comments</comments>
		<pubDate>Fri, 13 Nov 2009 05:45:33 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[flash builder]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=1001</guid>
		<description><![CDATA[這也是從Adobe TV的MAX2009 session 聽來的，完整版請到adobe.tv看。

Ctrl+3 : 顯示快速command列表, 可以type-and-search執行所有的eclipse command
Ctrl + I : 自動縮排的妙用: 由別的文字檔貼過來的文字，全選後按下此快速鍵會自動排列。文字游標(I-Beam)移到任何地方按下此快速鍵，自動移到應該要去的地方，省得你按一堆tab和space
Ctrl+Shift+T:是open type， 這個大家都知道，但是奧妙在type-search的地方，可以打camel case string 作為搜尋；甚至可以用wildcard search. 舉例來說，想打開AdvancedDataGrid, 不用打Adv&#8230;去找，可打ADG就好( AdvancedDataGrid )。用wildcard search: 打 *skin 會列出所有 XXXskin相關的classes
Code assist : Alt+. (預設) 可以重複按，會自動filter分類，本來是顯示所有的屬性，每一次會顯示各類別: property, style, event

]]></description>
			<content:encoded><![CDATA[<p>這也是從Adobe TV的MAX2009 session 聽來的，完整版請到adobe.tv看。</p>
<ul>
<li>Ctrl+3 : 顯示快速command列表, 可以type-and-search執行所有的eclipse command</li>
<li>Ctrl + I : 自動縮排的妙用: 由別的文字檔貼過來的文字，全選後按下此快速鍵會自動排列。文字游標(I-Beam)移到任何地方按下此快速鍵，自動移到應該要去的地方，省得你按一堆tab和space</li>
<li>Ctrl+Shift+T:是open type， 這個大家都知道，但是奧妙在type-search的地方，可以打camel case string 作為搜尋；甚至可以用wildcard search. 舉例來說，想打開AdvancedDataGrid, 不用打Adv&#8230;去找，可打ADG就好( <strong>A</strong>dvanced<strong>D</strong>ata<strong>G</strong>rid )。用wildcard search: 打 *skin 會列出所有 XXXskin相關的classes</li>
<li>Code assist : Alt+. (預設) 可以重複按，會自動filter分類，本來是顯示所有的屬性，每一次會顯示各類別: property, style, event</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/1001/feed</wfw:commentRss>
		</item>
		<item>
		<title>用Google Analytics 分析Flex應用程式</title>
		<link>http://blog.shiue.net/archives/966</link>
		<comments>http://blog.shiue.net/archives/966#comments</comments>
		<pubDate>Tue, 10 Nov 2009 05:33:59 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=966</guid>
		<description><![CDATA[Google 真的太威了&#8230;
安裝說明:
http://code.google.com/apis/analytics/docs/tracking/flashTrackingSetupFlex.html#getTheLibrary
取得library:
http://code.google.com/p/gaforflash/
注意:
GA tracking 的結果，不是及時的!
測試不是能夠直接看到結果的，必須等待幾個小時再到Google Analytics網站看報告。

]]></description>
			<content:encoded><![CDATA[<p><strong>Google 真的太威了&#8230;</strong></p>
<p>安裝說明:<br />
http://code.google.com/apis/analytics/docs/tracking/flashTrackingSetupFlex.html#getTheLibrary<br />
取得library:<br />
http://code.google.com/p/gaforflash/</p>
<blockquote><p>注意:<br />
GA tracking 的結果，不是及時的!<br />
測試不是能夠直接看到結果的，必須等待<strong>幾個小時</strong>再到Google Analytics網站看報告。
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/966/feed</wfw:commentRss>
		</item>
		<item>
		<title>你也在寫Flex嗎? 那你可能要特別注意&#8230;</title>
		<link>http://blog.shiue.net/archives/992</link>
		<comments>http://blog.shiue.net/archives/992#comments</comments>
		<pubDate>Tue, 10 Nov 2009 05:28:25 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=992</guid>
		<description><![CDATA[本篇文章來自MAX2009的session:
How Not to code FLEX

演講者主要說明何謂壞程式碼(bad code)，但也說壞程式碼不一定不好，只要你確定能盡快回來改正他。那何謂壞程式碼?

Container 元件的誤用：Container元件諸如Box, Canvas, Tile等等，他們的原本目的都是: 排列裡面的子元件。因此只要你不是拿來排版或甚至沒有給予它任何的子元件，就違背原本用意了。
例子:
&#60;mx:TextInput/&#62;
&#60;mx:VBox backgroundImage=&#34;blah.png&#34; borderStyle=&#34;solid&#34;/&#62; &#60;!-- 你看, 沒有小孩的容器元件--&#62;

ListBase 元件的誤用: List, TileList, DataGrid 都是用來針對列表物件的選取、排序、renderer回收而生，因此，當你想要製作的元件並不需要這些功能，就不該採用List來處理。
local model binding: 避免直接將值給UI元件，盡量用local model binding來處理。(按:此方法還可避免元件初始化延遲所帶來的問題)
ex:
&#60;mx:script&#62;

&#160; //這樣是不好的
&#160; function test():void
&#160; {
&#160; &#160; &#160;myLabel.text = &#34;hello&#34;;
&#160; }

&#60;/mx:script&#62;
&#60;mx:Label id=&#34;myLabel&#34;/&#62;
&#60;mx:Script&#62;
//用local model binding.
[Bindable]
private var helloText:String = &#34;hello&#34;;
&#60;/mx:Script&#62;
&#60;mx:Label id=&#34;myLabel&#34; text=&#34;{helloText}&#34;/&#62;


別把local view event 交由非常上層的元件處理。(按:這裡必須搭配cairngorm microframework 來解釋 )
元件與元件之間的訊息傳遞，如果能在local就解決，便盡量不要拋到上層的command-frontcontroller 去處理然後又繞回來&#8221;原本的元件&#8221;。以後維護會很辛苦。


不適當的容器元件使用方法:
如果你發現你的容器元件裡面只有一個子元件(child)，那可能有問題。


Two dots and you are out.
兩個參照你就出局囉!
如果你的程式碼需要進入非常多的子元件，那就有問題了。如下:
var [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>本篇文章來自MAX2009的session:<br />
<a href="http://tv.adobe.com/watch/max-2009-develop/how-not-to-code-flex/">How Not to code FLEX</a>
</p></blockquote>
<p>演講者主要說明何謂壞程式碼(bad code)，但也說壞程式碼不一定不好，只要你確定能盡快回來改正他。那何謂壞程式碼?</p>
<ul>
<li>Container 元件的誤用：Container元件諸如Box, Canvas, Tile等等，他們的原本目的都是: 排列裡面的子元件。因此只要你不是拿來排版或甚至沒有給予它任何的子元件，就違背原本用意了。<br />
例子:</p>
<div class="codecolorer-container xml " style="overflow:auto;white-space:nowrap;width:435px"><div class="xml codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc3"><span class="re1">&lt;mx:TextInput</span><span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;mx:VBox</span> <span class="re0">backgroundImage</span>=<span class="st0">&quot;blah.png&quot;</span> <span class="re0">borderStyle</span>=<span class="st0">&quot;solid&quot;</span><span class="re2">/&gt;</span></span> <span class="sc-1">&lt;!-- 你看, 沒有小孩的容器元件--&gt;</span></div></div>
</li>
<li>ListBase 元件的誤用: List, TileList, DataGrid 都是用來針對列表物件的選取、排序、renderer回收而生，因此，當你想要製作的元件並不需要這些功能，就不該採用List來處理。</li>
<li>local model binding: 避免直接將值給UI元件，盡量用local model binding來處理。(按:此方法還可避免元件初始化延遲所帶來的問題)<br />
ex:</p>
<div class="codecolorer-container xml " style="overflow:auto;white-space:nowrap;width:435px"><div class="xml codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc3"><span class="re1">&lt;mx:script<span class="re2">&gt;</span></span></span><br />
<br />
&nbsp; //這樣是不好的<br />
&nbsp; function test():void<br />
&nbsp; {<br />
&nbsp; &nbsp; &nbsp;myLabel.text = &quot;hello&quot;;<br />
&nbsp; }<br />
<br />
<span class="sc3"><span class="re1">&lt;/mx:script<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;mx:Label</span> <span class="re0">id</span>=<span class="st0">&quot;myLabel&quot;</span><span class="re2">/&gt;</span></span></div></div>
<div class="codecolorer-container xml " style="overflow:auto;white-space:nowrap;width:435px"><div class="xml codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc3"><span class="re1">&lt;mx:Script<span class="re2">&gt;</span></span></span><br />
//用local model binding.<br />
[Bindable]<br />
private var helloText:String = &quot;hello&quot;;<br />
<span class="sc3"><span class="re1">&lt;/mx:Script<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;mx:Label</span> <span class="re0">id</span>=<span class="st0">&quot;myLabel&quot;</span> <span class="re0">text</span>=<span class="st0">&quot;{helloText}&quot;</span><span class="re2">/&gt;</span></span></div></div>
</li>
<li>
別把local view event 交由非常上層的元件處理。(按:這裡必須搭配cairngorm microframework 來解釋 )<br />
元件與元件之間的訊息傳遞，如果能在local就解決，便盡量不要拋到上層的command-frontcontroller 去處理然後又繞回來&#8221;原本的元件&#8221;。以後維護會很辛苦。
</li>
<li>
不適當的容器元件使用方法:<br />
如果你發現你的容器元件裡面只有一個子元件(child)，那可能有問題。
</li>
<li>
<blockquote><p>Two dots and you are out.<br />
兩個參照你就出局囉!</p></blockquote>
<p>如果你的程式碼需要進入非常多的子元件，那就有問題了。如下:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">var</span> hey<span class="sy0">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">String</span></a> = myBox.thisBox.thatBox.rightLabel.<span class="kw7">text</span>;</div></div>
<p>這是一個本質上的問題，應該要封裝這些子元件，若其他元件需要存取裡面的值，應該要透過Event(帶資料出來) 來幫你。</p>
<li>
自以為的聰明寫法並不好。<br />
這種情況會發生在複雜的binding寫法，像是:</p>
<div class="codecolorer-container xml " style="overflow:auto;white-space:nowrap;width:435px"><div class="xml codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc3"><span class="re1">&lt;mx:Button</span> <span class="re0">id</span>=<span class="st0">&quot;btn&quot;</span> <span class="re0">enabled</span>=<span class="st0">&quot;{ isCheck &amp;amp;&amp;amp; ( firstBtn.enabled &amp;amp; !secondBtn.enabled) &amp;amp;&amp;amp; (thirdBtn.enabled|| feelGood) }&quot;</span><span class="re2">/&gt;</span></span></div></div>
<p>應該要用function 去處理這些binding 邏輯:</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">&lt;mx:Script&gt;<br />
private function getEnabled( a:Boolea , b:Boolea , c:Boolean , d:Boolean , e:Boolean ):Boolean<br />
{<br />
//邏輯應該在這裡描述啦:<br />
return a &amp;&amp; (b&amp;&amp;!c) &amp;&amp;(d||e);<br />
}<br />
&lt;/mx:Script&gt;<br />
&lt;mx:Button id=&quot;btn&quot; enabled=&quot;{ getEnabled(isCheck,firstBtn.enabled,secondBtn.enabled,thirdBtn.enabled,feeGood) }&quot;/&gt;</div></div>
</li>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/992/feed</wfw:commentRss>
		</item>
		<item>
		<title>大稻埕煙火</title>
		<link>http://blog.shiue.net/archives/989</link>
		<comments>http://blog.shiue.net/archives/989#comments</comments>
		<pubDate>Sun, 08 Nov 2009 10:50:21 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[一缽千家飯 孤身萬里遊]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=989</guid>
		<description><![CDATA[感謝小巧帶我去看煙火。坐在野餐墊上戰了七八場富饒之城後，我們順利地等到煙火。
特別喜愛像金色大煙火。沒有多餘的顏色，只有金與黑，如同一管巨大的毛筆沾著金粉墨水，緩緩地在天空黑布上抹下，不知怎麼如此均勻，彷彿盛開的花瓣，對稱的大圓。後來漸漸地垂下，像是金色的雨水沾著窗戶慢慢流下，而我們在窗沿邊拼命讚嘆，就像小孩兒第一次看見彩虹。
煙火是種表演藝術，一波又一波的花樣，前後呼應，剛剛流瀉而下的金雨，下一刻恍若退至幕前，另一道五彩煙花炸裂，一幅金葉藍花倏忽盛開。花開花落，數秒驟逝。
除了煙火本身之外，第一次體會到直接的輿論力量，後排的人們齊心吶喊請前排的民眾坐下，風行草偃，大家都能一望無際。感謝大家的公德心和同理心。
]]></description>
			<content:encoded><![CDATA[<p>感謝小巧帶我去看煙火。坐在野餐墊上戰了七八場富饒之城後，我們順利地等到煙火。</p>
<p>特別喜愛像金色大煙火。沒有多餘的顏色，只有金與黑，如同一管巨大的毛筆沾著金粉墨水，緩緩地在天空黑布上抹下，不知怎麼如此均勻，彷彿盛開的花瓣，對稱的大圓。後來漸漸地垂下，像是金色的雨水沾著窗戶慢慢流下，而我們在窗沿邊拼命讚嘆，就像小孩兒第一次看見彩虹。<br />
煙火是種表演藝術，一波又一波的花樣，前後呼應，剛剛流瀉而下的金雨，下一刻恍若退至幕前，另一道五彩煙花炸裂，一幅金葉藍花倏忽盛開。花開花落，數秒驟逝。</p>
<p>除了煙火本身之外，第一次體會到直接的輿論力量，後排的人們齊心吶喊請前排的民眾坐下，風行草偃，大家都能一望無際。感謝大家的公德心和同理心。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/989/feed</wfw:commentRss>
		</item>
		<item>
		<title>Adobe 官方推出拼字檢查元件( Squiggly ) for Flash/Flex</title>
		<link>http://blog.shiue.net/archives/985</link>
		<comments>http://blog.shiue.net/archives/985#comments</comments>
		<pubDate>Fri, 25 Sep 2009 01:32:18 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[Adobe AIR]]></category>

		<category><![CDATA[spellchecker]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=985</guid>
		<description><![CDATA[念法:
Squiggly [ˈskwigli] DJ   [ˈskwɪglɪ] KK
下載:
http://labs.adobe.com/downloads/squiggly.html
Demo:
http://labs.adobe.com/technologies/squiggly/demo/
]]></description>
			<content:encoded><![CDATA[<p>念法:<br />
<a href="http://www.google.com/dictionary?aq=1&#038;oq=squiggl&#038;langpair=en|zh-TW&#038;q=squiggly&#038;hl=en"><strong>Squiggly [ˈskwigli] DJ   [ˈskwɪglɪ] KK</strong></a></p>
<p>下載:<br />
<a href="http://labs.adobe.com/downloads/squiggly.html">http://labs.adobe.com/downloads/squiggly.html</a><br />
Demo:<br />
<a href="http://labs.adobe.com/technologies/squiggly/demo/">http://labs.adobe.com/technologies/squiggly/demo/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/985/feed</wfw:commentRss>
		</item>
		<item>
		<title>使用: Flex Unit Test Framework</title>
		<link>http://blog.shiue.net/archives/971</link>
		<comments>http://blog.shiue.net/archives/971#comments</comments>
		<pubDate>Fri, 11 Sep 2009 14:29:44 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=971</guid>
		<description><![CDATA[因應 XP 開發手法的趨勢，Adobe也推出FlexUnit: Unit test framework。但我個人覺得，Flex主要是關連到UI的，而UI的測試，光靠FlexUnit不夠的，用人測最直接。然而，通常你找不到那個人。
下載地點：Adobe open source project: Flex unit
何謂Unit Test? 簡單地來說：就每個Method當成一個unit(單位)，測試之。在XP的開發過程中，是測試導向開發，什麼是&#8221;測試導向&#8221;? 就是：每次要寫新功能的時候，不是先寫功能的運作方法，而是先寫『測試該功能的程式』，換言之，我們要以&#8221;通過測試&#8221;為方向，去開發新功能的程式。因此，我們的開發流程往往是: 先寫空白的功能程式，譬如一個空的方法: getSomeResult()，然後先寫測試碼(test case)，像是: testGetSomeResult() 然後寫上我們&#8221;預期的&#8221;測試結果，立刻跑一次test runner，當然，不會過關，立刻回頭撰寫getSomeResult()內容，讓它正確通過test case，那麼getSomeResult()即開發完成 。(見下方的步驟)
這樣的好處，除了確保開發出來的功能可以通過測試；往後的重構(refactor)或是需求變更，都可以再次把unit test 列出來跑一次，確保原來的功能沒有毀掉。
使用步驟：

建立TestRunner
寫TestCase/TestSuite並加入TestRunner
跑TestRunner
看結果，修改原始碼，回到(2)

例子：
//這是要被測試的class method

public class MyApp
&#123;
&#160; &#160; &#160; public function getSomeResult&#40; input:Number &#41;:Number
&#160; &#160; &#160; &#123;
&#160; &#160; &#160; &#160; &#160; &#160;//這裡放入真正的邏輯...
&#160; &#160; &#160; &#160; &#160; &#160;return input/10;
&#160; &#160; &#160; &#160;&#125;
&#125;
//這是測試code( Test Case 不會用在真的主程式裡 ) [...]]]></description>
			<content:encoded><![CDATA[<p>因應 XP 開發手法的趨勢，Adobe也推出FlexUnit: Unit test framework。但我個人覺得，Flex主要是關連到UI的，而UI的測試，光靠FlexUnit不夠的，用人測最直接。然而，通常你找不到那個人。</p>
<p>下載地點：<a href="http://opensource.adobe.com/wiki/display/flexunit/Downloads">Adobe open source project: Flex unit</a></p>
<p>何謂Unit Test? 簡單地來說：就每個Method當成一個unit(單位)，測試之。在XP的開發過程中，是測試導向開發，什麼是&#8221;測試導向&#8221;? 就是：每次要寫新功能的時候，不是先寫功能的運作方法，而是先寫『測試該功能的程式』，換言之，我們要以&#8221;通過測試&#8221;為方向，去開發新功能的程式。因此，我們的開發流程往往是: 先寫空白的功能程式，譬如一個空的方法: getSomeResult()，然後先寫測試碼(test case)，像是: testGetSomeResult() 然後寫上我們&#8221;預期的&#8221;測試結果，立刻跑一次test runner，當然，不會過關，立刻回頭撰寫getSomeResult()內容，讓它正確通過test case，那麼getSomeResult()即開發完成 。(見下方的步驟)</p>
<p>這樣的好處，除了確保開發出來的功能可以通過測試；往後的重構(refactor)或是需求變更，都可以再次把unit test 列出來跑一次，確保原來的功能沒有毀掉。<br />
使用步驟：</p>
<ol>
<li>建立TestRunner</li>
<li>寫TestCase/TestSuite並加入TestRunner</li>
<li>跑TestRunner</li>
<li>看結果，修改原始碼，回到(2)</li>
</ol>
<p>例子：</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">//這是要被測試的class method</span><br />
<br />
<span class="kw1">public</span> <span class="kw4">class</span> MyApp<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw3">function</span> getSomeResult<span class="br0">&#40;</span> input<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> <span class="br0">&#41;</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//這裡放入真正的邏輯...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">return</span> input<span class="sy0">/</span><span class="nu0">10</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">//這是測試code( Test Case 不會用在真的主程式裡 ) : MyTestCase.as</span><br />
<span class="kw1">private</span> <span class="kw2">var</span> classToTestRef<span class="sy0">:</span>MyApp;<br />
<span class="kw1">public</span> <span class="kw3">function</span> testGetSomeResult<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp;classToTestRef = <span class="kw1">new</span> MyApp<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="coMULTI">/*assertEquals : 意思是兩個參數的值結果應該要一樣, <br />
　　　　如果不一樣test 就失敗(fail),你會在TestRunner看到<br />
&nbsp; &nbsp; &nbsp; 底下這個例子會過!<br />
&nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp;assertEquals<span class="br0">&#40;</span> &nbsp;<span class="nu0">100</span> , classToTestRef.getSomeResult<span class="br0">&#40;</span> <span class="nu0">1000</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="co1">//這個不會過</span><br />
&nbsp; &nbsp; &nbsp;assertEquals<span class="br0">&#40;</span> &nbsp;<span class="nu0">2</span>, classToTestRef.getSomeResult<span class="br0">&#40;</span> <span class="nu0">1000</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="co1">//還有許多assertXXX可以用，請見官方文件</span><br />
<span class="br0">&#125;</span></div></div>
<p>特別要強調的是，針對Event處理的測試要怎麼寫? 因為Event發出的時間往往有時間差，並不即時。FlexUnit體貼地加上了一個addAsync() 的方法，幫助我們測試event listeners。寫法如下:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace">addAsync<span class="br0">&#40;</span> eventListener<span class="sy0">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Function</span></a><span class="coMULTI">/*放置assertion的listener*/</span> , timeout<span class="sy0">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">int</span></a> <span class="coMULTI">/*過了多少時間(ms)就算失敗?*/</span><span class="br0">&#41;</span>;</div></div>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw3">function</span> testVeryComplexCalulation<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">//用addAsync() 把test case 延遲檢查:</span><br />
&nbsp; &nbsp; instanceToTest.<span class="kw7">addEventListener</span><span class="br0">&#40;</span> <a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Event</span></a>.<span class="kw8">COMPLETE</span> , <br />
&nbsp; &nbsp; addAsync<span class="br0">&#40;</span> onComplete , <span class="nu0">1000</span> <span class="coMULTI">/*設定:1秒沒發生就算測試失敗*/</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>; &nbsp; <br />
&nbsp; &nbsp; instanceToTest.run<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<br />
<span class="co1">//在 event listener 裡面才寫 assertions:</span><br />
<span class="kw1">private</span> <span class="kw3">function</span> onComplete<span class="br0">&#40;</span> event<span class="sy0">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Event</span></a> <span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp;assertNotNull<span class="br0">&#40;</span> instanceToTest.result <span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/971/feed</wfw:commentRss>
		</item>
		<item>
		<title>Event, EventDispatcher, Listener</title>
		<link>http://blog.shiue.net/archives/927</link>
		<comments>http://blog.shiue.net/archives/927#comments</comments>
		<pubDate>Thu, 13 Aug 2009 16:19:16 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=927</guid>
		<description><![CDATA[這三者的關係，可以用一個情境來解釋：
總機先生，電話機，通話內容。
總機先生是 Listener
電話是 EventDispatcher
通話內容是 Event
通話內容必須透過電話傳達出去，出去之後就由總機先生立刻接聽；此外，一通電話內容可以讓無限個總機接聽(想像把電話機設定成擴音模式)。這個模式的作用在於，讓總機先生在『適當的時間』，做『適當的事』，比如說，一接到找老闆的電話，就要先問：『您是哪位？』此時『一接到電話』就是Event 透過EventDispatcher 發出來了，又正好總機監聽著電話狀態，所以總機立刻根據電話內容(event)，做了特定的事情(問:您是哪位?)。再舉個例子，像是接到愛慕的A氏，就回答:『哈囉你好嗎?』 這兩種回達都是一個Listener ，根據不同的事件，定義不同的listener。
Listener 在 AS3.0 的世界，規定要寫成:
function functionName&#40; event:Event &#41;:void
要監聽某個電話就要寫成:
myPhone.addEventListener( eventType , myListener );
其中eventType是個字串，代表事件的類別(老闆打的還是同事打的)，myListener 就是呼應的動作。要特別強調的是，在AS的世界裡，當一個Event被dispatch出來之後，對應的listener幾乎『沒有時差』就發動，因此我們常遇到UIComponent繪製畫面不如預期，這時可在listener之中利用 callLater 來針對UIComponent操作，利用callLater的延遲是比較正統的作法。
]]></description>
			<content:encoded><![CDATA[<p>這三者的關係，可以用一個情境來解釋：<br />
總機先生，電話機，通話內容。</p>
<p>總機先生是 Listener<br />
電話是 EventDispatcher<br />
通話內容是 Event</p>
<p>通話內容必須透過電話傳達出去，出去之後就由總機先生立刻接聽；此外，一通電話內容可以讓無限個總機接聽(想像把電話機設定成擴音模式)。這個模式的作用在於，讓總機先生在『適當的時間』，做『適當的事』，比如說，一接到找老闆的電話，就要先問：『您是哪位？』此時『一接到電話』就是Event 透過EventDispatcher 發出來了，又正好總機監聽著電話狀態，所以總機立刻根據電話內容(event)，做了特定的事情(問:您是哪位?)。再舉個例子，像是接到愛慕的A氏，就回答:『哈囉你好嗎?』 這兩種回達都是一個Listener ，根據不同的事件，定義不同的listener。</p>
<p>Listener 在 AS3.0 的世界，規定要寫成:</p>
<div class="codecolorer-container actionscript " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">function</span> functionName<span class="br0">&#40;</span> event:Event <span class="br0">&#41;</span>:<span class="kw3">void</span></div></div>
<p>要監聽某個電話就要寫成:<br />
myPhone.addEventListener( eventType , myListener );<br />
其中eventType是個字串，代表事件的類別(老闆打的還是同事打的)，myListener 就是呼應的動作。要特別強調的是，在AS的世界裡，當一個Event被dispatch出來之後，對應的listener幾乎『沒有時差』就發動，因此我們常遇到UIComponent繪製畫面不如預期，這時可在listener之中利用 callLater 來針對UIComponent操作，利用callLater的延遲是比較正統的作法。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/927/feed</wfw:commentRss>
		</item>
		<item>
		<title>AIR 跟 JS&#8230;</title>
		<link>http://blog.shiue.net/archives/922</link>
		<comments>http://blog.shiue.net/archives/922#comments</comments>
		<pubDate>Sun, 26 Jul 2009 15:07:17 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[Adobe AIR]]></category>

		<category><![CDATA[AIR]]></category>

		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=922</guid>
		<description><![CDATA[當兩者糾纏在一起的時候，如果由AIR呼叫Javascript 會掛掉的話，可先試著用setTimeout，通常都可以解決。因為HTML DOM需要時間初始化，Javascript 才能被呼叫。
像是 setTimeout( domWindow.myJsFunction , 1000 );
]]></description>
			<content:encoded><![CDATA[<p>當兩者糾纏在一起的時候，如果由AIR呼叫Javascript 會掛掉的話，可先試著用setTimeout，通常都可以解決。因為HTML DOM需要時間初始化，Javascript 才能被呼叫。</p>
<p>像是 setTimeout( domWindow.myJsFunction , 1000 );</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/922/feed</wfw:commentRss>
		</item>
		<item>
		<title>強制結束DragManager</title>
		<link>http://blog.shiue.net/archives/919</link>
		<comments>http://blog.shiue.net/archives/919#comments</comments>
		<pubDate>Fri, 24 Jul 2009 04:02:27 +0000</pubDate>
		<dc:creator>小薛</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[dragManager]]></category>

		<guid isPermaLink="false">http://blog.shiue.net/?p=919</guid>
		<description><![CDATA[DragManagerImpl#endDrag();
見:DragManagerImpl.as
由於原本的DragManager實作了IDragManager，裡面並沒有公開endDrag()此signature，因此你必須轉型之後才能呼叫這個方法。
]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">DragManagerImpl#endDrag();</div></div>
<p>見:DragManagerImpl.as<br />
由於原本的DragManager實作了IDragManager，裡面並沒有公開endDrag()此signature，因此你必須轉型之後才能呼叫這個方法。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.shiue.net/archives/919/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
   

