为了保障原创作者在本站发表文章的利益, 并维护本站原创的精神, 特声明: RIAShanghai对有以下任何情况之一的文章将不通知作者并直接进行快意删除:
- 非原创, 或者原创但一文多发;
- 各种形式的广告与吹擂;
- 不符合本站文章格式.
欢迎各位读者监督. 谢谢合作. 另: 作为Adobe正式的UG, 我们将把Adobe不定期分发的软件,书籍及各种纪念品赠送给发文活跃的作者, 共同进步.
When creating a custom UI component, one should remember that the UI component does need time (sometimes very long time) to complete the construction. I refer the state between the constructor is called and the UI is fully created completely as the intermediate state, i.e., a transient state.
You should take extra caution on intermediate state when you create complex or composite UI components. One reason is that many functions do not work as expected during this state. For example, ListBase.listItems() should return all the renders, but it might return zero or few of the renders in this state.
Recently, I encountered a very strange problem with a custom Tree. This custom tree is able to automatically resize so the ugly scroll bar will never show up. The problem is that sometimes this tree shows up in the UI but many times it does not! The reason? The auto resize function relies on transient internal variables that change during the intermediate state. The solution? disable the auto resize function until the tree creation is done. You can always listen to creationComplete event to detect when the UI is fully constructed. I find that using visible property is easier:
protected function performAutoResize(event:Event = null):void {
// Bugfix: in the intermediate state - auto resize incremented by -20 till 0.
if(! visible) { // if not visble, do nothing.
return;
}
... // the resize magic goes here
}