AS spell checking engine Squiggly

23 Sep 2009 In: ActionScript Lib

Squiggly允許你在任何基於Flex 3文本組件上使用檢查語言的拼寫,最終的版本支持的會是flashplayer 10的運行環境。

在線演示程序

visualsearch of Bing.com

15 Sep 2009 In: Silverlight, User Experience

http://www.bing.com/visualsearch?mkt=en-us

Good idea, Good VisualSearch, Good User Experience!

You need install Silverlight 3.0 first.

關于程式效能優化的文章,我前面介紹過2篇,都是值得一看:

近日在 InsideRIA 發表了新的一篇 10 Tips for Flex Application Performance ,是我非常敬仰的大師 Andrew Trice 所寫,程式效能優化雖然老生常談,但畢竟大師的作品是不應該落下的,因此拉出來跟大家一起品味一下。

原文就自己看了,我稍微用中文總結一下 Andrew Trice 所述的其中 6 點。

  • Manage your event listeners
    要經常 remove 不需要的 event listeners。
    定義 event listeners 的時候,注意 target 和 parent 的關系。
    設置好 Event 的 bubbles & cancelable。
    addEventListener 中的 useCapture, priority, useWeakReference。
  • Unload loaders
    如果使用的 Component 是基于 loader 的,諸如 SWFLoader, Image等等,要使用 unloadAndStop()。
    unloadAndStop(),這個是 flashplayer 10 后才有的,flashplayer 9 的 unload()并不能真正回收,應該也屬于 bug 的范疇。
    關于 unloadAndStop() ,大家可以參考下面的2篇文章作大致的了解:
    Flash Player 10 unloadAndStop 測試
    FlashPlayer10的Loader.unloadAndStop
  • Dispose of things
    在做 dispose() 的時候,把一切該混滅得都毀滅吧。
  • Handle collections properly
    去了解 ICollectionView 的 enableAutoUpdate () & disableAutoUpdate () ,這一點對寫 Component 的同學特別重要。
    如果沒有使用 data binding,盡量使用 Array。
    在 sort & filterFunction 后是否立即要使用 refresh() 需要注意畫面的實際情況。
  • Use deferred instantiation
    這一點需要大家去了解 Flex Component 的 lifeCycle 。
    在使用tab,nav, accordion, viewstack等控件的時候,Flex 用 creationPolicy 來進行對子對象創建的策略。默認情況下,tab,nav, accordion, viewstack等的子控件都沒有完全生成,而是在比如點擊第二頁的時候,他會去生成第二個子控件里面的內容。
    因此,對 Flex Component 而言,不要把生成子對象寫在 Constructor 里面,要記得去 override createChildren()。
  • Object recycling vs new objects
    Reduce,  Reuse,  Recycle 就是最大的概況。
  • Don’t invalidate/destroy/re-validate your objects if nothing changed
  • Dynamic/Generic vs. Typed Objects
  • Use constants when applicable
  • Use static members

4P 4C 4R

1 Sep 2009 In: Life is Cool!

Product、Price、Place、Promotion

Consumer、Cost、Convenience、Communication

Relativity、Reaction、Relation、Retribution

VerifyError: Error #1107 Solution

25 Aug 2009 In: ActionScript3, Adobe Flex

VerifyError: Error #1107: The ABC data is corrupt, attempt to read out of bounds
VerifyError: Error #1107: ABC 数据已损坏,尝试的读取操作超出范围。

今天遇到了 Adobe Flex VerifyError: Error #1107 的錯誤,囧了一天。
在網上搜了很多,貌似都沒有幾個合理的解釋,因此總結一下網上搜索的結果和自己的實際經驗來給大家分享下解決方案。

————————————————-
Class is too large, or contains too much large arrays

http://forums.ilog.com/elixir/index.php?topic=858.0

Marc Said:
It seems that the compiled actionscript class is too large, or contains too much large arrays, which confuses the Flash Player. To get a smaller class, I did use the simplification threshold to generate the class. A value of 50000 meters did work for me. Note that you will also need some patience  because the simplification process in Custom Map Converter is quite time consuming.

metman Said:
Reducing the number of points did work – thanks. Is there anyway of telling what this is? Or if that array size will be increased in a future release to prevent this happening? BTW the simplification process is very fast and is not a problem.

說明 Reduce the number of points 有效,class文件太大或者內容里面還有太多的 Array,導致編譯器發生錯誤。
我沒有唉。:-(

————————————————-
Update to Flex3.2

我的錯誤發生的編譯環境是 Flex2.0.1 Hotfix3 ,而如果使用 Flex3.2 的SDK,并不會發生 VerifyError: Error #1107 的錯誤
因此升級為 Flex3.2 的版本,不會有這樣的錯誤發生。
但是目前工程情況不允許。 :-(

————————————————-
Common Flex 2 compiler errors and known issues

175465: The following runtime error is produced because the compiler fails to report an error when there is a protected set method in base class with the same name as a protected member variable in a derived class: VerifyError: Error #1107: The ABC data is corrupt, attempt to read out of bounds.

大概的意思是 a protected set method 命名重復了。
自己找了一下,protected set method 沒有重復。Orz… :-(

————————————————-
奇異的命名重復

最好發現原來在2個 Class 里面對同一個 Instance 進行了 MouseDown 的監聽,而且直接在后面跟上 function ,名字都是 handleMouseDown 。
XXX.getInstance().addEventListener(MouseEvent.MOUSE_DOWN, function handleMouseDown(event:Event):void{...})
那么會出現 VerifyError: Error #1107 的錯誤。

如果1個 Class 里面命名為 a ,一個命名為 b,還是會發生錯誤。 囧

目前情況是 把handleMouseDown單獨提出來寫,不管是否命名重復,那么錯誤不會發生。因此這應該是 Adobe 的BUG。 ;-)

VerifyError: Error #1107 Solution: 因此避免錯誤的總結是 按照編碼規約,監聽事件的處理程式要單獨提出來寫。