views:

102

answers:

1

I am creating an AIR nativeWindow. I am adding two children, an HTMLLoader and a Sprite. The child Sprite has two children, a TextField and a Sprite that will be used to draw. I have set stage.scaleMode = "noScale" and stage.align = "TL", which the HTMLLoader seems to respect. However, the child Sprite scales its children whenever I set a height.

public function BaseWindow(){
 var winInit:NativeWindowInitOptions = new NativeWindowInitOptions();
 winInit.type = NativeWindowType.NORMAL;
 winInit.resizable = false;
 winInit.maximizable = false;
 super(winInit);

 //native window
 activate();
 alwaysInFront = true;
 addEventListener(Event.CLOSING, onClosing, false, 0, true);
 stage.scaleMode = StageScaleMode.NO_SCALE;
 stage.align = StageAlign.TOP_LEFT;
 width = DEFAULT_WIDTH;
 height = DEFAULT_HEIGHT;

 //html loader
 _html = new HTMLLoader();
 stage.addChild(_html);  
 _html.width = DEFAULT_WIDTH;
 _html.height = DEFAULT_HEIGHT;
 _html.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
 _html.addEventListener(Event.LOCATION_CHANGE, onLocationChange, false, 0, true);   

 //distractor
 distractor = new Distractor();
 stage.addChild(distractor);
 distractor.height = 30;   

 urlVars = new URLVariables();
 req = new URLRequest();
 req.data = urlVars;
}

How do I prevent the distractor Sprite from scaling its children?

A: 

all children of a Sprite are scaled with the parent, the only way of doing this is to work out the scale factor then apply the inverse of it to all children (see "applications" section of this article for an example), but then the simplest idea is probably to make the thing you want to scale (presumably a background) a sibling of the text field rather than a parent then scale it separately.

shortstick
So how does flex work around this. UIComponent is a descendant of Sprite. Does it handle all of this scaling of children during the updateDisplayList() phase?
Jeff
by the liveDocs ( http://livedocs.adobe.com/flex/3/langref/mx/core/UIComponent.html#updateDisplayList%28%29 ) it states that the updateDisplay is where it applies move() and sets setActualSize() on children.By overriding the method you can either cancel completely, or set specific children to scale without the others being affected, think of using 'background.setActualSize()' as opposed to all children.
shortstick