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

code on 2008-12-18

author Haramakoto

import caurina.transitions.Tweener;
// write as3 code here..
package
{
    /**
    * author Haramakoto
    */
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.Graphics;
    //import caurina.transitions.Tweener;
    import flash.events.Event;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.geom.ColorTransform;
    import flash.geom.Rectangle;
    
    [SWF(width="465", height="465", background="0x000000", frameRate="30")]
    public class testAS extends Sprite
    {
        private var circleMC:Sprite = new Sprite();
        private var counter:uint = 0;
        private var particleArray:Array = new Array(); //particle入れる配列
        private var pNum:uint = 50;
        private var pBodySize:Number = 4;
        private var bkRect:Sprite = new Sprite();
        private var base:Sprite = new Sprite();
        private var bmpData:BitmapData;
        private var bmp:Bitmap;
        private var rect:Rectangle;
        private var tonedown:ColorTransform;      

        public function testAS()
        {
            bmpData = new BitmapData(465, 465, true, 0xFFFFFF);
            bmp = new Bitmap( bmpData );
            tonedown = new ColorTransform(2.2, 1, 1.7, 0.9);
            rect = new Rectangle(0, 0, 465, 465);
            setbkRect();
            //addChild( bkRect );
            initParticles();
            addChild( bmp );
            addChild( base );
            addEventListener( Event.ENTER_FRAME, _onEnterFrame );
        }
        

        private function setbkRect():void
        {
            bkRect.graphics.beginFill( 0x000000, 1 );
            bkRect.graphics.drawRect( 0, 0, 465, 465);
            bkRect.graphics.endFill();
        }
        private function initParticles():void
        {
            for( var i:uint=0; i<pNum; i++ )
            {
                var particle:Object = _oneParticle();
                base.addChild( particle.body );
                particle.body.x = 200 * Math.random();
                particle.body.y = 200 * Math.random();
                particleArray.push( particle );
            }
        }

        private function draw_a_Circle(mc:Sprite):void
        {
            var shape:Shape = new Shape();
            var g:Graphics = shape.graphics;
            g.lineStyle (1, 0x666666, 1.0);
            g.drawCircle(0, 0, 10);
            mc.addChild( shape );
        }

        private function _oneParticle():Object
        {
            var partiObj:Object = new Object();
            partiObj.vx = partiObj.vy = 0; //速度
            partiObj.ax = partiObj.ay = 0; //加速度
            partiObj.r = 360 * Math.random(); //進行方向角度
            partiObj.cnt = 0; //カウンター
            var oneParticle:Sprite = new Sprite();
            partiObj.body = oneParticle;
            oneParticle.graphics.beginFill(0xFFFFFF * Math.random(), 1);
            oneParticle.graphics.drawCircle(-pBodySize/2, pBodySize, pBodySize);
            oneParticle.graphics.endFill();
            return partiObj;
        }
        private function _onEnterFrame(e:Event):void
        {
            for( var i:uint=0; i<pNum; i++ )
            {
                particleArray[i].cnt += 5 * Math.random();
                particleArray[i].r += Math.cos( particleArray[i].cnt * Math.PI / 180 );
                particleArray[i].vx = 2 * Math.cos(particleArray[i].r * Math.PI / 180);
                particleArray[i].vy = 2 * Math.sin(particleArray[i].r * Math.PI / 180);
                particleArray[i].body.x += particleArray[i].vx;
                particleArray[i].body.y += particleArray[i].vy;
                
                bounceEdge( particleArray[i] );
            }
            bmpData.colorTransform(rect, tonedown);  
            bmpData.draw(base);

            counter += 1;
        }

        /**
         * 端に行ったら跳ね返る処理
         */
        private function bounceEdge(obj:Object):void
        {
            if( obj.body.x > 465 ) obj.r = obj.r + 90;
            if( obj.body.x < 0 ) obj.r = obj.r + 90;
            if( obj.body.y > 465 ) obj.r = obj.r + 90;
            if( obj.body.y < 0 ) obj.r = obj.r + 90;
        }
    }
}