In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

本格的超高速もぐら叩きゲームクラシック

/**
 * Copyright o8que ( http://wonderfl.net/user/o8que )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wb1a
 */

package {
    import com.bit101.components.PushButton;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.text.TextField;
    import flash.utils.Timer;
//    import ore.orelib.commons.Labeler;
    
    [SWF(width = "465", height = "465", frameRate = "30", backgroundColor = "0x000000")]
    public class Main extends Sprite {
        private var _timer:Timer;
        private var _time:int;
        private var _timeLabel:TextField;
        private var _instruction:Sprite;
        
        public function Main() {
            drawBackground();
            
            _timer = new Timer(1000);
            _timer.addEventListener(TimerEvent.TIMER, onTimer);
            _time = 30;
            
            var labeler:Labeler = new Labeler().fontColor(0xFFFFFF).fontSize(20).pos(10, 10).size(445, 100);
            addChild(labeler.build("Score :   0"));
            addChild(_timeLabel = labeler.align(Labeler.RIGHT).build("Time : 30"));
            
            addChild(_instruction = createInstruction());
        }
        
        private function drawBackground():void {
            graphics.beginFill(0x224422);
            graphics.drawRect(0, 0, 465, 465);
            graphics.endFill();
            
            for (var row:int = 0; row < 4; row++) {
                for (var col:int = 0; col < 4; col++) {
                    graphics.beginFill(0x884400);
                    graphics.drawEllipse(13 + 113 * col, 93 + 93 * row, 100, 80);
                    graphics.endFill();
                    
                    graphics.beginFill(0x220000);
                    graphics.drawEllipse(23 + 113 * col, 98 + 93 * row, 80, 60);
                    graphics.endFill();
                }
            }
        }
        
        private function createInstruction():Sprite {
            var result:Sprite = new Sprite();
            result.graphics.beginFill(0x000000, 0.8);
            result.graphics.drawRect(0, 0, 465, 465);
            result.graphics.endFill();
            
            result.addChild(
                new Labeler().align(Labeler.CENTER).autoSize(Labeler.CENTER, Labeler.MIDDLE)
                .fontColor(0xFFFFFF).fontSize(20).size(465, 445)
                .build("30秒でできるだけ多くのもぐらを叩け!\nもぐらを叩くにはもぐらをクリック!!")
            );
            new PushButton(result, 182, 280, "start!", startGame);
            
            return result;
        }
        
        private function startGame(event:MouseEvent = null):void {
            removeChild(_instruction);
            _timer.start();
        }
        
        private function onTimer(event:TimerEvent):void {
            _time--;
            _timeLabel.text = "Time : " + _time;
        }
    }
}
//package ore.orelib.commons {
    import flash.geom.Point;
    import flash.text.AntiAliasType;
    import flash.text.GridFitType;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
    
    //public 
    class Labeler {
        private var _hAlign:String;
        private var _autoSize:String;
        private var _vAlign:String;
        private var _background:Boolean;
        private var _backgroundColor:uint;
        private var _filters:Array;
        private var _fontName:String;
        private var _sharpness:Number;
        private var _thickness:Number;
        private var _fontColor:uint;
        private var _fontSize:int;
        private var _position:Point;
        private var _selectable:Boolean;
        private var _size:Point;
        private var _wordWrap:Boolean;
        
        public static const NONE:String = "none";
        public static const LEFT:String = "left";
        public static const CENTER:String = "center";
        public static const RIGHT:String = "right";
        public static const TOP:String = "top";
        public static const MIDDLE:String = "middle";
        public static const BOTTOM:String = "bottom";
        private static const DEVICE_FONT:String = "_sans";
        
        public function Labeler() {
            _hAlign = TextFormatAlign.LEFT;
            _autoSize = TextFieldAutoSize.NONE;
            _vAlign = Labeler.TOP;
            _background = false;
            _backgroundColor = 0xFFFFFF;
            _filters = [];
            _fontName = Labeler.DEVICE_FONT;
            _sharpness = _thickness = 0;
            _fontColor = 0x000000;
            _fontSize = 12;
            _position = new Point(0, 0);
            _size = new Point(100, 100);
            _selectable = _wordWrap = false;
        }
        
        public function align(value:String = Labeler.LEFT):Labeler {
            switch(value) {
                case Labeler.CENTER: { _hAlign = TextFormatAlign.CENTER; break; }
                case Labeler.RIGHT: { _hAlign = TextFormatAlign.RIGHT; break; }
                case Labeler.LEFT: default: { _hAlign = TextFormatAlign.LEFT; break; }
            }
            return this;
        }
        
        public function autoSize(horizontal:String = Labeler.NONE, vertical:String = Labeler.TOP):Labeler {
            switch(horizontal) {
                case Labeler.LEFT: { _autoSize = TextFieldAutoSize.LEFT; break; }
                case Labeler.CENTER: { _autoSize = TextFieldAutoSize.CENTER; break; }
                case Labeler.RIGHT: { _autoSize = TextFieldAutoSize.RIGHT; break; }
                case Labeler.NONE: default: { _autoSize = TextFieldAutoSize.NONE; break; }
            }
            _vAlign = vertical;
            return this;
        }
        
        public function background(enabled:Boolean = true, color:uint = 0xFF0000):Labeler { _background = enabled; _backgroundColor = color; return this; }
        public function filters(value:Array):Labeler { _filters = value; return this; }
        public function font(name:String, sharpness:Number = 0, thickness:Number = 0):Labeler { _fontName = name; _sharpness = sharpness; _thickness = thickness; return this; }
        public function fontColor(value:uint):Labeler { _fontColor = value; return this; }
        public function fontSize(value:int):Labeler { _fontSize = value; return this; }
        public function offset(x:Number, y:Number):Labeler { _position.offset(x, y); return this; }
        public function pos(x:Number, y:Number):Labeler { _position.setTo(x, y); return this; }
        public function selectable(enabled:Boolean = true):Labeler { _selectable = enabled; return this; }
        public function size(width:Number, height:Number):Labeler { _size.setTo(width, height); return this; }
        public function wordWrap(enabled:Boolean = true):Labeler { _wordWrap = enabled; return this; }
        
        public function build(text:String):TextField {
            var result:TextField = new TextField();
            result.x = _position.x; result.width = _size.x; result.height = _size.y;
            result.autoSize = _autoSize;
            result.background = _background; result.backgroundColor = _backgroundColor;
            result.filters = _filters;
            result.mouseEnabled = result.selectable = _selectable;
            result.wordWrap = _wordWrap;
            result.defaultTextFormat = new TextFormat(_fontName, _fontSize, _fontColor, null, null, null, null, null, _hAlign);
            if (_fontName != Labeler.DEVICE_FONT) {
                result.embedFonts = true;
                result.antiAliasType = AntiAliasType.ADVANCED;
                result.gridFitType = (_hAlign == TextFormatAlign.LEFT) ? GridFitType.PIXEL : GridFitType.SUBPIXEL;
                result.sharpness = _sharpness; result.thickness = _thickness;
            }
            result.text = text;
            switch(_vAlign) {
                case Labeler.MIDDLE: { result.y = _position.y + (_size.y - result.height) / 2; break; }
                case Labeler.BOTTOM: { result.y = _position.y + (_size.y - result.height); break; }
                case Labeler.TOP: default: { result.y = _position.y; break; }
            }
            return result;
        }
    }
//}