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

flash on 2012-5-13

Get Adobe Flash player
by jokehn9 13 May 2012
    Embed
/**
 * Copyright jokehn9 ( http://wonderfl.net/user/jokehn9 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/i0b8
 */

package {
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.events.Event;
    import flash.geom.Point;
    import flash.filters.BlurFilter;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..


    var nowDraw:Array = []; // define type of objects
    var nowDrawX:Array = []; // object's x
    var nowDrawY:Array = []; // object's y
    var nowDrawNumber:int = 0; // how many objects exist
    var nowDrawXm:Array = []; // enterFrame ,object's x -= xm 
    var nowDrawRotation:Array = []; // defin rotation
    var speedD:int = 0; 
    var i:int = 0;
    var j:int = 0;
    var now:int = 0;

    var long:Shape = new Shape(); //define shape 1
    long.graphics.beginFill(0xff0000);
    long.graphics.drawRect(0,0,20,80);
    
    var three:Shape = new Shape(); //define shape 2
    three.graphics.beginFill(0xff8700);
    three.graphics.drawRect(100,0,20,60);
    three.graphics.drawRect(120,40,20,20);
    
    var three2:Shape = new Shape(); // define shape 3
    three2.graphics.beginFill(0x0087ff);
    three2.graphics.drawRect(200,0,20,60);
    three2.graphics.drawRect(180,40,20,20);
    
    var rect:Shape = new Shape(); //define shape 4
    rect.graphics.beginFill(0x008700);
    rect.graphics.drawRect(0,100,40,40);
    
    var sam:Shape = new Shape(); // define shape 5
    sam.graphics.beginFill(0x840f8f);
    sam.graphics.drawRect(200,180,60,20);
    sam.graphics.drawRect(220,160,20,20);
    
    var bt:BitmapData = new BitmapData(500,400,true,0x0);
    addChild(new Bitmap(bt));
    
    stage.addEventListener("enterFrame",fc);
    function fc(e:Event):void
    {
        var decision:int;
        speedD++;
        if (speedD % 1 == 0)
        {
            speedD = 0;
            decision = 5 * Math.random();
            nowDraw[nowDrawNumber] = decision;
            nowDrawX[nowDrawNumber] = Math.floor(500 * Math.random());
            nowDrawY[nowDrawNumber] = Math.floor(200*Math.random());
            nowDrawXm[nowDrawNumber] = Math.floor( - 10 + 20 * Math.random());
            nowDrawRotation[nowDrawNumber] = Math.floor(360*Math.random());
            nowDrawNumber++;
        }
        for (i=0; i<nowDrawNumber; i++)
        {
            if (nowDraw[i] == 0)
            {
                long.x = nowDrawX[i];
                long.y = nowDrawY[i];
                long.rotation = nowDrawRotation[i];
                bt.draw(long,long.transform.matrix);
            }
            else if (nowDraw[i] == 1)
            {
                three.x = nowDrawX[i];
                three.y = nowDrawY[i];
                three.rotation = nowDrawRotation[i];
                bt.draw(three,three.transform.matrix);
            }
            else if (nowDraw[i] == 2)
            {
                three2.x = nowDrawX[i];
                three2.y = nowDrawY[i];
                three2.rotation = nowDrawRotation[i];
                bt.draw(three2,three2.transform.matrix);
            }
            else if (nowDraw[i] == 3)
            {
                rect.x = nowDrawX[i];
                rect.y = nowDrawY[i];
                rect.rotation = nowDrawRotation[i];;
                bt.draw(rect,rect.transform.matrix);
            }
            else if (nowDraw[i] == 4)
            {
                sam.x = nowDrawX[i];
                sam.y = nowDrawY[i];
                sam.rotation = nowDrawRotation[i];;
                bt.draw(sam,sam.transform.matrix);
            }
    
            nowDrawX[i] -=  nowDrawXm[i];
            nowDrawY[i] +=  30;
    
            if (nowDrawY[i] > stage.height) //delete object's data when they y is bigger than stage.height 
            {
                now = i;
                for (j=now; j<nowDrawNumber-1; j++)
                { // fill hole of array
                    nowDraw[j] = nowDraw[j + 1];
                    nowDrawX[j] =nowDrawX[j+1];
                    nowDrawY[j] = nowDrawY[j+1];
                    nowDrawXm[j] = nowDrawXm[j+1] ;
                    nowDrawRotation[j] = nowDrawRotation[j+1];
                }
                nowDrawNumber--;
            }
            bt.applyFilter(bt,bt.rect,new Point(0,0),new BlurFilter(8,8,1));
        }
    
    }
            }
        }
}