package com.vw { import flash.display.* import com.vw.*; import flash.events.*; import flash.utils.*; import flash.geom.Rectangle; public class MainScreen extends MovieClip { public var controls:MovieClip; public var viewPort:MovieClip; public var imageCanvas:MovieClip; public var navigator:MovieClip; public function MainScreen() { // Empty constructor: } public function init() :void { App.Trace(this + "::init()"); controls.init(); stage.align = StageAlign.TOP_LEFT; stage.addEventListener(Event.RESIZE, handle_resize); setTimeout(function():void { handle_resize(new Event("dummy_event")); imageCanvas.init(); navigator.init(); },1); controls.addEventListener("zoomLevel_changed", zoomLevel_changed); } private function zoomLevel_changed(e:Event) :void { dispatchEvent(e); } private function handle_resize(e:Event) :void { App.Trace("stage.stageWidth: " + stage.stageWidth); viewPort.width = stage.stageWidth; viewPort.height = stage.stageHeight - controls.height; viewPort.y = 60; viewPort.x = (stage.stageWidth / 2) - (viewPort.width / 2); var orig:Object = { width: 900, height: 550 }; if( x > 0 ) x = 0; // Move the controls so that they are centered: controls.x = (stage.stageWidth / 2) - (controls.width / 2); if( controls.x < 0 ) controls.x = 0; // Move the navigator so that it is bottom-right justified: navigator.x = viewPort.width - navigator.width - 20; navigator.y = viewPort.height - navigator.height + controls.height - 20; // Move the log too: App.log.x = 20; App.log.y = viewPort.height - App.log.height + controls.height - 20; dispatchEvent( new Event("resized")); } } }