強制結束DragManager
Thursday, July 23rd, 2009見:DragManagerImpl.as
由於原本的DragManager實作了IDragManager,裡面並沒有公開endDrag()此signature,因此你必須轉型之後才能呼叫這個方法。
見:DragManagerImpl.as
由於原本的DragManager實作了IDragManager,裡面並沒有公開endDrag()此signature,因此你必須轉型之後才能呼叫這個方法。
針對Flex 預設的Drag-Drop,List元件會貼心地幫你畫出indicator(預設是一條線),然而,一旦試著用 DragEvent#preventDefault()時,indicator 會殘留在畫面上,此時,可以利用
即可清除掉indicator, highlight 等 DisplayObject.
==
To clean up Flex default DragDrop visualization, try ListBase#hideDropFeedback(event), Especially when implementing your own drag-drop event handlers. This method remove all highlight and indicator display objects.
模仿Rails的Inflection方法,用actionscript 改寫如下:
如:
Inflection.singularize( “cars” ); //cars => car
如:
Inflection.pluralize( “apple” ); // apple => apples
原始碼如下:(source)
Mac的比較漂亮啦 !

剛剛研究出快速畫出Mac標題列的樣式,這麼做:
建立自己的ProgramaticSkin, 覆寫 updateDisplayList( w , h );
更新@2009/5/11:
Adobe 有個驅動Garbage Collection的方法:
flash.system.System.gc();
flash.system.System.gc();
但是必須連續呼叫兩次,第一次呼叫: 對物件加上記號;第二次:清除記憶體
更多詳情請見:
http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/
原文:
http://blogs.adobe.com/air/2009/05/performance_tips_for_adobe_air.html
在處理Grant Skinner發現的CPU效能問題之前,有幾個方法可以先改善AIR程式的效能:
更多文章:
HP 推出可以偵測swf檔的安全漏洞的程式: SWFScan
可到HP官網免費下載!
File.nativePath 是完整的絕對路徑,如果直接用nativePath的值當作路徑,在mac上有時會出現IOError。然而,File.url 會把applicationStorage的路徑用app-storage: 替換掉,參照的時候再轉換,對於不同的系統結構,用File.url是比較保險的作法。
展開一個Tree元件的所有節點的方法,有兩個階段:
1. 走訪所有節點
2. 如果是枝幹(branch)結點,就打開它( 有預設的方法可以使用, expandChildrenOf( node, open) )
要提醒的地方是,所有ListBase類型的元件,裡頭都有一個collectionChangeHandler的涵式,我們可以複寫他,讓每次資料重讀之後,就打開全部節點。
請見下方原始碼
===
All ListBase-components handle collection with a collectionChangeHandler(event). All we have to do is override it by adding a expandAll() function. How will we do with this expandAll()? See following sample:
As you see, we just iterate all tree node, determining if it is a branch and then call the built-in expandChildreOf(node,open) method.
DOM object in HTML ( HTML.domWindow ) stop the Drag events propagating so that dragging over HTML ui will not succeed, which means you cannot see an accept-drop-icon near mouse cursor. To solve this, you have to register a handler to prevent DOM doing something behind but accept drop action, as following sample code:
PS: Javascript drag event types:
dragover
dragenter
drop
ex: getElementById( “myBox” ).addEventListener( “dragover” , onOverBox );
[更新@2008.12.16]
關於更改Series上的label,修改InstanceCache宣告會更快更好:
使用Bar Chart 的時候,有個現象:
當Bar上頭的標籤文字太長,以至於無法放進畫面中,BarChart 會清除掉裡面的文字內容:
label.text = “”; (請見BarChart.as line 662)
好在,它只是清掉renderData的cache,並非真正的dataProvider內容(如果是,就糟了),也因此,我們有機會把這些文字回覆,逼它無論如何都要顯示,方法很簡單,你可以自訂一個BarSeries,請見如下程式碼。走訪dataprovider,把值塞回去給Label 實體即可,但請確保文字框夠大,或是把truncateToFit改成false,這樣就不會被裁切掉了。
[English version]
A Bar-Chart renders several series where those labels show up. If you have read source of BarChart.as, you would aware of one thing: If by checking the TextField width against remaining space, there is no enough space to place the label , the label text will be eliminated. ( see source: BarChart.as Line 662 ) However, I think Adobe team might do too much here so that even if you set explicit textField width with a very large number, it won’t work. Fortunately, BarChart itself clear the renderCache instead of dataprovider so that we could recover the text of each label. Here is an example: