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

forked from: Nyanyanyanyanyanyanya!っぽいの。

Nyanyanyanyanyanyanya!っぽいの。

http://www.nicovideo.jp/watch/sm11509720
/**
 * Copyright hiragyuu ( http://wonderfl.net/user/hiragyuu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/1LRa
 */

// forked from daniwell's Nyanyanyanyanyanyanya!っぽいの。
/**
 * Nyanyanyanyanyanyanya!っぽいの。
 * 
 * http://www.nicovideo.jp/watch/sm11509720
 */
package  
{
    import flash.display.Sprite;
    import flash.events.Event;
    
    [SWF(backgroundColor = "0xfffedd", frameRate = "30", width = "465", height = "465")]
    public class Main extends Sprite
    {
        private var _nyas  :/*Nya*/Array;
        private var _count :int = 0;
        
        public function Main() 
        {
            _nyas = [];
            addEventListener(Event.ENTER_FRAME, _enterFrame);
        }
        
        private function _enterFrame(evt:Event):void 
        {
            _create();
            _update();
        }
        private function _create():void
        {
            if (_count++ % 3 != 0) return;
            
            var nya :Nya = addChild(new Nya()) as Nya;
            nya.x = Math.random() * 465;
            nya.y = 465;
            _nyas.push(nya);
        }
        private function _update():void
        {
            var n :int = -1;
            while (_nyas[++n])
            {
                if (_nyas[n].update())
                {
                    removeChild(_nyas[n]);
                    _nyas[n] = null;
                    _nyas.splice(n, 1);
                }
            }
        }
    }
}

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.text.TextField;
import flash.text.TextFormat;

class Nya extends Bitmap
{
    private var _vx  :Number;
    private var _vy  :Number;
    private var _ay  :Number;
    private var _rot :Number;
    
    public function Nya()
    {
        var tf :TextField = new TextField();
        tf.defaultTextFormat = new TextFormat("_sans", Math.random() * 48 + 32, 0, true);
        tf.autoSize = "left";
        tf.text = "Nya";
        
        var bmd :BitmapData = new BitmapData(tf.width, tf.height, true, 0);
        bmd.draw(tf);
        super(bmd, "auto", true);
        
        _vx  =   Math.random() *  32 -  16;
        _vy  = - Math.random() *  15 -  25;
        _rot =   Math.random() *   4 -   2;
        _ay  =   Math.random() * 0.5 + 1.5;
    }
    public function update():Boolean
    {
        x   += _vx;
        y   += _vy;
        _vy += _ay;
        
        rotation += _rot;
        
        if (465 < y) return true;
        return false;
    }
}