construtctor和createchildren都是只调用一次,但有什么不同呢,如果写只被调用一次的代码,应该写到哪里好呢?
看了很多资料后,说是应该把子控件的初始化写到createchildren中。
为什么要这么做呢,因为FLEX的实现是这样做的,比如:
<VBox id="box1">
<VBox id=“box2” />
</VBox>
那么,FLEX自动把初始化 box2 的代码写到 box1 的createchildren中,所以我们最好也这么写,
符合一致性。
但为什么flex要这么做呢?
因为在construtctor中,有很多东西是得不到的,比如:parent等等。
具体在construtctor中能取得什么对象,在createchildren中能取得什么对象,还没仔细试,
请大家指教一下。
下面是关于flex启动过程的一些资料:
http://www.wietseveenstra.nl/blog/2007/02/understanding-the-flex-application-startup-event-order/
http://www.devbean.info/2011/03/understand_flex_4_comp_life_cycle_1/
http://blog.csdn.net/dante_k7/article/details/4275381