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