沒怎么用過State, 據說Flex4中State有很大更新, 今天小用了下. 發現一個問題:
非Start State中的Component在Application Create complete后不能立即使用. 于是想到了之前常用的creationPolicy – 統統設置為ALL, 結果仍舊無濟于事.
解決方法: 設定組件itemCreationPolicy="immediate".
API:
Use the itemCreationPolicy property to specify the creation policy. The itemCreationPolicy property supports the following values:
deferred (默認值 – State活動時再創建)
Creates the component instance when it is first added by a change to the view state. This is the default value.
immediate (立即創建)
Creates the component instance at application startup.
- See: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf63611-7ffa.html
- 注意:
itemCreationPolicy and itemDestructionPolicy attributes must accompany either the includeIn or excludeFrom attribute.
組件必須已經使用includeIn /excludeFrom 屬性, 因此如果組件未設定顯示的State(可能是外部容器設定了), 又要在該組件上單獨使用itemCreationPolicy, 那就需要在該組件上先通過includeIn /excludeFrom 設定下要顯示/排除的State.
-
另: 與創建政策Create Policy對應的, 還有銷毀政策: itemDestructionPolicy
關于Flex4 State中文介紹可參見: http://swfever.com/?p=717
@import url(http://www.tkk7.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);