1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: |
package{
import flash.display.*; import flash.events.*; [SWF(width = 500,height = 250,backgroundColor = 0xEEEEEE)] public class Main extends MovieClip{ private var arUnit:Array; public function Main(){ this.arUnit = new Array(); this.arUnit.push(new MyTopLeft(50,50)); this.arUnit.push(new MyTopCenter(50,50)); this.arUnit.push(new MyTopRight(50,50)); this.arUnit.push(new MyBottomLeft(50,50)); this.arUnit.push(new MyBottomCenter(50,50)); this.arUnit.push(new MyBottomRight(50,50)); for(var i:int=0;i<this.arUnit.length;i++){ this.addChild(this.arUnit[i]); } this.stage.scaleMode = StageScaleMode.NO_SCALE; this.stage.addEventListener(Event.RESIZE, this.resizeHandler); stage.align = StageAlign.TOP_LEFT; this.resizeHandler(); } private function resizeHandler(event:Event = null):void{ for(var i=0;i<this.arUnit.length;i++){ this.arUnit[i].OnResize(); } } } } import flash.display.*; class MyTopLeft extends Shape{ public function MyTopLeft(nWidth:int,nHeight:int){ this.graphics.beginFill(0x000000); this.graphics.drawRect(0,0,nWidth,nHeight); this.graphics.endFill(); } public function OnResize():void{} } class MyTopCenter extends MyTopLeft{ public function MyTopCenter(nWidth:int,nHeight:int){ super(nWidth,nHeight); } override public function OnResize():void{ this.x = Math.floor((this.stage.stageWidth - this.width) * 0.5); } } class MyTopRight extends MyTopLeft{ public function MyTopRight(nWidth:int,nHeight:int){ super(nWidth,nHeight); } override public function OnResize():void{ this.x = (this.stage.stageWidth - this.width); } } class MyBottomLeft extends MyTopLeft{ public function MyBottomLeft(nWidth:int,nHeight:int){ super(nWidth,nHeight); } override public function OnResize():void{ this.y = (this.stage.stageHeight - this.height); } } class MyBottomCenter extends MyTopLeft{ public function MyBottomCenter(nWidth:int,nHeight:int){ super(nWidth,nHeight); } override public function OnResize():void{ this.x = Math.floor((this.stage.stageWidth - this.width) * 0.5); this.y = (this.stage.stageHeight - this.height); } } class MyBottomRight extends MyTopLeft{ public function MyBottomRight(nWidth:int,nHeight:int){ super(nWidth,nHeight); } override public function OnResize():void{ this.x = (this.stage.stageWidth - this.width); this.y = (this.stage.stageHeight - this.height); } } |