發表文章

Android的@Override Error

圖片
久久沒用Android,重新安裝了環境、匯入Propject後跑出了一些錯誤,都是沒有實作的error,如: Multiple markers at this line - implements android.text.TextWatcher.afterTextChanged - The method afterTextChanged(Editable) of type showTextInputDialog.CustomTextWatcher must override a superclass  原來這是 Java SDK版本對於註記符號支援度 的問題,ADT預設使用Java 1.5( language level 5) 編譯內容,但1.5檢查source的時候並不認得「@Override」註記方法,而認為該class沒有正確override,只要把language level改成1.6(以上)就可以了。修改位置: project >  property > java compiler > Compiler compliance level > 1.6。

Flex 3 Tree 元件的資料更新Bug

圖片
Flex 3 的Tree元件可以使用filterFunction來做過濾的功能,比如介面上有一個文字框,輸入文字後比對Tree內容,不包含這段過濾文字者就不顯示。正確情況應該如下圖所示。 但是如果資料的筆數很多時,在Tree元件上使用filterFunction過濾資料時,Tree的內容會亂掉並跑出幾個奇怪的現象: 過濾以後的Tree高度,不會更新,所以ScrollBar一樣可以向下拉動很長的高度。如下圖示,ScrollBar還是很小,表示Tree內容很長。 過濾後,Tree內容仍然保持很長,那不應該存在的cell會怎樣呢?結果Tree裡面會自動找東西亂填cell,如下圖,過濾後應該有5個cell,但超過第3個cell的名稱就開始重複了。 即使使用了invalidateList、validateNow、Collection.refresh等方法也沒有用,標準解法目前未知,但可以用下列方式將顯示更正。在呼叫完filterFunction以後,加上下列方式: tree.expandItem( [your tree data] ,false); tree.expandItem( [your tree data] ,true); 語意上就是讓Tree展開和關閉一次,expandItem方法內部觸發了某個正確的resize和display方法,什麼方法?暫不研究。

Flash Platform 重大更新 -- Flash Player 11.4 and AIR 3.4

近日Flash Platform提出重大更新 --  Flash Player 11.4 and AIR 3.4,更新重點節錄如下: Flash Player 11.4 webcam support for StageVideo broader   Stage3D support Starling framework  has been updated to be constrained mode ready (?) AIR 3.4 iOS push notifications iOS 5.1 SDK support compressed texture with alpha for stage3D  (?) Webcam support for StageVideo Flash Builder 4.7 beta Apache Flex 4.8 support for Flash Player 11.4 AIR 3.4  and many improvements to iOS app development workflows including USB debugging, iOS simulator support, and direct on-device deployment. Flash Professional (early September) ToolKit CreateJS 1.1 support for Flash Player 11.4 and AIR 3.4 improved iOS app development workflows including iOS simulator support, and direct on-device deployment ::References:: 完整更新列表: Flash Player and Adobe AIR feature list 新聞來源: Enabling the web and app development with new bleeding edge technology – Flash Player 11.4 and AIR 3.4 ...

ActionScript的Dictionary

當作動態集合時, Dictionary 跟Object的功能很類似,唯一的不同點就是Dictionary可以設定為弱引用,這樣當Dictionary中紀錄了大量的資料時,可以自行識別集合中的物件是否已經剩下Dictionary中才存在了,是的話就會把引用從Dictionary中移除,如此一來可以讓Dictionary集合的記憶體使用比較有效率。

ActionScript使用原生 JSON 功能

ActionScript在Flash Player 11.0以上開始原生地支援JSON了,官方中文文件可見  使用原生 JSON 功能  和  API Reference 。 節錄官方API的目錄: JSON API 概觀 toJSON() 方法 定義自訂 JSON 行為 在內建類別的原型定義 toJSON() 定義或覆寫類別層級的 toJSON() 使用 JSON.stringify() replacer 參數 使用 JSON.parse() reviver 參數 剖析範例

Cast String to numbers

轉換成整數 int string = "5"; num = parseInt(string); 轉換成浮點數 Number num = Number(string); num = parseFloat(string);

Unload Flex Module Completely?

Flex內部有提供Module的機制,透過Module的設計,可以把主程式切分成幾個swf,然後在需要的時候才去動態 loading和 instantiated,這樣作理論上可以調控網路使用量和記憶體使用量...可是... 這個機制加載時沒問題(目前),但是移除(unload)時卻是問題重重,最大的問題就是,移除掉module後原本佔用的記憶體永遠不會被釋放, 爬了很多文,發現有一些work around的撇步 ,稍微試了一下結果還是行不通: What We Know About Unloading Modules   Unloading modules completely, MXML   問題的關鍵應該是Flex內部有某些物件始終cache住讀進來的 module的 reference,導致即使表面上以為刪除,但實際上卻永遠不會被垃圾蒐集。時間關係,目前先不考慮用Module來做想要的功能了。