My understanding was order listeners were added.
In this example, offstage sprite was added last, and events are handled last:
MAIN: Entering frame 2
Root node: 2571 - Enter Frame
Child 1: 2571 - Enter Frame
Child 2: 2571 - Enter Frame
Offstage child: 2571 - Enter Frame
Root node: 2574 - Frame Constructed
Child 1: 2574 - Frame Constructed
Child 2: 2574 - Frame Constructed
Offstage child: 2574 - Frame Constructed
Root node: 2574 - Exit Frame
Child 1: 2574 - Exit Frame
Child 2: 2574 - Exit Frame
Offstage child: 2574 - Exit Frame
Root node: 2574 - Render
Child 1: 2574 - Render
Child 2: 2574 - Render
In this example, offstage sprite was added first, and events are handled first:
MAIN: Entering frame 2
Root node: 2334 - Enter Frame
Offstage child: 2334 - Enter Frame
Child 1: 2334 - Enter Frame
Child 2: 2334 - Enter Frame
Root node: 2336 - Frame Constructed
Offstage child: 2336 - Frame Constructed
Child 1: 2336 - Frame Constructed
Child 2: 2336 - Frame Constructed
Root node: 2336 - Exit Frame
Offstage child: 2336 - Exit Frame
Child 1: 2336 - Exit Frame
Child 2: 2336 - Exit Frame
Root node: 2336 - Render
Child 1: 2336 - Render
Child 2: 2336 - Render
Example program to isolate behavior:
Main Application
package {
import flash.display.Sprite;
import flash.events.Event;
public class Main extends DisplayNotifier {
protected var frameNumber:uint = 0;
public function Main() {
super("Root node", 0, true);
stage.frameRate = 1;
// add a child to the display list
addChild(new DisplayNotifier("Child 1", 1, true));
// add a child to that child
(getChildAt(0) as Sprite).addChild(new DisplayNotifier("Child 2", 2, true));
// add a child off the diplay list
var offstage:Sprite = new DisplayNotifier("Offstage child", 0, false);
}
override protected function enterFrameHandler(event:Event):void {
trace("MAIN: Entering frame " + ++frameNumber);
super.enterFrameHandler(event);
stage.invalidate();
}
}
}
DisplayNotifier - Utility display object to trace events
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.getTimer;
public class DisplayNotifier extends Sprite {
protected var displayName:String;
protected var depth:uint = 0;
protected var onStage:Boolean = false;
public function DisplayNotifier(displayName:String,
depth:uint,
onStage:Boolean) {
super();
this.displayName = displayName;
this.depth = depth;
this.onStage = onStage;
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
addEventListener(Event.FRAME_CONSTRUCTED, frameConstructedHandler);
addEventListener(Event.EXIT_FRAME, exitFrameHandler);
addEventListener(Event.RENDER, renderHandler);
}
protected function enterFrameHandler(event:Event):void {
trace(toString() + " - Enter Frame");
}
protected function frameConstructedHandler(event:Event):void {
trace(toString() + " - Frame Constructed");
}
protected function renderHandler(event:Event):void {
trace(toString() + " - Render");
}
protected function exitFrameHandler(event:Event):void {
trace(toString() + " - Exit Frame");
}
override public function toString():String {
return (DisplayNotifier.indent(depth) + displayName + ": " + getTimer());
}
protected static function indent(depth:uint):String {
var n:uint = depth;
var s:String = "";
while (n-- > 0) {
s += '\t';
}
return s;
}
}
}