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

にゃんこちゃんSWC

////////////////////////////////////////////////////////////////////////////////
// にゃんこちゃんSWC
//
// [AS3.0] Catクラスに挑戦! (1)
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=1791
//
// wonderfl_cat.swf
// Security.allowDomain("wonderfl.net");
// Security.allowDomain("swf.wonderfl.net");
////////////////////////////////////////////////////////////////////////////////
Get Adobe Flash player
by ProjectNya 16 Sep 2012
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3MMT
 */

////////////////////////////////////////////////////////////////////////////////
// にゃんこちゃんSWC
//
// [AS3.0] Catクラスに挑戦! (1)
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=1791
//
// wonderfl_cat.swf
// Security.allowDomain("wonderfl.net");
// Security.allowDomain("swf.wonderfl.net");
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.DisplayObject;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.net.URLRequest;
    import flash.system.Security;
    import flash.system.LoaderContext;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.display.Shape;
    import flash.geom.Matrix;
    import flash.display.GradientType;

    [SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private var loader:Loader;
        private static var basePath:String = "http://www.project-nya.jp/images/wonderfl/";
        private static var catPath:String = "cat.swf";
        private var Cat:Class;
        private var cat:DisplayObject;
        private var label:Label;

        public function Main() {
            //Wonderfl.capture_delay(4);
            init();
        }

        private function init():void {
            draw();
            //
            Security.allowDomain("www.project-nya.jp");
            loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete, false, 0, true);
            loader.load(new URLRequest(basePath + catPath), new LoaderContext(true));
            //
            label = new Label(200, 40, 32, Label.CENTER);
            addChild(label);
            label.x = 132;
            label.y = 80;
            label.textColor = 0xFFFFFF;
            label.alpha = 0.6;
            label.text = "Cat.swc";
        }
        private function complete(evt:Event):void {
            loader.removeEventListener(Event.COMPLETE, complete);
            //Catクラス
            Cat = Class(loader.contentLoaderInfo.applicationDomain.getDefinition("jp.nya.project.character.Cat"));
            setup();
            loader = null;
        }
        private function setup():void {
            cat = new Cat();
            addChild(cat);
            cat.x = 232;
            cat.y = 400;
            //スケール
            Cat(cat).scale = 4;
            Cat(cat).type = uint(Math.random()*7) + 1;
            //ボタン無効化
            Cat(cat).mouseChildren = false;
        }
        /////////////////////////////////////////////
        //背景
        /////////////////////////////////////////////
        private function draw():void {
            drawSky();
            drawGround();
        }
        private function drawSky():void {
            var matrix:Matrix = new Matrix();
            matrix.createGradientBox(465, 350, 0.5*Math.PI, 0, 0);
            graphics.beginGradientFill(GradientType.LINEAR, [0x0069A0, 0x00AAE4], [1, 1], [0, 255], matrix);
            graphics.drawRect(0, 0, 465, 350);
            graphics.endFill();
        }
        private function drawGround():void {
            var matrix:Matrix = new Matrix();
            matrix.createGradientBox(465, 115, 0.5*Math.PI, 0, 350);
            graphics.beginGradientFill(GradientType.LINEAR, [0x99CC33, 0x7EB133], [1, 1], [0, 255], matrix);
            graphics.drawRect(0, 350, 465, 115);
            graphics.endFill();
        }

    }

}


//////////////////////////////////////////////////
// Labelクラス
//////////////////////////////////////////////////

import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFieldAutoSize;
import flash.text.AntiAliasType;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;

class Label extends Sprite {
    private var txt:TextField;
    private static var fontType:String = "_ゴシック";
    private var _width:uint = 20;
    private var _height:uint = 20;
    private var size:uint = 12;
    public static const LEFT:String = TextFormatAlign.LEFT;
    public static const CENTER:String = TextFormatAlign.CENTER;
    public static const RIGHT:String = TextFormatAlign.RIGHT;

    public function Label(w:uint, h:uint, s:uint = 12, align:String = LEFT) {
        _width = w;
        _height = h;
        size = s;
        draw(align);
    }

    private function draw(align:String):void {
        txt = new TextField();
        addChild(txt);
        txt.width = _width;
        txt.height = _height;
        txt.autoSize = align;
        txt.type = TextFieldType.DYNAMIC;
        txt.selectable = false;
        //txt.embedFonts = true;
        //txt.antiAliasType = AntiAliasType.ADVANCED;
        var tf:TextFormat = new TextFormat();
        tf.font = fontType;
        tf.size = size;
        tf.align = align;
        txt.defaultTextFormat = tf;
        textColor = 0x000000;
    }
    public function set text(value:String):void {
        txt.text = value;
    }
    public function set textColor(value:uint):void {
        txt.textColor = value;
    }

}