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

Flurryを作...れてきた 3

【Flurryを作りたい】

ver.3 2010.09.23
処理速度が変わらなさそうなのでstageの大きさを戻した.
中心をsin, cosで適度にウニウニさせてみた.
触手を3本にした.
ようやくFlurryっぽくなってきた!
処理は依然として重い.

ver.2 2010.09.23
触手を2本にしてみた.少し雰囲気出てきたかな...
処理を少しでも軽くするため,stageのサイズを小さくしてみた.

ver.1 2010.09.23
sin,cosでウニウニさせてみる.
Math.random()を使うと煙に近くなった.
EnterFrameでどんどんaddChild()しているので処理は激重...
Get Adobe Flash player
by geko 23 Sep 2010
    Embed
/**
 * Copyright geko ( http://wonderfl.net/user/geko )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/z7uW
 */

// forked from KoheiTAKAMIYA's Flurryを作...れなかった 2
// forked from KoheiTAKAMIYA's Flurryを作...れなかった
package {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    
    [SWF(/*width="200",height="200",*/frameRate="30")]
    public class FlashTest extends Sprite {
        private var bmp:Bitmap = new Bitmap();
        private var flurry:Flurry;
        private var flurryB:Flurry;
        private var flurryC:Flurry;
        private var i:Number = 0;
        private var j:Number = 0;
        private var k:Number = 0;
        
        public function FlashTest() {
            bmp.bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x000000);
            addChild(bmp);
            addEventListener(Event.ENTER_FRAME, loop);
        }
        
        public function loop(event:Event):void{
            i+=0.02;
            j+=0.01;
            k+=0.018;
            
            flurry = new Flurry(3, Math.sin(Math.PI/2*i), 0.03, -0.03);
            flurryB = new Flurry(Math.cos(Math.PI/2*k), 3, 0.05, 0.03);
            flurryC = new Flurry(Math.cos(Math.PI/2*j), -3, -0.05, -0.03);
            addChild(flurry);
            addChild(flurryB);
            addChild(flurryC);
            flurry.addEventListener(Event.ENTER_FRAME, update);
            flurryB.addEventListener(Event.ENTER_FRAME, update);
            flurryC.addEventListener(Event.ENTER_FRAME, update);
            
            flurry.x = flurryB.x = flurryC.x = stage.stageWidth/2+Math.sin(Math.PI/2*j)*50;//mouseX;
            flurry.y = flurryB.y = flurryC.y = stage.stageHeight/2+Math.cos(Math.PI/2*k)*20;//mouseY;
        }
        
        public function update(event:Event):void{
            var target:Flurry = event.target as Flurry;
            target.update();
            
            if(Math.min(Math.max(target.x, -3), stage.stageWidth+3) == target.x && 
               Math.min(Math.max(target.y, -3), stage.stageHeight+3) == target.y &&
               target.alpha > 0) return;
            
            target.removeEventListener(Event.ENTER_FRAME, update);
            removeChild(target);
            target = null;
        }
    }
}

import flash.display.Shape;
import flash.display.BlendMode;
import flash.events.Event;
import flash.filters.BlurFilter;

class Flurry extends Shape{
    private var filter:BlurFilter = new BlurFilter(5,5,3);
    private var spout:Object = new Object();
    private var wind:Object = new Object();
    
    public function Flurry(spoutX:Number = 0, spoutY:Number = 0, windX:Number = 0, windY:Number = 0, color:uint = 0x33CCCC):void{
        blendMode = BlendMode.ADD;
        filters = [filter];
        spout.x = spoutX;
        spout.y = spoutY;
        wind.x = windX/3;
        wind.y = windY/3;
        
        graphics.beginFill(color);
        graphics.drawCircle(0, 0, 6);
        graphics.endFill();
    }
    public function update():void{
        spout.x += wind.x;
        spout.y += wind.y;
        x += spout.x;
        y += spout.y;
        alpha -= 0.01;///= 1.03;
    }
}