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

Ukiuki × GYAOS_sample

Ukiukiライブラリを使ってエフェクトつけてみました。
クリックで攻撃します。
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/96uh
 */

// forked from hacker_9vjnvtdz's GYAOS_sample
/**
 * Copyright hacker_9vjnvtdz ( http://wonderfl.net/user/hacker_9vjnvtdz )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/f6f2
 */

/*
    Ukiukiライブラリを使ってエフェクトつけてみる。
*/
package
{
    import flash.geom.Matrix;
    import flash.display.Bitmap;
    import com.bit101.components.PushButton;
    
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.net.URLRequest;
    import flash.system.LoaderContext;
    import flash.utils.Timer;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    
    import org.libspark.ukiuki.Ukiuki;
    import org.libspark.ukiuki.jobs.UkiSequence;
    import org.libspark.ukiuki.ease.*;
    
    import flash.utils.setInterval;
    import flash.utils.setTimeout;
    
    [SWF(width="465", height="465", frameRate="60", backgroundColor="0x001122")]
    public class FlashTest extends MovieClip
    {
  
        private var imgUrl:Array =["http://assets.wonderfl.net/images/related_images/6/6d/6d2a/6d2aac9165308e05d07f52232f99bfe9d52a06fb",
                                    "http://assets.wonderfl.net/images/related_images/9/9a/9a67/9a674310835d956620db269594b14241d8c079ba",
                                    "http://assets.wonderfl.net/images/related_images/5/57/5728/5728bb5057da70c62a2bff824fac59cf139bcb44" ]
        
        private var num:uint = (imgUrl.length * Math.random()) >>> 0;
        private var loaders:Array = []; 
        private var actions:Array = [];
         
        private var enemy:Loader; // モンスター表示用コンテナ
        
        private var field:Sprite = new Sprite;
        private var hp:int = 100; // モンスターのHP
        
        private var enter:Array = [ [enterEffect, [], 30 ], [ addMonstor ] ]; 
        private var message:TextField = new TextField();
        public var movable:Boolean = false;
        
        public function FlashTest()
        {
            var now:NowLoading = new NowLoading(init);
            // モンスターをロードする
            for each (var url:String in imgUrl ){
                var loader:Loader = new Loader();
                var context:LoaderContext=new LoaderContext(true);
                loader.load(new URLRequest( url ), context);
                loaders.push(loader);
                now.addLoader(loader)
            } 
            enemy = loaders[num];
            setInterval( action, 4000 );
            
            addChild( now )
            addChild( message );
            addChild( new Bitmap(back) );
            addChild( field );
            message.width = 2000;
            message.height = 200;
            message.x = (W - 2000) / 2;
            message.y = (H - 120) / 2;
            message.defaultTextFormat = new TextFormat( "_serif", 300, 0xEEEEEE, true, null, null, null, null, "center" );
            message.visible = false;
        }
        
        
        // モンスターのロード完了時の処理
        private function init():void
        {
            // モンスターをステージ中央に配置する
            field.addChild( enemy );
            enemy.visible = false;
            hp = 100;
            enemy.scaleX = 1;
            enemy.scaleY = 1;
            enemy.x = stage.stageWidth / 2 - enemy.width / 2;
            enemy.y = stage.stageHeight / 2 - enemy.height / 2;
            Ukiuki.sequence( null, enter );
        }
        
        private function enterEffect():void {
            message.alpha = 1;
            message.text = "戦闘開始";
            message.visible = true;
            var mx:Number = message.x;
            message.x = -W*10;
            Ukiuki.tween( message, { x:mx }, { time:20, ease:Back.OUT } );
            var vec:Vector.<Particle> = back.effect( 1000 );
            for each( var p:Particle in vec ){
                p.x = W * Math.random();
                p.y = H * Math.random();
                Ukiuki.chase2D( p, {x:W/2,y:H/2}, { inertia:0.50, spring:0.2, timeLimit:80, matrix:new Matrix(0.4,0.4,-0.4,0.4) } )
                Ukiuki.tween( p, {r:0,g:0,b:0}, {time:100,onRemove:p.remove()} )
            }
        }
        

        private function addMonstor():void {
            message.visible = false; 
            back.draw( message, new Matrix(1,0,0,1,message.x,message.y) );
            enemy.visible = true;
            enemy.alpha = 0;
            movable = true;
            Ukiuki.random( enemy, {x:3,y:3}, {limit:50} );
            Ukiuki.tween( enemy, { alpha:1 }, { time:40, ease:Sine.IN } );
            Ukiuki.yoyo( enemy, { x: enemy.x-enemy.width/2, y:enemy.y-enemy.height/2, scaleX:2, scaleY:2 }, { time:10, ease:Quint.IN_OUT } )

            Sound.se(2)
            stage.addEventListener( "mouseDown", atc );
        }
        
        
        


        // 攻撃処理
        private function atc(e:MouseEvent):void
        {
            if( movable ){
                var r:int=Math.floor(Math.random() * 10) + 10;
                hp-=r;
                
                if ( hp < 1 ){
                    movable = false;
                    enemy.visible = false
                    field.removeChild( enemy );
                    back.draw( enemy,  new Matrix(1,0,0,1,enemy.x,enemy.y) );
                    setTimeout( init, 3000 ); 
                    Sound.se(1)
                }else{
                    movable = false;
                    message.text = "攻撃"
                    back.draw( message, new Matrix(1,0,0,1,message.x,message.y) );
                    Ukiuki.random( enemy, {x:5,y:5}, { limit:20 } )
                    Ukiuki.sequence( this, [[20],["movable",true]] )
                    Sound.se(0)
                }
            }
        }
        
        // 敵の行動
        private function action():void {
            if( movable ){
                 var act:Array = [ "stare", "screem", "jump" ] 
                 movable = false;
                switch( act[(Math.random()*act.length)>>>0] ){
                    case "jump":
                         message.text = "JUMP"
                         back.draw( message, new Matrix(1,0,0,1,message.x,message.y) );
                         Ukiuki.yoyo( enemy, { y:enemy.y-50 }, { time:6, repeat:1, ease:Quad.OUT } )
                         Ukiuki.sequence( this, [[50],["movable",true]] );
                         break;
                     case "stare":
                         message.text = "STARE"
                         back.draw( message, new Matrix(1,0,0,1,message.x,message.y) );
                         Ukiuki.zigzag( enemy, { x:10 }, { time:5, repeat:1, ease:Sine.OUT } )
                         Ukiuki.sequence( this, [[50],["movable",true]] )
                         break;   
                     case "screem":
                         message.text = "SCREEM";
                         back.draw( message, new Matrix(1,0,0,1,message.x,message.y) );
                         Ukiuki.random( enemy, {x:3,y:3}, {limit:50} );
                         Ukiuki.yoyo( enemy, { x:enemy.x-enemy.width/10, y:enemy.y-enemy.height/10, scaleX:1.2, scaleY:1.2 }, { time:10, ease:Quint.IN_OUT } )
                         Ukiuki.sequence( this, [[50],["movable",true]] );
                         Sound.se(2)
                         break;                    
                }
            }
        }
        
    }
}
import flash.geom.Point;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.display.BitmapData;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.utils.setInterval;
import org.libspark.ukiuki.Ukiuki;

const W:int = 465;
const H:int = 465
const back:BackGround = new BackGround();

class BackGround extends BitmapData{
    private var particle:Vector.<Particle> =  new Vector.<Particle>();
    private var color:ColorTransform = new ColorTransform(0.99,0.93,0.8,0.9999);
    private var filter:BlurFilter = new BlurFilter( 4, 4 );
    function BackGround(){
        super( W,H,true,0 );
        setInterval( onFrame, 1000/60 );
    }
    public function effect( size:uint ):Vector.<Particle>{
        var re:Vector.<Particle> = new Vector.<Particle>();
        for( var i:uint = 0; i<size; i++ ){ var p:Particle=new Particle; re.push(p); particle.push(p);}
        return re;
    }
    public function onFrame():void{
        lock()
        var l:uint = particle.length;
        this.applyFilter( this, rect, new Point, filter );
        for( var i:uint = 0; i<l; i++ ){
            var p:Particle = particle[i]
            if( p.alive ){
                this.setPixel32( p.x, p.y, (p.a<<24) + (p.r<<16) +(p.g<<8) +(p.b<<0) );
            }else{
                particle.splice( i, 1 )
                i--; l--;
            }
        }
        this.colorTransform( rect, color );
        unlock()
    }
}



class Particle{
    public var x:Number, y:Number, a:uint=0xFF,r:uint=0xFF,g:uint=0xFF,b:uint=0xFF,alive:Boolean = true;
    public function remove():void{ alive = false; }
}


//SiON-----------------------------
import org.si.sion.*;
class MyDriver extends SiONDriver {
    function MyDriver():void{
        super();
        setSamplerData(0, render("%2@4 l48 c<<<c"));
        setSamplerData(1, render("%2@4 l48 <<c&>>c&<<c&c&>c"));
        setSamplerData(2, render("%2@2 v6l48 c>c>c<c"));
        play();
    }
}


class Sound{
    static public var driver:MyDriver = new MyDriver();
    static public function se(i:int,delay:int=0):void{
        driver.playSound(i,0,delay);
    }
}

//NowLoadingライブラリ===============================================================
import flash.display.Loader;
import flash.media.Sound;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.net.URLLoader;
class NowLoading extends Sprite {
    static public const COMPLETE:String = "complete";
    private var loaders:Vector.<Object> = new Vector.<Object>;
    private var bytesTotal:uint=0,bytesLoaded:uint=0;
    private var sprite:ProgressSprite;
    
    private var _loaderNum:uint=0, _completedNum:uint=0, _openNum:uint=0;
    private var text:Bitmap;
    private var onLoaded:Function;
    
    private var LETTER:Object = {
        "1":[[0,1,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1]],"2":[[1,1,1],[0,0,1],[0,1,1],[1,0,0],[1,1,1]],"3":[[1,1,1],[0,0,1],[1,1,1],[0,0,1],[1,1,1]],"4":[[1,0,1],[1,0,1],[1,0,1],[1,1,1],[0,0,1]],"5":[[1,1,1],[1,0,0],[1,1,1],[0,0,1],[1,1,1]],
        "6":[[1,1,1],[1,0,0],[1,1,1],[1,0,1],[1,1,1]],"7":[[1,1,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1]],"8":[[1,1,1],[1,0,1],[1,1,1],[1,0,1],[1,1,1]],"9":[[1,1,1],[1,0,1],[1,1,1],[0,0,1],[0,0,1]],"0":[[1,1,1],[1,0,1],[1,0,1],[1,0,1],[1,1,1]],
        ".":[[0],[0],[0],[0],[1]]," ":[[0],[0],[0],[0],[0]],"n":[[0,0,0],[0,0,0],[1,1,1],[1,0,1],[1,0,1]],"w":[[0,0,0,0,0],[0,0,0,0,0],[1,0,1,0,1],[1,0,1,0,1],[1,1,1,1,1]],"o":[[0,0,0],[0,0,0],[1,1,1],[1,0,1],[1,1,1]],
        "a":[[0,0,0],[0,0,1],[1,1,1],[1,0,1],[1,1,1]],"l":[[1],[1],[1],[1],[1]],"i":[[1],[0],[1],[1],[1]],"d":[[0,0,1],[0,0,1],[1,1,1],[1,0,1],[1,1,1]],"g":[[0,0,0],[0,0,0],[1,1,1],[1,0,1],[1,1,1],[0,0,1],[1,1,1]],
        "C":[[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,1,1]],"O":[[1,1,1],[1,0,1],[1,0,1],[1,0,1],[1,1,1]],"M":[[1,1,1,1,1],[1,0,1,0,1],[1,0,1,0,1],[1,0,1,0,1],[1,0,1,0,1]],"P":[[1,1,1],[1,0,1],[1,1,1],[1,0,0],[1,0,0]],
        "T":[[1,1,1],[0,1,0],[0,1,0],[0,1,0],[0,1,0]],"L":[[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,1,1]],"E":[[1,1,1],[1,0,0],[1,1,1],[1,0,0],[1,1,1]]
    }
    
    public function NowLoading( onLoaded:Function = null, progressSprite:ProgressSprite = null ){
        this.onLoaded = onLoaded;
        if ( progressSprite == null ) {
            sprite = new ProgressSprite();
        }else{
            sprite = progressSprite;
        }
        
        text = new Bitmap( new BitmapData(30 * 4, 8, true, 0x00000000 ) ); 
        
        addChild(sprite).blendMode = "invert"; 
        addChild(text).blendMode = "invert"; 
        
        addEventListener( Event.ADDED_TO_STAGE, init );
    }
    
    private function init(e:Event):void{
        removeEventListener( Event.ADDED_TO_STAGE, init );
        with (text) { 
            scaleX = scaleY = 1; 
            x = stage.stageWidth - text.width;
            y = stage.stageHeight - text.height;
        }
    }
    
    public function addLoader(loader:Loader):Loader{ setListener(loader.contentLoaderInfo);_loaderNum++;return loader;}
    public function addURLLoader(loader:URLLoader):URLLoader{setListener(loader); _loaderNum++; return loader;}
    public function addSound(sound:Sound):Sound{setListener(sound); _loaderNum++; return sound;}
    
    private function setListener(loader:*):void{
        loader.addEventListener("open", onOpen);
        loader.addEventListener("complete", onComplete);
        loader.addEventListener("progress", update);
    }
    
    private function update(e:Event=null):void{
        bytesLoaded=0; bytesTotal=0;
        for each(var loadObj:Object in loaders){
            bytesLoaded += loadObj.bytesLoaded;
            bytesTotal += loadObj.bytesTotal;
        };
        sprite.progress( bytesLoaded/bytesTotal * _openNum / _loaderNum );
        if (bytesTotal != 0) {
            setText( "now loading... " + (bytesLoaded / bytesTotal * _openNum / _loaderNum * 100).toFixed(1) );
        }
    }
    
    private function onOpen(e:Event):void { 
        e.currentTarget.removeEventListener("open", onOpen); 
        _openNum++;
        loaders.push(e.currentTarget);
        bytesTotal += e.currentTarget.bytesTotal;
    }
    
    private function onComplete(e:Event):void {  
        e.currentTarget.removeEventListener("complete", onComplete);
        e.currentTarget.removeEventListener("progress", update);
        _completedNum++; 
        if (_loaderNum == _completedNum) {  setText( "COMPLETE" ); if ( onLoaded != null ) { onLoaded() }  } 
    }
    
    
    private function setText(str:String):void{
        var b:BitmapData = text.bitmapData; var l:int = str.length; var position:int = b.width;
        b.lock();b.fillRect(b.rect,0x000000);
        for(var i:int=0;i<l;i++){
            var letterData:Array = LETTER[str.substr(l-i-1,1)];position-=letterData[0].length+1;
            for(var n:int=0;n<letterData.length;n++){ for(var m:int=0;m<letterData[n].length;m++){ 
                if(letterData[n][m]==1){b.setPixel32(m+position,n+1,0xFF000000);} 
            } }
        }
        b.unlock();
    }
}
class ProgressSprite extends Sprite{
    public function progress(rate:Number):void {
        if( stage != null ){
            graphics.clear(); graphics.beginFill( 0x000000, 1 )
            graphics.drawRect( 0, stage.stageHeight - 11, rate * stage.stageWidth, 11);
        }
    }
}