« ブロックが崩れるトランジッション - copyPixels | Main | 『24』風モーションタイポ »

燃える円陣 - draw

アニメーションはタイムラインで作成し、MCの配置とエフェクトのみスクリプトで記述。

import flash.filters.*;
import flash.display.*;
import flash.geom.*;

var w:Number = 360;
var h:Number = 240;
var r:Number = 90;
var maxi:Number = 50;
var th_init:Number = 0;
var th:Number = th_init/180*Math.PI;
var bmp:BitmapData = new BitmapData(w, h, true, 0);
var canvas:MovieClip = this.createEmptyMovieClip("canvas", 0);
var bmc:MovieClip;
var clr:ColorTransform = new ColorTransform(.3, .3, .3, .3, -30, 20, 10, 0);

var mat:Matrix = new Matrix(1, 0, 0, 1, w/2, h-40);
var blend:String = "add";
var blur:BlurFilter = new BlurFilter(4, 2, 2);
var maxh:Number = 100;
var minh:Number = 50;

var rate:Number = 1;

var clrmat:ColorMatrixFilter = new ColorMatrixFilter([
		1, 0, 0, 0, 0,
		0, 1, 0, 0, 0,
		0, 0, 1, 0, 0,
		0, 0, 0, .9, 0
		]);
var count:Number = 0;
canvas.attachBitmap(bmp,0);

bmc = this.createEmptyMovieClip("bmc",1);
bmc._x = w/2;
bmc._y = h/2;
bmc._visible = false;
for(var i:Number = 0; i < maxi; i++) {
	var f:MovieClip = bmc.attachMovie("c", "f"+i, i);
	f._yscale = Math.random()*(maxh-minh)+minh;
	f._x = Math.cos(th)*r;
	f._y = Math.sin(th)*r/3;
	f.filters = [blur];
	f.gotoAndPlay (i%f._totalframes);
	th += 360/maxi*(Math.PI/180);
}

this.onEnterFrame = function() :Void {
	if(++count%rate == 0) {
		bmp.draw(bmc, mat, clr, blend, null);
		bmp.applyFilter(bmp, bmp.rectangle, null, blur);
		bmp.applyFilter(bmp, bmp.rectangle, null, clrmat);
	}
}

TrackBack

このエントリーのトラックバックURL:
http://casualplay.net/cgi-bin/mt/mt-tb.cgi/18

Post a Comment