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

フラクタル実験

木がマウスカーソルの向きに曲がる
Get Adobe Flash player
by Nao_u 15 Apr 2009
//
// 木がマウスカーソルの向きに曲がる
//
package { 
    import flash.display.Sprite; 
    import flash.events.*; 
    [SWF(width="465", height="465", backgroundColor="0xFFFFFF", frameRate="60")]  
    
    public class FlashTest extends Sprite { 
        public function FlashTest() { 
            Main = this; 
            stage.addEventListener(Event.ENTER_FRAME,update);  
        } 
    } 
}         

import flash.display.Sprite;  
import flash.events.Event;
var Main:Sprite; 
var SCREEN_W:Number = 465;
var SCREEN_H:Number = 465;

var Cnt1:Number = 0, Cnt2:Number = 0, Cnt3:Number = 0, Cnt4:Number = 0;
var Rnd1:Number = 0, Rnd2:Number = 0, Rnd3:Number = 0, Rnd4:Number = 0;
var Mx:Number = 0, My:Number = 0;
function update(e :Event):void{ 
    Main.graphics.clear();
    Main.graphics.lineStyle(3,0xd0d000);    
    Main.graphics.moveTo( -10240, 455 );    
    Main.graphics.lineTo( 10240, 455 );       

    Cnt1 += 0.090;
    Cnt2 += 0.093;
    Cnt3 += 0.007;
    Cnt4 += 0.005;
    Rnd1 = (Math.cos(Cnt3)*Math.cos(Cnt3)) * Math.cos(Cnt3*3) * Math.cos(Cnt3*5) * 0.5 +            Math.sin(Cnt3*25) * 0.02;
    Rnd2 = (Math.cos(Cnt4)*Math.cos(Cnt4)) * Math.cos(Cnt4*3) * Math.cos(Cnt4*5) * 0.5 +            Math.sin(Cnt4*25) * 0.02;
    Rnd3 = (Math.sin(Cnt3)*Math.sin(Cnt3)) * Math.cos(Cnt3*4) * Math.cos(Cnt3*6) * 0.5 +            Math.sin(Cnt3*22) * 0.02;
    Rnd4 = (Math.cos(Cnt4)*Math.cos(Cnt4)) * Math.sin(Cnt4*3) * Math.sin(Cnt4*6) * 0.5 +            Math.cos(Cnt4*26) * 0.02;

    var tx:Number = Main.stage.mouseX / SCREEN_W - 0.5 + Math.sin(Cnt1) * 0.01 + Rnd1*0.01;  
    var ty:Number = Main.stage.mouseY / SCREEN_H - 0.5 + Math.cos(Cnt2) * 0.01;  
    Mx += (tx - Mx) * 0.30;
    My += (ty - My) * 0.30;

    draw( 4, 15 , SCREEN_W/8 * 1, 455, -150*Rnd1, -50+ 100*(Rnd2), 0.5 );
    draw( 5, 15 , SCREEN_W/8 * 2, 455, -100*Rnd2, -80+ 100*(Rnd1*Rnd2), 0.9 );
    draw( 4, 10 , SCREEN_W/8 * 3, 455, -50*Rnd3,  -90+ 100*(Rnd3), 0.5 );
    draw( 8, 20 , SCREEN_W/8 * 4, 455,  50*Rnd4,  -60+ 100*(-0.2+Rnd2+Rnd1), 1.0 );
    draw( 4, 10 , SCREEN_W/8 * 5, 455,  150*Rnd1, -90+ 100*(Rnd1*Rnd3), 0.5 );
    draw( 5, 15 , SCREEN_W/8 * 6, 455,  250*Rnd3, -80+ 100*(Rnd4), 0.9 );
    draw( 4, 15 , SCREEN_W/8 * 7, 455,  250*Rnd2, -50+ 100*(Rnd2+Rnd1), 0.5 );
}

function draw( cnt:int, w:Number, x:Number, y:Number, vx:Number, vy:Number, col:Number ):void{ 
    var c:int = 200 * col;
    var cc:int = (c<<16) + (c<<8);
    Main.graphics.lineStyle(w,cc);    
    Main.graphics.moveTo( x, y );    
    x += vx;
    y += vy;
    Main.graphics.lineTo( x, y );       

    cnt--;
    if( cnt <= 0 ) return;
    vx *= 0.99;
    vy *= 0.9;
    w *= 0.7;
    col *= 0.85;
    draw(cnt,w,x,y,2.5 * Math.sin((vx-vy)*0.1) + vx+(25+15*My+25*Rnd1) + Mx*60 + 0.1 * cnt, vy + My*40 + vx*vx*0.01,col );
    draw(cnt,w,x,y,2.5 * Math.cos((vx+vy)*0.1) + vx-(25+15*My+105*Rnd2)+ Mx*50 - 0.1 * cnt, vy + My*40 + vx*vx*0.01,col*0.9 );
    draw(cnt-2,w*0.5,x,y, vx+Mx*10.1+(My+25*Rnd3) * 0.5, vy + My*40 ,col );

}