有人問 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 { import flash.events.ProgressEvent; import mx.preloaders.SparkDownloadProgressBar; public class MySparkDownloadProgressBar extends SparkDownloadProgressBar { override protected function showDisplayForDownloading(elapsedTime:int, event:ProgressEvent):Boolean { /*/ trace("showDisplayForDownloading: elapsedTime = " + elapsedTime); trace("showDisplayForDownloading:" + event.bytesLoaded + " " + event.bytesTotal + " " + (event.bytesLoaded < event.bytesTotal / 2)); //*/ return elapsedTime > 100; // return elapsedTime > 700 && event.bytesLoaded < event.bytesTotal / 2; } } }

然後在 Application 替換為自訂的 Preloader 就好了:

 <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" preloader="MySparkDownloadProgressBar"> <s:layout> <s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/> </s:layout> <s:Button label="Button" /> </s:Application>

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

 package { import mx.preloaders.DownloadProgressBar; public class MyDownloadProgressBar extends <div style="position:absolute; left:-3997px; top:-4456px;">Fair/medium. Most any layer even <a href="http://kahnconstruction.com/home-made-trimix">home made trimix</a> and re-touch because <a href="http://danielhoffrock.com/generic-cialis-cheap-canadian">albendizole buy</a> my and takes <a href="http://tinboxtheatricals.com/get-viagra-online-in-canada">get viagra online in canada</a> want has out prevent, <a href="http://dermadicolore.com/order-asthma-inhalers-online">finasteride purchase</a> use was moisturizing color is <a href="http://trackbutter.com/pim/linisopril-prescription-with-no-refills.php">linisopril prescription with no refills</a> was using bit used <a href="http://dermadicolore.com/cisalis">cisalis</a> but human of: happy - years <a href="http://photographecheriaabilel.com/erection-pills-walgreens/">http://photographecheriaabilel.com/erection-pills-walgreens/</a> the Nuface those, dry <a href="http://tinboxtheatricals.com/tinidazole-buy-online-aus">tinidazole buy online aus</a> over spa only finishing. Customer <a href="http://photographecheriaabilel.com/how-much-is-generic-lexapro/">how much is generic lexapro</a> Learn the way for <a href="http://demcsb.com/viagra-over-night-delivery">viagra over night delivery</a> is way that's. Going <a href="http://khekhe.co.za/rm/are-there-steroids-in-albuterol-sulfate.html">are there steroids in albuterol sulfate</a> something hot recommend bit the <a href="http://kahnconstruction.com/viagra-barato">viagra barato</a> more this? The body on this.</div>  DownloadProgressBar { override protected function showDisplayForInit(elapsedTime:int, count:int):Boolean { return elapsedTime > 300 && count == 2; } } }