<?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>RichMedia+ &#187; Adobe Flex4</title>
	<atom:link href="http://blog.richmediaplus.com/tag/adobe-flex4/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.richmediaplus.com</link>
	<description>About the Adobe&#039;s RIA related solution and technology, like Adobe Air, Adobe Flex, Mobile Dev. You also can find the SEO for Flex, RIA, User Ex in this blog.</description>
	<lastBuildDate>Fri, 16 Dec 2011 09:33:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Flex 4.5 Spark RichEditableText maxChars 與輸入法問題</title>
		<link>http://blog.richmediaplus.com/2011/08/spark-richeditabletext-maxchars-issue/</link>
		<comments>http://blog.richmediaplus.com/2011/08/spark-richeditabletext-maxchars-issue/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 02:50:26 +0000</pubDate>
		<dc:creator>Ticore Shih</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Adobe Flex4]]></category>
		<category><![CDATA[TLF]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=807</guid>
		<description><![CDATA[當在 TextInput, TextArea 等文字組件設定 maxChars 最大字數屬性 使用中文輸入法打了數個字到文字佇列上，超過最大限制字數 然後用 Ctrl + Space 切換輸入法或是按下 Enter 方式輸入文字 結果會發現其它 Binding 到 text 屬性的目標無法取得正確的 text 字串 之後再利用按鈕事件 trace 組件的 text 屬性也是取到錯誤的字串資料 來回 trace 好多程式碼位置之後，發現問題主要是出在 RichEditableText 組件上 不過由於問題原因非常複雜，所以要分成很多段落先解釋一些 TLF 與文字組件運作方式 為什麼要花這麼大力氣找原因? 除了解決問題之外，主要還想要了解一下 TLF 文字引擎的運作方式 令我最驚訝的是，輸入法待選文字佇列功能，居然是 TLF 內建，完全用 AS3 寫的！ 相關 Bug Report http://bugs.adobe.com/jira/browse/SDK-28999 http://www.fxug.net/modules/xhnewbb/viewtopic.php?topic_id=4338 RichEditableText maxChars 與輸入法問題測試程式： &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;s:Application [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/09/spark-multi-column-sortable-datagrid/' rel='bookmark' title='Spark 多重欄位排序的 DataGrid'>Spark 多重欄位排序的 DataGrid</a></li>
<li><a href='http://blog.richmediaplus.com/2009/03/htmlformatforreducedatabasestorageinclient/' rel='bookmark' title='htmlFormat for Reduce DataBase Storage in Client'>htmlFormat for Reduce DataBase Storage in Client</a></li>
<li><a href='http://blog.richmediaplus.com/2011/06/flex-spark-preloader-disappear/' rel='bookmark' title='解決 Flex 4.x 下載進度不出現的問題'>解決 Flex 4.x 下載進度不出現的問題</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>當在 TextInput, TextArea 等文字組件設定 maxChars 最大字數屬性<br />
使用中文輸入法打了數個字到文字佇列上，超過最大限制字數<br />
然後用 Ctrl + Space 切換輸入法或是按下 Enter 方式輸入文字<br />
結果會發現其它 Binding 到 text 屬性的目標無法取得正確的 text 字串<br />
之後再利用按鈕事件 trace 組件的 text 屬性也是取到錯誤的字串資料</p>
<p>來回 trace 好多程式碼位置之後，發現問題主要是出在 RichEditableText 組件上<br />
不過由於問題原因非常複雜，所以要分成很多段落先解釋一些 TLF 與文字組件運作方式</p>
<p>為什麼要花這麼大力氣找原因?<br />
除了解決問題之外，主要還想要了解一下 TLF 文字引擎的運作方式<br />
令我最驚訝的是，輸入法待選文字佇列功能，居然是 TLF 內建，完全用 AS3 寫的！</p>
<p>相關 Bug Report</p>
<p>http://bugs.adobe.com/jira/browse/SDK-28999</p>
<p>http://www.fxug.net/modules/xhnewbb/viewtopic.php?topic_id=4338</p>
<p>RichEditableText maxChars 與輸入法問題測試程式：</p>

<div class="wp_syntax"><div 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> 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;">     xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span> fontSize=<span style="color: #ff0000;">&quot;14&quot;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HorizontalLayout</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> gap=<span style="color: #ff0000;">&quot;12&quot;</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;TextInput&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;txt1&quot;</span> contentBackgroundColor=<span style="color: #ff0000;">&quot;#DDDDDD&quot;</span></span>
<span style="color: #000000;">    maxChars=<span style="color: #ff0000;">&quot;3&quot;</span> widthInChars=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> text=<span style="color: #ff0000;">&quot;{txt1.text}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;txt1.text: {txt1.text}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> label=<span style="color: #ff0000;">&quot;trace(txt1.text);&quot;</span> click=<span style="color: #ff0000;">&quot;trace(txt1.text);&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> gap=<span style="color: #ff0000;">&quot;12&quot;</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;TextArea&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextArea</span> id=<span style="color: #ff0000;">&quot;txt2&quot;</span> contentBackgroundColor=<span style="color: #ff0000;">&quot;#DDDDDD&quot;</span></span>
<span style="color: #000000;">    maxChars=<span style="color: #ff0000;">&quot;3&quot;</span> heightInLines=<span style="color: #ff0000;">&quot;1&quot;</span> widthInChars=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> text=<span style="color: #ff0000;">&quot;{txt2.text}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;txt2.text: {txt2.text}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> label=<span style="color: #ff0000;">&quot;trace(txt2.text);&quot;</span> click=<span style="color: #ff0000;">&quot;trace(txt2.text);&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> gap=<span style="color: #ff0000;">&quot;12&quot;</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;RichEditableText&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RichEditableText</span> id=<span style="color: #ff0000;">&quot;txt3&quot;</span> backgroundColor=<span style="color: #ff0000;">&quot;#DDDDDD&quot;</span></span>
<span style="color: #000000;">    paddingLeft=<span style="color: #ff0000;">&quot;4&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;4&quot;</span> paddingTop=<span style="color: #ff0000;">&quot;4&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;4&quot;</span></span>
<span style="color: #000000;">    maxChars=<span style="color: #ff0000;">&quot;3&quot;</span> heightInLines=<span style="color: #ff0000;">&quot;1&quot;</span> widthInChars=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> text=<span style="color: #ff0000;">&quot;{txt3.text}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;txt3.text: {txt3.text}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> label=<span style="color: #ff0000;">&quot;trace(txt3.text);&quot;</span> click=<span style="color: #ff0000;">&quot;trace(txt3.text);&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</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></div></div>

<p><strong>※ RichEditableText 內部 TLF 文字管理</strong><br />
RichEditableText 本身並不直接控制文字表現<br />
而是透過內部一個 TLF TextContainerManager 實體<br />
負責表現、捲動、編輯文字以及文字輸入法佇列<br />
每當文字發生變動<br />
TextContainerManager 有三個事件會依序發出，當然還有其它的 Damage, Composition 等事件</p>
<p>FlowOperationEvent.FLOW_OPERATION_BEGIN<br />
FlowOperationEvent.FLOW_OPERATION_END<br />
FlowOperationEvent.FLOW_OPERATION_COMPLETE</p>
<p>RichEditable 內三個私有偵聽函式負責處理</p>
<p>textContainerManager_flowOperationBeginHandler<br />
 處理完立即發出 TextOperationEvent.CHANGING 事件</p>
<p>textContainerManager_flowOperationEndHandler</p>
<p>textContainerManager_flowOperationCompleteHandler<br />
 處理完立即發出 TextOperationEvent.CHANGE 事件</p>
<p>在 textContainerManager_flowOperationBeginHandler 內<br />
也會檢查插入文字 + 原本文字總長是否超出 maxChars，並加以裁切<br />
輸入法問題就是出在這裡</p>
<p><strong>※ RichEditableText.text 屬性的內部 cache</strong><br />
RichEditableText 內部用一個私有變數存放 Plain Text 叫做 _text<br />
每當 textFlow, content 被重新指定或是 damage 事件發生時，_text 會被重設為 null<br />
假如取用 text 時 _text 為 null，會從 TextFlow 重新 export plain text 並存放到 _text</p>
<p><strong>※ 從 TextFlow 取得 Plain 文字的方式</strong><br />
var staticPlainTextExporter:ITextExporter =<br />
  TextConverter.getExporter(TextConverter.PLAIN_TEXT_FORMAT);<br />
var txt:String = staticPlainTextExporter.export(textFlow, ConversionType.STRING_TYPE) as String;</p>
<p>// 或是</p>
<p>textFlow.getText();</p>
<p><strong>※ RichEditableText maxChars 與輸入法問題的成因</strong><br />
IME 輸入法輸入文字到佇列，然後確認文字是一連串複雜的動作<br />
由於佇列文字是由 TLF 負責表現<br />
當確認佇列文字時，必須先銷毀 TLF 佇列文字<br />
然後復原畫面到不包含佇列文字的狀況<br />
最後再合併輸入輸入文字</p>
<p>以上動作會在 FlowOperationEvent.FLOW_OPERATION_BEGIN 事件後開始進行<br />
預設情況下，由於輸入佇列文字動作比較複雜<br />
TLF EditManager 不會立刻完成所有的動作，而是會透過影格事件分批完成<br />
然後才發出 FlowOperationEvent.FLOW_OPERATION_END 事件<br />
導致此時從 TextFlow 取得的文字並非最後的結果</p>
<p>假如又要檢查 text.length 是否超過 maxChars 的話<br />
會觸發 export plain text 存到 _text 快取<br />
之後完全沒有更新的 _text 快取機會<br />
導致取到的 text 資料都是舊的</p>
<p><strong>※ 為什麼 Flex 4.0 沒有這問題</strong><br />
基本上 RichEditableText 沒有很大差異<br />
而 Flex 4.0 是使用 TLF 1.1，Flex 4.5 是使用 TLF 2.0<br />
主要是 TLF 1.1 TextContainerManager 最後完成所有操作之後<br />
都會再多發一次 Damage 事件，讓 _text 快取被清掉了</p>
<p><strong>※ 強迫 TLF EditManager 立刻完成所有的動作的方式</strong><br />
(Spark ComboBox 會設定 batchTextInput = false 所以才避開了這個問題)</p>
<p>RichEditableText Class：</p>
<p>/**<br />
 *  @private<br />
 *  The TLF edit manager will batch all inserted text until the next<br />
 *  enter frame event.  This includes text inserted via the GUI as well<br />
 *  as api calls to EditManager.insertText().  Set this to false if you<br />
 *  want every keystroke to be inserted into the text immediately which will<br />
 *  result in a TextOperationEvent.CHANGE event for each character.  One<br />
 *  place this is needed is for the type-ahead feature of the editable combo<br />
 *  box.<br />
 */<br />
mx_internal var batchTextInput:Boolean = true;<br />
以上屬性會在 RichEditableTextContainerManager createEditManager 時<br />
設定到 EditManager 上<br />
editManager.allowDelayedOperations = textDisplay.batchTextInput;</p>
<p><strong>※ 問題解決方式</strong><br />
方式 1.<br />
修改 RichEditableText 內的 textContainerManager_flowOperationBeginHandler 函式<br />
取用完 text.length 之後，指定 _text 為 null</p>
<p>if (maxChars != 0) {<br />
    var length1:int = text.length &#8211; delLen;<br />
    var length2:int = textToInsert.length;<br />
    if (length1 + length2 > maxChars)<br />
        textToInsert = textToInsert.substr(0, maxChars &#8211; length1);<br />
    _text = null;<br />
}<br />
方式 2.<br />
在 RichEditableText 組件 change 事件上，重新指定 textFlow，強迫更新 _text 快取</p>
<p>var tf:TextFlow = event.target.textFlow;<br />
event.target.textFlow = new TextFlow();<br />
event.target.textFlow = tf;<br />
Spark TextInput, TextArea 可以在自訂 Skin 裡面添加以上程式</p>
<p>方式 3. (建議)<br />
在 RichEditableText 組件 preinitialize 事件中，設定 batchTextInput 為 false</p>
<p>event.target.mx_internal::batchTextInput = false;<br />
Spark TextInput, TextArea 可以在自訂 Skin 裡面添加以上程式</p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/09/spark-multi-column-sortable-datagrid/' rel='bookmark' title='Spark 多重欄位排序的 DataGrid'>Spark 多重欄位排序的 DataGrid</a></li>
<li><a href='http://blog.richmediaplus.com/2009/03/htmlformatforreducedatabasestorageinclient/' rel='bookmark' title='htmlFormat for Reduce DataBase Storage in Client'>htmlFormat for Reduce DataBase Storage in Client</a></li>
<li><a href='http://blog.richmediaplus.com/2011/06/flex-spark-preloader-disappear/' rel='bookmark' title='解決 Flex 4.x 下載進度不出現的問題'>解決 Flex 4.x 下載進度不出現的問題</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/08/spark-richeditabletext-maxchars-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>解決 Flex 4.x 下載進度不出現的問題</title>
		<link>http://blog.richmediaplus.com/2011/06/flex-spark-preloader-disappear/</link>
		<comments>http://blog.richmediaplus.com/2011/06/flex-spark-preloader-disappear/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 10:39:22 +0000</pubDate>
		<dc:creator>Ticore Shih</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Adobe Flex4]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=791</guid>
		<description><![CDATA[有人問 Flex 4, 4.5 Spark 的 Download Progress Bar 不出現的問題 Adobe 討論板上也有人問 原因大略是因為 Flex 4, 4.5 提高了出現的門檻 原本 MX 版 Progress Bar 是要超過 300ms 才會出現 Spark 版 Progress Bar 要超過 700ms 且下載進度未超過 50% 才會出現 條件相當嚴苛，導致一般的小 Flex App 都看不到下載進度條了 解決的方式不難，自己繼承 SparkDownloadProgressBar 並覆寫 showDisplayForDownloading package &#123; import flash.events.ProgressEvent; import mx.preloaders.SparkDownloadProgressBar; &#160; public class MySparkDownloadProgressBar extends SparkDownloadProgressBar &#123; [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2009/12/as3-project-custom-preload-load-application/' rel='bookmark' title='AS3工程 Custom Preloader 動態加載 Application'>AS3工程 Custom Preloader 動態加載 Application</a></li>
<li><a href='http://blog.richmediaplus.com/2011/08/mxmlc-define-embed-source/' rel='bookmark' title='Flex Compiler 編譯參數嵌入外部資源技巧'>Flex Compiler 編譯參數嵌入外部資源技巧</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-3-style-module/' rel='bookmark' title='Flex 3 Style Module'>Flex 3 Style Module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>有人問 <a href="http://bbs.9ria.com/viewthread.php?tid=86656&#038;rpid=806988&#038;ordertype=0&#038;page=1#pid806988">Flex 4, 4.5 Spark 的 Download Progress Bar 不出現的問題</a><br />
<a href="http://forums.adobe.com/message/3700786">Adobe 討論板上也有人問</a> 原因大略是因為 Flex 4, 4.5 提高了出現的門檻<br />
原本 MX 版 Progress Bar 是要超過 300ms 才會出現<br />
Spark 版 Progress Bar 要超過 700ms 且下載進度未超過 50% 才會出現<br />
條件相當嚴苛，導致一般的小 Flex App 都看不到下載進度條了</p>
<p>解決的方式不難，自己繼承 SparkDownloadProgressBar 並覆寫 showDisplayForDownloading</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ProgressEvent</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>preloaders<span style="color: #000066; font-weight: bold;">.</span>SparkDownloadProgressBar<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
 <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MySparkDownloadProgressBar <span style="color: #0033ff; font-weight: bold;">extends</span> SparkDownloadProgressBar <span style="color: #000000;">&#123;</span>
&nbsp;
  override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> showDisplayForDownloading<span style="color: #000000;">&#40;</span>elapsedTime<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">,</span> event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">ProgressEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span>
   <span style="color: #009966; font-style: italic;">/*/</span>
   <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;showDisplayForDownloading: elapsedTime = &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> elapsedTime<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;showDisplayForDownloading:&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesLoaded</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; &quot;</span> <span style="color: #000066; font-weight: bold;">+</span>
    event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesTotal</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesLoaded</span> <span style="color: #000066; font-weight: bold;">&lt;</span> event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesTotal</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #009900; font-style: italic;">//*/</span>
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">return</span> elapsedTime <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #009900; font-style: italic;">// return elapsedTime &gt; 700 &amp;&amp; event.bytesLoaded &lt; event.bytesTotal / 2;</span>
  <span style="color: #000000;">&#125;</span>
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>然後在 Application 替換為自訂的 Preloader 就好了：</p>

<div class="wp_syntax"><div 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> 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;">  xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">  preloader=<span style="color: #ff0000;">&quot;MySparkDownloadProgressBar&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> label=<span style="color: #ff0000;">&quot;Button&quot;</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></div></div>

<p>假如想要調整 MX 版 Progress Bar 出現門檻，方法也是類似<br />
只是要覆寫的 function 不一樣</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>preloaders<span style="color: #000066; font-weight: bold;">.</span>DownloadProgressBar<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
 <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyDownloadProgressBar <span style="color: #0033ff; font-weight: bold;">extends</span> DownloadProgressBar <span style="color: #000000;">&#123;</span>
&nbsp;
  override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> showDisplayForInit<span style="color: #000000;">&#40;</span>elapsedTime<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">,</span> count<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000066; 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> elapsedTime <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">300</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> count == <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2009/12/as3-project-custom-preload-load-application/' rel='bookmark' title='AS3工程 Custom Preloader 動態加載 Application'>AS3工程 Custom Preloader 動態加載 Application</a></li>
<li><a href='http://blog.richmediaplus.com/2011/08/mxmlc-define-embed-source/' rel='bookmark' title='Flex Compiler 編譯參數嵌入外部資源技巧'>Flex Compiler 編譯參數嵌入外部資源技巧</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-3-style-module/' rel='bookmark' title='Flex 3 Style Module'>Flex 3 Style Module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/06/flex-spark-preloader-disappear/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex 4 SDK, Flash Builder 4正式版發布！</title>
		<link>http://blog.richmediaplus.com/2010/03/flex-4-sdk-flash-builder-4-release/</link>
		<comments>http://blog.richmediaplus.com/2010/03/flex-4-sdk-flash-builder-4-release/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 06:13:19 +0000</pubDate>
		<dc:creator>Alvin / Aedis.Ju</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe Flex4]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=509</guid>
		<description><![CDATA[Flex 4 SDK, Flash Builder 4正式版發布！ 語言方面增加了中文，法文，德文，不過我還是習慣英文&#8230;XD 細細品味中&#8230; Related posts: Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法 發瘋了？！Flex Builder改名為Flash Builder？ Flex Formatter Flash Builder/Eclipse 添加地址
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-flash-builder-fdt-profile-can-not-start-solution/' rel='bookmark' title='Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法'>Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法</a></li>
<li><a href='http://blog.richmediaplus.com/2009/05/crazy-flex-builder-changed-the-name-to-flash-builder/' rel='bookmark' title='發瘋了？！Flex Builder改名為Flash Builder？'>發瘋了？！Flex Builder改名為Flash Builder？</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-formatter-flash-builder-eclipse-url/' rel='bookmark' title='Flex Formatter Flash Builder/Eclipse 添加地址'>Flex Formatter Flash Builder/Eclipse 添加地址</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Flex 4 SDK, Flash Builder 4正式版發布！<br />
<img src="http://farm5.static.flickr.com/4023/4452854253_27c83a49c4.jpg" alt="Adobe Flash Builder 4 Release!" /><br />
語言方面增加了中文，法文，德文，不過我還是習慣英文&#8230;XD</p>
<p>細細品味中&#8230;</p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-flash-builder-fdt-profile-can-not-start-solution/' rel='bookmark' title='Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法'>Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法</a></li>
<li><a href='http://blog.richmediaplus.com/2009/05/crazy-flex-builder-changed-the-name-to-flash-builder/' rel='bookmark' title='發瘋了？！Flex Builder改名為Flash Builder？'>發瘋了？！Flex Builder改名為Flash Builder？</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-formatter-flash-builder-eclipse-url/' rel='bookmark' title='Flex Formatter Flash Builder/Eclipse 添加地址'>Flex Formatter Flash Builder/Eclipse 添加地址</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2010/03/flex-4-sdk-flash-builder-4-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cannes Multi Touchwall by Schematic</title>
		<link>http://blog.richmediaplus.com/2009/06/cannes-multi-touchwall-by-schematic/</link>
		<comments>http://blog.richmediaplus.com/2009/06/cannes-multi-touchwall-by-schematic/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 06:22:18 +0000</pubDate>
		<dc:creator>Alvin / Aedis.Ju</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Multi Touch]]></category>
		<category><![CDATA[Adobe Flex4]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=285</guid>
		<description><![CDATA[Cannes Multi Touchwall by Schematic&#8230;. Base on Flex4 framework. Two Videos: http://creativity-online.com/work/view?seed=476c13f7 http://vimeo.com/5326255 Related posts: X-Desk，加速吧！Multi-Touch! TLF &#038; OSMF Open Source
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2009/05/x-desk-epson-multi-touch/' rel='bookmark' title='X-Desk，加速吧！Multi-Touch!'>X-Desk，加速吧！Multi-Touch!</a></li>
<li><a href='http://blog.richmediaplus.com/2009/07/tlf-osmf-open-source/' rel='bookmark' title='TLF &amp; OSMF Open Source'>TLF &#038; OSMF Open Source</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Cannes Multi Touchwall by Schematic&#8230;.<br />
Base on Flex4 framework.</p>
<p>Two Videos:</p>
<ul>
<li>http://creativity-online.com/work/view?seed=476c13f7</li>
<li>http://vimeo.com/5326255</li>
</ul>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2009/05/x-desk-epson-multi-touch/' rel='bookmark' title='X-Desk，加速吧！Multi-Touch!'>X-Desk，加速吧！Multi-Touch!</a></li>
<li><a href='http://blog.richmediaplus.com/2009/07/tlf-osmf-open-source/' rel='bookmark' title='TLF &amp; OSMF Open Source'>TLF &#038; OSMF Open Source</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2009/06/cannes-multi-touchwall-by-schematic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Builder and Flash Catalyst Betas 發放！</title>
		<link>http://blog.richmediaplus.com/2009/06/flash-builder-and-flash-catalyst-betas-now-available/</link>
		<comments>http://blog.richmediaplus.com/2009/06/flash-builder-and-flash-catalyst-betas-now-available/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 04:54:00 +0000</pubDate>
		<dc:creator>Alvin / Aedis.Ju</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Catalyst]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe Flash Builder]]></category>
		<category><![CDATA[Adobe Flash Catalyst]]></category>
		<category><![CDATA[Adobe Flex4]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=258</guid>
		<description><![CDATA[Adobe Flash Builder beta(Adobe Flex4) and Adobe Flash Catalyst beta 已經發放，你現在就可以通過Adobe ID去下載。 大家速度下載體驗吧！ 雖然目前是beta版本，但是基本大致上已經基本可以確定，特別對Adobe Flash Catalyst更是讓我拭目以待。 Related posts: 讓 Flash Catalyst CS 5.5 也能編輯原始碼 Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法 Flex 4 SDK, Flash Builder 4正式版發布！
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/05/flash-catalyst-code-editable/' rel='bookmark' title='讓 Flash Catalyst CS 5.5 也能編輯原始碼'>讓 Flash Catalyst CS 5.5 也能編輯原始碼</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-flash-builder-fdt-profile-can-not-start-solution/' rel='bookmark' title='Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法'>Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法</a></li>
<li><a href='http://blog.richmediaplus.com/2010/03/flex-4-sdk-flash-builder-4-release/' rel='bookmark' title='Flex 4 SDK, Flash Builder 4正式版發布！'>Flex 4 SDK, Flash Builder 4正式版發布！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_flashbuilder4">Adobe Flash Builder beta</a>(Adobe Flex4) and <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_flashcatalyst">Adobe Flash Catalyst beta</a> 已經發放，你現在就可以通過Adobe ID去下載。</p>
<p>大家速度下載體驗吧！</p>
<p>雖然目前是beta版本，但是基本大致上已經基本可以確定，特別對<a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_flashcatalyst">Adobe Flash Catalyst</a>更是讓我拭目以待。</p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/05/flash-catalyst-code-editable/' rel='bookmark' title='讓 Flash Catalyst CS 5.5 也能編輯原始碼'>讓 Flash Catalyst CS 5.5 也能編輯原始碼</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-flash-builder-fdt-profile-can-not-start-solution/' rel='bookmark' title='Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法'>Flex Builder/Flash Builder/FDT Profile概要分析打不开解决方法</a></li>
<li><a href='http://blog.richmediaplus.com/2010/03/flex-4-sdk-flash-builder-4-release/' rel='bookmark' title='Flex 4 SDK, Flash Builder 4正式版發布！'>Flex 4 SDK, Flash Builder 4正式版發布！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2009/06/flash-builder-and-flash-catalyst-betas-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

