flash 五彩斑斓特效

文档类:


package

{

    import flash.display.*;

    import flash.events.*;

    import flash.geom.*;

    [SWF(backgroundColor="0x000000")]

    public class main extends Sprite

    {

        private var obj:Array = new Array();

        private var bmd:BitmapData, bmp:Bitmap, container:Sprite;

        

        public function main()

        {

            bmd = new BitmapData( 465, 465, true, 0x000000 );

            bmp = addChild( new Bitmap( bmd ) ) as Bitmap;

            container = addChild( new Sprite ) as Sprite;

            container.visible = false;

            for(var i:uint = 0; i < 100; i++)

            {

                obj[i] = new ball();

                container.addChild(obj[i]);

            }

            

            stage.addEventListener(Event.ENTER_FRAME, frame);

        }

        

        private function frame(e:Event):void

        {

            for(var i:String in obj)

            {

                obj[i].run();

            }

            var m:Matrix = new Matrix;

            bmd.draw( container, m, new ColorTransform( .7, .1, .2, 1), "add" );

            bmd.colorTransform( bmd.rect, new ColorTransform( 1, 1, 1, .97 ) );

        }

    }

}



import flash.display.*;

import flash.filters.*;

class ball extends Shape

{

    private var r:uint = 15;

    private var s:Number= ( Math.random()*3 | 0 ) + 2;

    private var b:Number= -5, bb:int = -5;

    function ball()

    {

        //s = Math.random()*2 | 0 ? s : -s;

        x = Math.round(Math.random() * 450);

        y = s > 0 ? -r - Math.random()*450: 465 + r + Math.random()*450;

        graphics.beginFill(Math.round(Math.random() * 255 * 255 * 255), 1);

        graphics.drawCircle(0, 0, ( Math.random()*r | 0 ) + 4);

        graphics.endFill();

        this.filters = [ new BlurFilter( -b, -b, 2 ) ];

    }

    

    public function run():void

    {



        if( s < 0 ) {

            if(y + r < 0)

            {

                x = Math.round(Math.random() * 450);

                y = 465 + r;

                scaleX = scaleY = 1;

            }

        } else {

            if(y - r > 465)

            {

                x = Math.round(Math.random() * 450);

                y = -r;

                scaleX = scaleY = 1;

            }

        }

        scaleX += 0.001;

        scaleY += 0.001;

        y += s;

    }



}

原文地址: http://www.68design.net/Web-Guide/Flash/53123-1.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值