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

FLOWER BLOOM

新年あけましておめでとうございます(5日遅れ)
久々に作ってみたら、色々とど忘れしてることがあって地味に苦労しました(汗
Get Adobe Flash player
by KBM 06 Jan 2015
/**
 * Copyright KBM ( http://wonderfl.net/user/KBM )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/15tV
 */

package {
    import flash.display.SimpleButton;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var flowers:Array = [];
            var max:int = 200;//花の最大数
            var framecount:int = 0;
            var count:int = 0;
            var time:int = 20; //花が出てくる間隔 処理落ちに注意
            
            addEventListener(Event.ENTER_FRAME,function onEnterFrame(e:Event):void{
                framecount++;
                if(framecount > time){
                    flowers.push(new Flower());
                    flowers[count].x = Math.random() * stage.stageWidth;
                    flowers[count].y = Math.random() * stage.stageHeight;
                    flowers[count].fadein();
                    addChild(flowers[count]);
                    count++;
                    framecount = 0;
                }
                if(count == max){
                    removeEventListener(Event.ENTER_FRAME,onEnterFrame)
                }
            })
        }
    }
}
import flash.events.Event;

import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;

class Flower extends Sprite{
    private var blossom:Shape;
    private var grb:Graphics;
    private var blossomColor:uint;
    private var stamens:Shape; //おしべ
    private var stamensColor:uint;
    private var grs:Graphics;
    private var r:int;
    private var difdegree:int; //花弁の角の差分 0~120°
    public function Flower():void{
        alpha = 0;
        r = 20;
        difdegree = Math.floor(Math.random() * 120);
        blossom = new Shape();
        stamens = new Shape();
        
        var redMAX:int = 0xEE; var redMIN:int = 0xAA;//花びら、青の最大値・最小値
        var greenMAX:int = 0x77; var greenMIN:int = 0x22;//花びら、緑の最大値・最小値
        var blueMAX:int = 0x77; var blueMIN:int = 0x22;//花びら、赤の最大値・最小値
        blossomColor = Math.floor((Math.random() * (redMAX - redMIN) / 2 + (redMAX + redMIN) / 2) * 0x10000 +
         (Math.random() * (greenMAX - greenMIN) / 2 + (greenMAX + greenMIN) / 2) * 0x100 + 
         Math.random() * (blueMAX - blueMIN) / 2 + (blueMAX + blueMIN) / 2 );
        
        stamensColor = 0xFFFF00;

        grb = blossom.graphics;
        for(var i:int =0; i < 5; i++){
        grb.beginFill(blossomColor);
        grb.drawCircle(r * Math.cos(Math.PI * ( 2 / 5 * i + difdegree / 180 )),
        r * Math.sin(Math.PI *( 2 / 5 * i + difdegree / 180 )),r);
        grb.endFill();
        }
        blossom.alpha = 0.97;
        grs = stamens.graphics;
        grs.beginFill(stamensColor);
        grs.drawCircle(0,0,r/2);
        grs.endFill();
        stamens.alpha = 0.8;
        
        this.addChild(blossom);
        this.addChild(stamens);
    }

    public function fadein():void{
        var framecount:int = 0;
        var frametime:int = 200;//フェードインにかけるフレーム数 これを変えるだけでもだいぶ違う
        var rotationSpeed:int = 1280;//花のフェードイン時の回転数。320の倍数が無難かな。あんまり速いとしつこいかも
        addEventListener(Event.ENTER_FRAME,function onEnterFrame(e:Event):void{
          rotation = Math.sin(Math.PI / 2 * framecount / frametime) * rotationSpeed;
          alpha = Math.tan(Math.PI / 4 * framecount / frametime);
          framecount++;
          if(framecount == frametime){removeEventListener(Event.ENTER_FRAME,onEnterFrame)}
        })
        
    }

}