引用 http://www.actionscript.org/forums/showthread.php3?t=220154
var _container:Sprite = new Sprite();
//_container.addEventListener(Event.ADDED,onAdded);
//_container.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
function onAdded(e:Event):void {
trace("onAdded:",e);
}
function onAddedToStage(e:Event):void {
trace("onAddedToStage:",e);
}
addChild(_container);
var _sub:Sprite = new Sprite();
_sub.addEventListener(Event.ADDED,onAdded);
_sub.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
_container.addChild(_sub);
“ Basically added is for an object or any of its children being added to any display list, and added to stage is for an object (not including its children) being added to the active display list giving it access to stage.”
added对象自身或者其子对象被添加到任意的显示列表中[相当于有对象加到它其中或者它被加到其他对象中](比如container.addChild(sub),但是container不一定已经添加到舞台,即此时还是不可见的)【只要被addChild】
addedToStage表示对象自身(不包括子对象)被添加到可显示的显示列表,这样对象就可以访问到舞台。【即对象自身可以访问到舞台】
所以上例中是否先addChild(container)结果也很明显
var all:Sprite = new Sprite;
var container:Sprite = new Sprite;
var sub:Sprite = new Sprite;
container.addEventListener(Event.ADDED,onAdded);
container.addChild(sub);
all.addChild(container);
// 触发两次