The way I usually handle this is I have a custom class that extends Sprite
that listens for Event.RESIZE
on the stage and then override that function in each class since usually I don't have a single solution for how I want display objects to act on resize. You could possibly modify this to work for your purposes.
public class ResizeableSprite extends Sprite {
public function ResizeableSprite()
{
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage, false, 0, true);
}
protected function onResize(eventObject:Event):void {
// override
}
protected function onAddedToStage(eventObject:Event):void {
root.stage.addEventListener(Event.RESIZE, onResize, false, 0, true);
}
protected function onRemovedFromStage(eventObject:Event):void {
root.stage.removeEventListener(Event.RESIZE, onResize);
}
public function destroy():void {
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}
}