forked from: 周辺視野拡大トレーニング

by tepe forked from 周辺視野拡大トレーニング (diff: 357)
♥0 | Line 717 | Modified 2014-10-09 17:25:49 | MIT License
play

ActionScript3 source code

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

// forked from tepe's 周辺視野拡大トレーニング
package {
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import flash.net.*;
    import caurina.transitions.Tweener;
    public class FlashTest extends Sprite {
        private var checkNum:int = 1;
        private var txt:TextField = new TextField();
        private var panelNum:int;
        private var panelList:Array;
        private var numList:Array;
        private var panelMain:Sprite = new Sprite();
        private var stTime:Date;
        private var prevTime:Date;
        
        private var level:int;
        //private var exp:int;
        private var bestScore:int;//ベストスコア
        private var score:int;//スコア
        private var combo:int;//コンボ数
        private var retryCnt:int;//リトライ回数
        private var saveData:Object = new Object();
        
        private var scoreCnt:int;//表示されるポイント
        private var expCnt:int;
        private var save:SaveData;
        private var targetNum:panel;
           
        public function FlashTest() {
            // write as3 code here..
            targetNum = new panel();
            targetNum.x = (455/2)-25;
            targetNum.y = 420;
            targetNum.scaleX = targetNum.scaleY = 0.7;
            //addChild(targetNum);
            save = new SaveData("my_data");
            save.clear();
            if(save.length==0)initSaveData();
            saveData = save.data;
            var format:TextFormat = new TextFormat();
            format.align = TextFormatAlign.LEFT;    // 整列
            format.font = "MS ゴシック";        // フォント名
            format.size = 30;        // 文字のポイントサイズ
            
            txt.defaultTextFormat = format;
            addChild(txt);
            txt.width =400;
            addChild(panelMain);
            
            setStartPanel();//初期画面
            
            var menu:ActionBtn = new ActionBtn();
                menu.x = -120;
                menu.y = 20 ;
                addChild(menu);
                menu.init({id: 1, label: "トレーニング終了", width: 80});
                menu.addEventListener(MouseEvent.CLICK, function():void{
                    //setPanel(4+Math.random()*11,3+Math.random()*4);
                    //gameStart();
                    //stage.displayState = StageDisplayState.NORMAL;
                    setStartPanel();
                    
                });
             
            var menu2:ActionBtn = new ActionBtn();
                menu2.x = 600 ;
                menu2.y = 20 ;
                addChild(menu2);
                menu2.init({id: 2, label: "リセット", width: 80});
                menu2.addEventListener(MouseEvent.CLICK,f2);


        }
        
        private var gameLevel:int = 1;
        private function f2(e:MouseEvent=null):void{
            
            var a:int = 6 + gameLevel;
            var b:int = a-((a-2)*Math.random());
            if(13<b)b=13;
            var c:int = a-b+2;
            if(5<c)c=5;
            setPanel(b,c);
            //setPanel(4+Math.random()*11,3+Math.random()*4);
            gameStart();
            
            gameLevel++;
            
        }

        
        //セーブデータ初期化
        private function initSaveData():void{
            var obj:Object = new Object();
            var exp:int=0;
            var level:int=1;
            obj["exp"]=0;
            obj["level"]=level;
            
            save.data=obj;
        }

        
        //スタート画面表示
        private function setStartPanel():void{
            while(0<this.numChildren)this.removeChildAt(0); 
            while(0<panelMain.numChildren)panelMain.removeChildAt(0);
            stage.displayState = StageDisplayState.NORMAL;
            txt.x = 40;
            txt.y = 150;
            txt.text = "周辺視野拡大トレーニング\n\n"+"    クリック";            
            txt.selectable = false;
            addChild(txt);
            txt.width =400;
            addChild(panelMain);
            addEventListener(MouseEvent.MOUSE_UP,f1);

        }
        
        //全画面
        private function f1(e:MouseEvent):void{
            
            
            var menu:ActionBtn = new ActionBtn();
                menu.x = -120;
                menu.y = 20 ;
                addChild(menu);
                menu.init({id: 1, label: "トレーニング終了", width: 80});
                menu.addEventListener(MouseEvent.CLICK, function():void{
                    //setPanel(4+Math.random()*11,3+Math.random()*4);
                    //gameStart();
                    //stage.displayState = StageDisplayState.NORMAL;
                    setStartPanel();
                    
                });
             
            var menu2:ActionBtn = new ActionBtn();
                menu2.x = 600 ;
                menu2.y = 20 ;
                addChild(menu2);
                menu2.init({id: 2, label: "リセット", width: 80});
                menu2.addEventListener(MouseEvent.CLICK,f2);

            
            gameLevel=1;
            txt.x = 0;
            txt.y = 0;
            stage.displayState = StageDisplayState.FULL_SCREEN;
            //setPanel(4+Math.random()*11,3+Math.random()*4);
            expCnt = saveData["exp"];
            //gameStart();
            f2();
        }


        
        private function setPanel(sizeX:int,sizeY:int):void{
            removeEventListener(MouseEvent.MOUSE_UP,f1);
            while(0<panelMain.numChildren)panelMain.removeChildAt(0);
            panelMain.y = 40;
            //panelMain.x = (455/2)-sizeX*26;
            retryCnt=0;
            bestScore=0;
            
            var list:Array = new Array();
            panelList = null;
            panelList = new Array();
            for(var i:int=0;i<sizeY;i++){
                for(var j:int=0;j<sizeX;j++){
                    var p1:panel = new panel();
                    p1.text = genText(2,5);
                    p1.x = (p1.width+1)*j;
                    p1.y = (p1.height+1)*i;
                    p1.addEventListener(MouseEvent.MOUSE_DOWN,onClick);
                    panelMain.addChild(p1);
                    list.push(p1);
                    panelList.push(p1);
                    
                    
                } 
            }
            //スケールの調整
            if(750<panelMain.width){ 
                var scale:Number = (750/panelMain.width);
                panelMain.scaleX = panelMain.scaleY = scale;
            }
            else panelMain.scaleX = panelMain.scaleY = 1;
            
            panelMain.x = (455/2) - (panelMain.width/2);
            
            panelNum=sizeX*sizeY;
            var cnt:int=1;
            numList = null;
            numList = new Array();
            while(0<list.length){
                var a:int=(list.length)*Math.random();
                //txt.text+=a.toString()+" ";
                //var p:panel = list.pop(a);
                //list[a].text = cnt.toString();
                //list[a].text = Math.round(Math.random()*1000).toString();
                //list[a].text = genText();
                numList.push(list[a]);
                list.splice(a,1);
                //delete list[a];
                cnt++;
            }
        }
        
        //ランダムな文字列を生成
        private function genText(len:int=3,_ptn:int=14):String{
            var str:String = new String();
            for(var i:int=0;i<len;i++){
                var ptn:int = Math.random()*_ptn;
                
                switch(ptn){
                    //case 0:
                    //str+="●";
                    //break;
                        
                    case 0:
                    str+="○";
                    break;
                    
                    case 1:
                    str+="△";
                    break;
                    
                    //case 3:
                    //str+="★";
                    //break;
                    
                    case 2:
                    str+="▽";
                    break;
                    
                    //case 5:
                    //str+="◆";
                    //break;
                    
                    case 3:
                    str+="◇";
                    break;
                    
                    //case 7:
                    //str+="■";
                    //break;
                    
                    case 4:
                    str+="□";
                    break;
                    
                    case 5:
                    str+="◎";
                    break;
                    
                    //case 10:
                    //str+="▲";
                    //break;
                    
                    case 6:
                    
                    str+="☆";
                    break;
                    
                    //case 12:
                    //str+="▼";
                    //break;
                    
                    case 7:
                    str+="♪";
                    break;
                    
                    default:
                    str+="○";
                    
                    break;
                }

            }
            return str;
        }

        


        //ゲーム開始
        private function gameStart():void{            
            checkNum=1;
            for(var i:int=0;i<panelList.length;i++){
                panelList[i].alpha = 1.0;
            }
            score = 0;
            scoreCnt=0;
            combo=0;
            //txt.text = "game start";
            txt.text = "Lv:"+saveData["level"].toString()+"  score:"+scoreCnt.toString();
            stTime = new Date();
            prevTime = new Date();
            addEventListener(Event.ENTER_FRAME,onFrame);
            
            addChild(targetNum);
            targetNum.text = numList[0].text;
            
        }

        //パネルクリック
        private function onClick(e:MouseEvent):void{
                        
            if(e.currentTarget.text == numList[checkNum-1].text){//正解クリック
                var now:Date = new Date();
                var time:int = now.valueOf()-prevTime.valueOf();
                if(time<1000){
                    score += 200;
                    combo++;
                }
                else if(time<2000){
                    score += 100;
                    combo++;
                }
                else if(time<3000){
                    score += 50;
                    combo++;
                }
                else if(time<4000){
                    score += 30;
                    combo++;
                }
                else if(time<5000){
                    score += 20;
                    combo=0;
                }
                else{
                    score += 10;
                    combo=0;
                }
                score += combo*10;
                prevTime = now;
                
                e.currentTarget.alpha = 0.3;
                e.currentTarget.draw(0x000000);
                //numList[checkNum-1].draw(0x000000);
                //ターゲット番号更新
                
                checkNum++;
                //txt.text = checkNum.toString()+ "    score:"+score.toString();
                if(panelNum+1==checkNum){
                    removeChild(targetNum); 
                    gameClear();//クリア
                }
                else targetNum.text = numList[checkNum-1].text;
            }
            else{
                prevTime.setTime(prevTime.valueOf()-3000);
            }

            //パネル再描画
            for(var i:int=0;i<numList.length;i++){
                numList[i].draw();
            }
            

        }//onClick
        
        
        private function get topText():String{
            return "Lv:"+saveData["level"].toString()+"  score:"+scoreCnt.toString();
        }

        
        //ゲームクリア
        private var clearStr:String;
        private function gameClear():void{
            if(bestScore<score && 0<retryCnt){
                 clearStr = "BestScore  "+bestScore.toString()+" -> "+score.toString();
                 bestScore = score;
            }
            else{
                if(retryCnt==0) bestScore = score;
                clearStr = "best "+bestScore.toString()+" score:"+score.toString();
            }
            save.data =saveData;            
                        
            
            var menu4:ActionBtn = new ActionBtn();
                menu4.x = 700 ;
                menu4.y = 150 ;
                addChild(menu4);
                menu4.init({id: 2, label: "次へ", width: 80});
                menu4.addEventListener(MouseEvent.MOUSE_UP,function():void{ 
                    Tweener.addTween(menu3, {
                        time: 0.5,
                        //x: px,
                        alpha: 0,
                        transition: "easeOutQuar",
                        onComplete: function():void{
                            f2();
                            removeChild(menu3);
                            removeChild(menu4);
                            menu3=null;
                            menu4=null;
                        }
                    });
                    Tweener.addTween(menu4, {
                        time: 0.5,
                        //x: px,
                        alpha: 0,
                        transition: "easeOutQuar"
                    });
                });
            //var scale:Number = 1;
            var px:Number = (455/2) + 70;

            Tweener.addTween(menu4, {
                time: 0.8,
                x: px,
                transition: "easeOutQuar"
            });

            var menu3:ActionBtn = new ActionBtn();
                menu3.x = 700 ;
                menu3.y = 150 ;
                addChild(menu3);
                menu3.init({id: 2, label: "リトライ", width: 80});
                menu3.addEventListener(MouseEvent.MOUSE_UP,function():void{
                    Tweener.addTween(menu3, {
                        time: 0.5,
                        //x: px,
                        alpha: 0,
                        transition: "easeOutQuar",
                        onComplete: function():void{
                            retryCnt++;
                            gameStart();
                            removeChild(menu3);
                            removeChild(menu4);
                            menu3=null;
                            menu4=null;
                        }

                    });
                    Tweener.addTween(menu4, {
                        time: 0.5,
                        //x: px,
                        alpha: 0,
                        transition: "easeOutQuar"
                    });
                });
            var px2:Number = (455/2) - 70;
            Tweener.addTween(menu3, {
                time: 0.8,
                x: px2,
                transition: "easeOutQuar"
            });

        }
        
        

        
        private function getTime():Number{
            var now:Date = new Date();
            var time:Number = now.valueOf()-stTime.valueOf();
            return time/1000;
        }

        private function onFrame(e:Event):void{
            var now:Date = new Date();
            var time:int = now.valueOf()-prevTime.valueOf();
            
            if(scoreCnt<score){
                if(scoreCnt+200<score)scoreCnt=score-200;
                scoreCnt+=10;
                txt.text = topText;
                
            }
            //else clearStr ="";


            
            if(time<5000){
                return;
            }
            else if(time<8000){
                numList[checkNum-1].draw(0x00ff00);
                return;
            }
            else if(time<10000){
                numList[checkNum-1].draw(0xffaa00);
                return;
            }
            else{
                numList[checkNum-1].draw(0xff0000);
                return;
            }
            
            

            //txt.text = checkNum.toString()+"        time:"+getTime().toString();
        }//onFrame
        


    }//class
    

}//package



///---------------------------------------------------------
import flash.display.*;
import flash.events.*;
import flash.text.*;
import caurina.transitions.Tweener;
class panel extends Sprite{
    private var _num:int;
    private var _col:uint=0x000000;
    private var _scale:Number = 1.0;
    public var tf:TextField;
    public function panel(){
        tf = new TextField();
        var format:TextFormat = new TextFormat();
        format.align = TextFormatAlign.CENTER;    // 整列
        format.font = "MS ゴシック";        // フォント名
        format.size = 30;        // 文字のポイントサイズ
        tf.defaultTextFormat = format;
        
        tf.selectable = false;
        tf.width = 50;
        tf.height = 50;
        tf.text = "test";
        
        addChild(tf);
        draw();
        addEventListener(MouseEvent.MOUSE_DOWN,onDown);
        addEventListener(MouseEvent.MOUSE_UP,onUp);
        addEventListener(MouseEvent.MOUSE_OUT,onUp);

    }
    
    public function set text(str:String):void{
        tf.text = str;
        tf.width = tf.textWidth+10;
        draw();
        //tf.scaleX = tf.scaleY = 1/(tf.width/50); 
    }
    public function get text():String{
        return tf.text;
    }


    public function set num(n:int):void{
        _num = n;
        tf.text = _num.toString();
    }
    public function get num():int{
        return _num;
    }

    public function draw(col:uint=0x000000):void{
        if(col!=_col)_col=col;
        this.graphics.clear();
        this.graphics.lineStyle(2,_col);
        //this.graphics.drawRect(0,0,50,50);
        this.graphics.beginFill(0xffffff);
        this.graphics.drawRoundRect(0,0,tf.width,tf.height,5,5);
        this.graphics.endFill();
        
    }
    public function onDown(e:MouseEvent):void{
        _scale = this.scaleX;
        //アニメーション処理
        var scale:Number = _scale*0.9;
            Tweener.addTween(this, {
                time: 0.1,    // アニメーション時間
                scaleX: scale,  // s の scaleX を 指定値 まで遷移
                scaleY: scale,  // s の scaleY を 指定値 まで遷移
                //alpha: 1,//不透明率
                transition: "easeOutBounce"//バウンドアニメーション
            });
    }
    public function onUp(e:MouseEvent):void{
        //アニメーション処理
        var scale:Number = _scale;
            Tweener.addTween(this, {
                time: 0.3,    // アニメーション時間
                scaleX: scale,  // s の scaleX を 指定値 まで遷移
                scaleY: scale,  // s の scaleY を 指定値 まで遷移
                //alpha: 1,//不透明率
                transition: "easeOutBounce"//バウンドアニメーション
            });
    }


}




//////////////////////////////////////////////////

// ActionBtnクラス

//////////////////////////////////////////////////



import flash.display.Sprite;

import flash.display.Shape;

import flash.text.TextField;

import flash.text.TextFieldType;

import flash.text.AntiAliasType;

import flash.text.TextFormat;

import flash.text.TextFormatAlign;

import flash.filters.DropShadowFilter;

import flash.geom.Matrix;

import flash.display.GradientType;

import flash.display.SpreadMethod;

import flash.display.InterpolationMethod;

import flash.geom.ColorTransform;

import flash.events.Event;

import flash.events.MouseEvent;



class ActionBtn extends Sprite {

    public var id:uint;

    private var shade:Shape;

    private var base:Shape;

    private var front:Shape;

    private var light:Shape;

    private var overlay:Shape;

    private var txt:TextField;

    private var label:String = "";

    private static var fontType:String = "_ゴシック";

    private var _width:uint = 60;

    private static var _height:uint = 32;

    private static var corner:uint = 6;

    private static var tHeight:uint = 17;

    private static var bColor:uint = 0xFFFFFF;

    private static var sColor:uint = 0x000000;

    private static var baseColor:uint = 0x0066CC;

    private static var lightColor:uint = 0x00FFFF;

    private static var overColor:uint = 0x3333FF;

    private static var tColor:uint = 0xFFFFFF;

    private static var defaultColorTrans:ColorTransform;

    private static var disableColor:uint = 0xCCCCCC;

    private static var disableColorTrans:ColorTransform;

    private var mode:int;

    private var _selected:Boolean = false;

    private var _enabled:Boolean = true;



    public function ActionBtn() {

    }



    public function init(option:Object):void {

        if (option.id != undefined) id = option.id;

        if (option.label != undefined) label = option.label;

        if (option.width != undefined) _width = option.width;

        draw();
        
        this.addEventListener(MouseEvent.MOUSE_DOWN,onDown);
        this.addEventListener(MouseEvent.MOUSE_UP,onUp);

    }

    private function draw():void {

        defaultColorTrans = new ColorTransform();

        disableColorTrans = new ColorTransform();

        disableColorTrans.color = disableColor;

        shade = new Shape();

        base = new Shape();

        front = new Shape();

        light = new Shape();

        overlay = new Shape();

        txt = new TextField();

        addChild(shade);

        addChild(base);

        addChild(front);

        addChild(light);

        addChild(overlay);

        addChild(txt);

        createBase(shade, _width, _height, corner, bColor);

        shade.filters = [new DropShadowFilter(1, 90, sColor, 0.4, 4, 4, 2, 3, false, false)];

        createBase(base, _width-2, _height-2, corner, baseColor);

        createFront(front, _width, _height, corner);

        createLight(light, _width-2, _height-2, corner);

        createOverlay(overlay, _width-2, _height-2, corner);

        txt.x = -_width/2;

        txt.y = -tHeight + _height/4;

        txt.width = _width;

        txt.height = tHeight;

        txt.type = TextFieldType.DYNAMIC;

        txt.selectable = false;

        //txt.embedFonts = true;

        //txt.antiAliasType = AntiAliasType.ADVANCED;

        var tf:TextFormat = new TextFormat();

        tf.font = fontType;

        tf.size = 10;

        tf.align = TextFormatAlign.CENTER;

        txt.defaultTextFormat = tf;

        txt.textColor = tColor;

        txt.text = label;

        txt.filters = [new DropShadowFilter(0, 90, sColor, 0.5, 2, 2, 2, 3, false, false)];

        light.alpha = 0;

        enabled = true;

        mouseChildren = false;

    }

    private function rollOver(evt:MouseEvent = null):void {

        mode = 1;

        addEventListener(Event.ENTER_FRAME, action, false, 0, true);

    }

    private function rollOut(evt:MouseEvent = null):void {

        mode = -1;

        addEventListener(Event.ENTER_FRAME, action, false, 0, true);

    }

    private function action(evt:Event):void {

        light.alpha += 0.1*mode;

        if (light.alpha < 0) {

            light.alpha = 0;

            removeEventListener(Event.ENTER_FRAME, action);

        }

        if (light.alpha > 1) {

            light.alpha = 1;

            removeEventListener(Event.ENTER_FRAME, action);

        }

    }
    
    public function onDown(e:MouseEvent):void{

        //アニメーション処理

        var scale:Number = 0.9;

            Tweener.addTween(this, {

                time: 0.1,    // アニメーション時間

                scaleX: scale,  // s の scaleX を 指定値 まで遷移

                scaleY: scale,  // s の scaleY を 指定値 まで遷移

                //alpha: 1,//不透明率

                transition: "easeOutBounce"//バウンドアニメーション

            });

    }

    public function onUp(e:MouseEvent):void{

        //アニメーション処理

        var scale:Number = 1;

            Tweener.addTween(this, {

                time: 0.3,    // アニメーション時間

                scaleX: scale,  // s の scaleX を 指定値 まで遷移

                scaleY: scale,  // s の scaleY を 指定値 まで遷移

                //alpha: 1,//不透明率

                transition: "easeOutBounce"//バウンドアニメーション

            });

    }

    private function _up():void {

        base.transform.colorTransform = defaultColorTrans;

        front.transform.colorTransform = defaultColorTrans;

    }

    private function _down():void {

        base.transform.colorTransform = defaultColorTrans;

        front.transform.colorTransform = defaultColorTrans;

        light.alpha = 1;

    }

    private function _disable():void {

        base.transform.colorTransform = disableColorTrans;

        front.transform.colorTransform = disableColorTrans;

    }

    public function get selected():Boolean {

        return _selected;

    }

    public function set selected(param:Boolean):void {

        _selected = param;

        enabled = !_selected;

        if (_selected) {

            _down();

        } else {

            _up();

            rollOut();

        }

    }

    public function get enabled():Boolean {

        return _enabled;

    }

    public function set enabled(param:Boolean):void {

        _enabled = param;

        buttonMode = _enabled;

        mouseEnabled = _enabled;

        useHandCursor = _enabled;

        if (_enabled) {

            _up();

            addEventListener(MouseEvent.MOUSE_OVER, rollOver, false, 0, true);

            addEventListener(MouseEvent.MOUSE_OUT, rollOut, false, 0, true);

        } else {

            _disable();

            removeEventListener(MouseEvent.MOUSE_OVER, rollOver);

            removeEventListener(MouseEvent.MOUSE_OUT, rollOut);

        }

    }

    private function createBase(target:Shape, w:uint, h:uint, c:uint, color:uint, alpha:Number = 1):void {

        target.graphics.beginFill(color, alpha);

        target.graphics.drawRoundRect(-w/2, -h/2, w, h, c*2);

        target.graphics.endFill();

    }

    private function createFront(target:Shape, w:uint, h:uint, c:uint):void {

        var colors:Array = [baseColor, baseColor];

        var alphas:Array = [0, 0.5];

        var ratios:Array = [0, 255];

        var matrix:Matrix = new Matrix();

        matrix.createGradientBox(w, h, 0.5*Math.PI, -w/2, -h/2);

        target.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix, SpreadMethod.PAD, InterpolationMethod.RGB, 0);

        target.graphics.drawRoundRect(-w/2, -h/2, w, h, c*2);

        target.graphics.endFill();

    }

    private function createLight(target:Shape, w:uint, h:uint, c:uint):void {

        var colors:Array = [lightColor, overColor];

        var alphas:Array = [1, 0];

        var ratios:Array = [40, 160];

        var matrix:Matrix = new Matrix();

        matrix.createGradientBox(w*2, h*3, 0, -w, -h*0.9);

        target.graphics.beginGradientFill(GradientType.RADIAL, colors, alphas, ratios, matrix, SpreadMethod.PAD, InterpolationMethod.RGB, 0);

        target.graphics.drawRoundRect(-w/2, -h/2, w, h, c*2);

        target.graphics.endFill();

    }

    private function createOverlay(target:Shape, w:uint, h:uint, c:uint):void {

        target.graphics.beginFill(bColor, 0.3);

        target.graphics.drawEllipse(-w*1.125, -h*4.375, w*2.25, h*4.375);

        target.graphics.endFill();

        var _mask:Shape = new Shape();

        _mask.graphics.beginFill(sColor);

        _mask.graphics.drawRoundRect(-w/2, -h/2, w, h, c*2);

        _mask.graphics.endFill();

        addChild(_mask);

        target.mask = _mask;

    }



}





//////////////////////////////////////////////////

// BitmapTileクラス

//////////////////////////////////////////////////



import flash.display.Shape;

import flash.display.BitmapData;

import flash.geom.ColorTransform;



class BitmapTile extends Shape {

    private var _width:uint;

    private var _height:uint;



    public function BitmapTile(w:uint, h:uint, Tile:Class, color:uint = 0x000000) {

        _width = w;

        _height = h;

        draw(Tile, color);

    }



    private function draw(Tile:Class, color:uint):void {

        var tile:BitmapData = new Tile();

        var bitmapdata:BitmapData = new BitmapData(tile.width, tile.height);

        var colorTrans:ColorTransform = new ColorTransform();

        colorTrans.color = color;

        bitmapdata.draw(tile, null, colorTrans);

        graphics.beginBitmapFill(bitmapdata, null, true);

        graphics.drawRect(0, 0, _width, _height);

        graphics.endFill();

    }



}





import flash.display.BitmapData;



class Tile6 extends BitmapData {

    private static var size:uint = 6;

    private static var color:uint = 0xFF000000;



    public function Tile6() {

        super(size, size, true, 0x00000000);

        init();

    }



    private function init():void {

        setPixel32(0, 2, color);

        setPixel32(0, 5, color);

        setPixel32(1, 1, color);

        setPixel32(1, 4, color);

        setPixel32(2, 0, color);

        setPixel32(2, 3, color);

        setPixel32(3, 2, color);

        setPixel32(3, 5, color);

        setPixel32(4, 1, color);

        setPixel32(4, 4, color);

        setPixel32(5, 0, color);

        setPixel32(5, 3, color);

    }



}



//-------Objectデータをローカルに保存する------------------------------------------------

    import flash.net.*;

    class SaveData{

        private var so:SharedObject;

        //オブジェクト名を指定して開く

        public function SaveData(name:String){

            so = SharedObject.getLocal(name);

        }



        //データロード

        public function get data():Object{

            var obj:Object;

            if(so){ 

                obj = so.data;

                return obj;

            }      

            return null;

        }

        

        //データセーブ

        public function set data(obj:Object):void{

            if(so){

                for(var str:String in obj){

                    so.data[str] = obj[str];

                }

            }

        }

        //データ消去

        public function clear():void{

            if(so){

                so.clear();

            }

        }

        public function get length():int{

            var cnt:int=0;

            for(var str:String in so.data)cnt++;

            return cnt;

        }



        

        //データ確認

        public function show():String{

            var text:String = new String();

            for(var str:String in so.data){ 

                text += str;

                text += "="+so.data[str].toString()+"\n";

            }

            return text;

        }



    }

Forked