Flex嵌套容器的生成次序
之前一直没在意父容器和子容器各自的生成次序,知道在项目中遇到一种case:初始化界面时父容器初始化的内容由子容器先初始化再触发,但是父容器必须在初始化时就已经加上了对子容器的监控。这就造成一对矛盾,既想先生成子容器又想先生成父容器。
先自己写段代码测试一下生成顺序,父容器
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:guoguo="*" layout="absolute" initialize="init()" creationComplete="created()">
<mx:Script>
<!--[CDATA[
public function init():void
{
trace("parents init");
}
public function created():void
{
trace("parents created");
}
]]-->
</mx:Script>
<guoguo:children />
</mx:Application>
子容器
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" initialize="init()" creationComplete="created()">
<mx:Script>
<!--[CDATA[
public function init():void
{
trace("child init");
}
public function created():void
{
trace("child created");
}
]]-->
</mx:Script>
</mx:Canvas>
debug下trace的结果为
child init
parents init
child created
parents created
所以他的次序是先初始化子容器再初始化父容器再完成子容器再完成父容器,说起来很拗口。貌似能解决我一开始的问题了,那就是分开写init和created,parent init时加监控,child created时加载数据,parents created再调用。理论上是可以的,但是我在项目中的情况有点特殊,因为要调用httpService,是异步执行。
再做一个实验,父容器中传参数
<guoguo:children username="doudou" />
子容器中代码改为
public var username:String ="xiaomaomao" ;
public function init():void
{
trace("child init" + username);
}
public function created():void
{
trace(&
相关文档:
/*Copyright (c) 2006 Adobe Systems Incorporated
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, m ......
Flex中控件组件一大堆,总结一下。
1.
用来布局的控件有 form、canvas、panel、box 等。 当然box 中又有很多了,有vbx、hbox、VDividedBox、HividedBox、Tile。 当然这些里面大体上又分为两种
一种是绝对布局、一种是相对布局(个人认为啊)。其中canvas 是只支持绝对布局的 form、box 只支持相对布局。而p ......
首先,申明本文是转载
http://blog.csdn.net/ivanmarkliu/archive/2009/07/08/4327570.aspx
,大家可以访问该链接,也可以直接阅读本文后续部分以了解
flex
事件。接下来简单谈下为何要转载此文及本人对此文的一些补充。
可以这样说 ......
转自:http://hi.baidu.com/wosinmaiken/blog/item/ee59f7a8f72604bdca130c24.html
/**ceil 向前(数轴向右)取整(返回值为Number)**/
trace(Math.ceil(10.4)); //11
trace(Math ......