root/as3/snapfit/trunk/src/snapfit/display/FStage.as

リビジョン 2161, 5.1 kB (コミッタ: nutsu, コミット時期: 3 年 前)

パス上の長さから位置だしとか

Line 
1 //
2 // Licensed under the MIT License
3 //
4 // Copyright (C) 2008  TAKANAWA Tomoaki (http://nutsu.com) and
5 //                                         Spark project (www.libspark.org)
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 // THE SOFTWARE.
24 //
25
26 package snapfit.display
27 {
28         import flash.display.DisplayObject;
29         import flash.display.MovieClip;
30         import flash.display.Stage;
31         import flash.display.StageAlign;
32         import flash.display.StageScaleMode;
33         import flash.display.StageQuality;
34         import flash.geom.Rectangle;
35         import snapfit.events.adapters.FStageAdapter;
36        
37         /**
38         * ...
39         * @author nutsu
40         */
41         public class FStage
42         {
43                 private static var __initialized__:Boolean = false;
44                 private static var _stage:Stage;
45                 private static var _adapter:FStageAdapter;
46                
47                 /**
48                  * init
49                  */
50                 public static function initialize( stage_:Stage ):Boolean
51                 {
52                         if( stage_ is Stage )
53                         {
54                                 _stage = stage_;
55                                 if ( _adapter )
56                                         _adapter.dispatcher = _stage;
57                                 else
58                                         _adapter = new FStageAdapter( _stage );
59                                 __initialized__ = true;
60                                 return true;
61                         }
62                         else
63                         {
64                                 return false;
65                         }
66                 }
67                
68                 public static function get isInitialized():Boolean
69                 {
70                         return __initialized__;
71                 }
72                
73                 //------------------------------------------------------------------------------------
74                 //      STAGE PROP
75                 //------------------------------------------------------------------------------------
76                
77                 public static function get stage():Stage
78                 {
79                         if ( !__initialized__ ) throw new Error( "FStage is not initialized." );
80                         return _stage;
81                 }
82                
83                 public static function get event():FStageAdapter
84                 {
85                         return _adapter;
86                 }
87                
88                 //------------------------------------------------------------------------------------ ALIGN
89                 /**
90                  * align
91                  */
92                 public static function get align():String { return stage.align;  }
93                 public static function set align( value:String ):void
94                 {
95                         stage.align = value;
96                 }
97                
98                 public static function alignTopLeft():void
99                 {
100                         stage.align = StageAlign.TOP_LEFT
101                 }
102                
103                 public static function alignTop():void
104                 {
105                         stage.align = StageAlign.TOP;
106                 }
107                
108                 public static function alignBottom():void
109                 {
110                         stage.align = StageAlign.BOTTOM;
111                 }
112                
113                 public static function alignCenter():void
114                 {
115                         stage.align = "";
116                 }
117                
118                 //------------------------------------------------------------------------------------ SCALE
119                 /**
120                  * scaleMode
121                  */
122                 public static function get scaleMode():String { return stage.scaleMode;  }
123                 public static function set scaleMode( value:String ):void
124                 {
125                         stage.scaleMode = value;
126                 }
127                
128                 public static function scaleNo():void
129                 {
130                         stage.scaleMode = StageScaleMode.NO_SCALE;
131                 }
132                
133                 public static function scaleExactFit():void
134                 {
135                         stage.scaleMode = StageScaleMode.EXACT_FIT;
136                 }
137                
138                 public static function scaleShowAll():void
139                 {
140                         stage.scaleMode = StageScaleMode.SHOW_ALL;
141                 }
142                
143                 public static function scaleNoBorder():void
144                 {
145                         stage.scaleMode = StageScaleMode.NO_BORDER;
146                 }
147                
148                 //------------------------------------------------------------------------------------ GEOM
149                
150                 /**
151                  * Geom
152                  */
153                 public static function get rect():Rectangle
154                 {
155                         return new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight );
156                 }
157                 public static function get width():Number  { return stage.stageWidth; }
158                 public static function get height():Number { return stage.stageHeight; }
159                
160                 //------------------------------------------------------------------------------------ Quality
161                
162                 /**
163                  * StageQuality を LOW に設定します.
164                  */
165                 public static function QLow():void
166                 {
167                         stage.quality = StageQuality.LOW;
168                 }
169                
170                 /**
171                  * StageQuality を MEDIUM に設定します.
172                  */
173                 public static function QMedium():void
174                 {
175                         stage.quality = StageQuality.MEDIUM;
176                 }
177                
178                 /**
179                  * StageQuality を HIGH に設定します.
180                  */
181                 public static function QHigh():void
182                 {
183                         stage.quality = StageQuality.HIGH;
184                 }
185                
186                 /**
187                  * StageQuality を BEST に設定します.
188                  */
189                 public static function QBest():void
190                 {
191                         stage.quality = StageQuality.BEST;
192                 }
193         }
194        
195 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。