沒怎么用過State, 據(jù)說Flex4中State有很大更新, 今天小用了下. 發(fā)現(xiàn)一個問題:
非Start State中的Component在Application Create complete后不能立即使用. 于是想到了之前常用的creationPolicy – 統(tǒng)統(tǒng)設(shè)置為ALL, 結(jié)果仍舊無濟(jì)于事.
解決方法: 設(shè)定組件itemCreationPolicy="immediate".
API:
Use the itemCreationPolicy property to specify the creation policy. The itemCreationPolicy property supports the following values:
deferred (默認(rèn)值 – State活動時再創(chuàng)建)
Creates the component instance when it is first added by a change to the view state. This is the default value.
immediate (立即創(chuàng)建)
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.
組件必須已經(jīng)使用includeIn /excludeFrom 屬性, 因此如果組件未設(shè)定顯示的State(可能是外部容器設(shè)定了), 又要在該組件上單獨使用itemCreationPolicy, 那就需要在該組件上先通過includeIn /excludeFrom 設(shè)定下要顯示/排除的State.
-
另: 與創(chuàng)建政策Create Policy對應(yīng)的, 還有銷毀政策: itemDestructionPolicy
關(guān)于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);