Following Flash 9 docs it's realtive easy to know that you need to access the stage property of a DisplayObject to manage the stageScaleMode
//Timeline code
var child:Sprite = new Sprite();
child.name = "stageMode"
child.addEventListener(Event.ADDED_TO_STAGE, stageListener);
this.addChild(child);
function stageListener(evt:Event):void{
var t:Sprite = Sprite(this.getChildByName("stageMode"))
t.stage.scaleMode=StageScaleMode.SHOW_ALL;
}
But in Flex it becomes a little tricky because you can't add a Sprite to Stage, only objects that extends UIComponent, so you should do the same, but using some dummy component, say a Canvas
//init function called from application creationComplete event
function init():void{
var child:Sprite = new Canvas();
child.name = "stageMode"
child.addEventListener(Event.ADDED_TO_STAGE, stageListener);
addChild(child);
}
private function stageListener(evt:Event):void{
var child = getChildByName("stageController")
child.stage.scaleMode=StageScaleMode.SHOW_ALL;
}
Tryng to set inmediatly the scaleMode after the element is added to the displayList will trigger an error similar to this:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Jorge