
Main Document Class
package com.brunomilitzer.framework
{
import flash.display.*;
import flash.events.*;
import com.brunomilitzer.events.StageEvent;
import com.brunomilitzer.framework.TopBg;
public class TopLevel extends MovieClip
{
public static var stage:Stage;
public static var root:DisplayObject;
public var stageAlign:StageAlign;
public var stageScaleMode:StageScaleMode;
private var stageEvent:StageEvent = new StageEvent();
private var background:TopBg;
public function TopLevel() {
TopLevel.stage = this.stage;
TopLevel.root = this;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.displayState = StageDisplayState.NORMAL;
stage.showDefaultContextMenu = false;
stage.addEventListener(Event.RESIZE, onStageResize);
stage.dispatchEvent(new Event(Event.RESIZE));
background = new TopBg(stageEvent.xWidth, stageEvent.yHeight);
}
private function onStageResize(event:Event):void {
if (stage.stageWidth < 980) {
stageEvent.xWidth = 980;
} else {
stageEvent.xWidth = stage.stageWidth;
}
if (stage.stageHeight < 600) {
stageEvent.yHeight = 600;
} else {
stageEvent.yHeight = stage.stageHeight;
}
if (preloader_mc != null) {
preloader_mc.x = (stageEvent.xWidth / 2) - (preloader_mc.width / 2);
preloader_mc.y = (stageEvent.yHeight / 2) - (preloader_mc.height / 2);
}
}
}
}
Background Class
package com.brunomilitzer.framework
{
import flash.display.*;
import flash.events.*;
public class TopBg extends MovieClip
{
private var stageWidth:Number;
private var stageHeight:Number;
public function TopBg(sW:Number, sH:Number) {
stageWidth = sW;
stageHeight = sH;
}
}
}If you would like to make a comment, please fill out the form below.
Recent Comments