// // Licensed under the MIT License // // Copyright (C) 2008 TAKANAWA Tomoaki (http://nutsu.com) and // Spark project (www.libspark.org) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // package snapfit.display { import flash.display.DisplayObject; import flash.display.MovieClip; import flash.display.Stage; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.display.StageQuality; import flash.geom.Rectangle; import snapfit.events.adapters.FStageAdapter; /** * ... * @author nutsu */ public class FStage { private static var __initialized__:Boolean = false; private static var _stage:Stage; private static var _adapter:FStageAdapter; /** * init */ public static function initialize( stage_:Stage ):Boolean { if( stage_ is Stage ) { _stage = stage_; if ( _adapter ) _adapter.dispatcher = _stage; else _adapter = new FStageAdapter( _stage ); __initialized__ = true; return true; } else { return false; } } public static function get isInitialized():Boolean { return __initialized__; } //------------------------------------------------------------------------------------ // STAGE PROP //------------------------------------------------------------------------------------ public static function get stage():Stage { if ( !__initialized__ ) throw new Error( "FStage is not initialized." ); return _stage; } public static function get event():FStageAdapter { return _adapter; } //------------------------------------------------------------------------------------ ALIGN /** * align */ public static function get align():String { return stage.align; } public static function set align( value:String ):void { stage.align = value; } public static function alignTopLeft():void { stage.align = StageAlign.TOP_LEFT } public static function alignTop():void { stage.align = StageAlign.TOP; } public static function alignBottom():void { stage.align = StageAlign.BOTTOM; } public static function alignCenter():void { stage.align = ""; } //------------------------------------------------------------------------------------ SCALE /** * scaleMode */ public static function get scaleMode():String { return stage.scaleMode; } public static function set scaleMode( value:String ):void { stage.scaleMode = value; } public static function scaleNo():void { stage.scaleMode = StageScaleMode.NO_SCALE; } public static function scaleExactFit():void { stage.scaleMode = StageScaleMode.EXACT_FIT; } public static function scaleShowAll():void { stage.scaleMode = StageScaleMode.SHOW_ALL; } public static function scaleNoBorder():void { stage.scaleMode = StageScaleMode.NO_BORDER; } //------------------------------------------------------------------------------------ GEOM /** * Geom */ public static function get rect():Rectangle { return new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight ); } public static function get width():Number { return stage.stageWidth; } public static function get height():Number { return stage.stageHeight; } //------------------------------------------------------------------------------------ Quality /** * StageQuality を LOW に設定します. */ public static function QLow():void { stage.quality = StageQuality.LOW; } /** * StageQuality を MEDIUM に設定します. */ public static function QMedium():void { stage.quality = StageQuality.MEDIUM; } /** * StageQuality を HIGH に設定します. */ public static function QHigh():void { stage.quality = StageQuality.HIGH; } /** * StageQuality を BEST に設定します. */ public static function QBest():void { stage.quality = StageQuality.BEST; } } }