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: もうどうにでもなーれ

もうどうにでもなーれ
知り合いに見せてもらったiPhoneアプリをうるおぼえで再現
未チューニング
/**
 * Copyright s8t1h12akj ( http://wonderfl.net/user/s8t1h12akj )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/t4I8
 */

// forked from okoi's もうどうにでもなーれ
/**
 *    もうどうにでもなーれ
 *         知り合いに見せてもらったiPhoneアプリをうるおぼえで再現
 *         未チューニング
 */
package 
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Matrix;
    import flash.text.TextField;
    import frocessing.color.ColorHSV;
    
    [SWF(width = "465", height = "465")]
    
    public class Main extends Sprite 
    {
        private var _canvas:BitmapData;
        
        
        private var mousedown:Boolean;
        private var step:int;
        
        private var _array:/*Effect*/Array;
        
        private var _color:ColorHSV = new ColorHSV();

        private var text:String = 
            "        *'``・* 。\n" +
            "        |     `*。\n" +
            "       ,。☆      *    ステージをクリックしてね :あき爺\n" +
            "      ☆ ◎     * \n" +
            "      `*。 ヽ、       U*\n" +
            "       `・+。*    ゚\n" +
            "       ☆        *゚\n" +
            "        ☆☆*・ \n" 
        
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            graphics.beginFill(0);
            graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
            graphics.endFill();
            
            var txtfield:TextField = new TextField();
            txtfield.text = text;
            txtfield.textColor = 0xFFFFFF;
            txtfield.autoSize = "left";
            txtfield.x = 465/2 - txtfield.width / 2;
            txtfield.y = 465 / 2 - txtfield.height / 2;
            txtfield.selectable = false;
            addChild(txtfield);
            
            _canvas = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0);
            addChild(new Bitmap(_canvas) );
                        
            mousedown = false;
            step = 0;
            _array = new Array();
            
            stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
            stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
            
            addEventListener(Event.ENTER_FRAME, Update);
        }
        
        private function MouseDown(e:MouseEvent) : void
        {
            mousedown = true;
        }
        private function MouseUp(e:MouseEvent) : void
        {
            mousedown = false;
        }
        private function Update(e:Event) : void
        {
            var i:int;
            if ( mousedown )
            {
                for ( i = 0; i < 4; i++ ) AddEffect();
            }
            
            for ( i = _array.length - 1; i >= 0; i-- )
            {
                _array[i].Update();
                if ( _array[i].life == 0 )
                {
                    _array.splice(i, 1);
                }
            }
            
            _canvas.lock();
            _canvas.fillRect(_canvas.rect, 0x0);
            for ( i = 0; i < _array.length; i++ )
            {
                var mat:Matrix = new Matrix(1, 0, 0, 1);
                mat.scale(_array[i].scale, _array[i].scale);
                mat.rotate(45*Math.PI/180);
                mat.translate(_array[i].x, _array[i].y);
                _canvas.draw( _array[i], mat, null, "add" );
            }
            _canvas.unlock();
            
            
            step++;
        }
        
        private function AddEffect() : void
        {
            _color.h = Math.random() * 360;
            
            var e:Effect = new Effect(_color.value);
            e.x = stage.mouseX;
            e.y = stage.mouseY;
            e.blendMode = "add";
                        
            _array.push(e);
        }
        
    }
    
}
import flash.display.Graphics;
import flash.display.Shape;
import flash.geom.Matrix;

class Effect extends Shape {
    
    private var color:uint;
    public var life:int;
    public var scale:Number;
    
    private var mx:Number;
    private var my:Number;
    
    public function Effect(color:uint) {
        
        super();
        
        var g:Graphics = graphics;
                
        g.beginFill(color, 0.5);
        g.drawEllipse( -30, -2, 60, 4);
        g.drawEllipse( -2, -30, 4, 60);
        g.endFill();
        
        var mat:Matrix = new Matrix();
        mat.createGradientBox(40, 40,0,-20,-20);
        g.beginGradientFill("radial", [color, color], [1, 0], [0, 255], mat); 
        g.drawCircle(0, 0, 40);
        g.endFill();
                
        life = 30;
        
        scale = 1 - Math.random() * 0.5;
        
        var angle:Number = Math.random() * 360;
        var speed:Number = Math.random() * 3 + 3;
        mx = Math.cos( angle * Math.PI / 180 ) * speed;
        my = Math.sin( angle * Math.PI / 180 ) * speed;
        
    }
    
    public function Update() : void
    {
        life--;
        x += mx;
        y += my;
    }
}