as 火焰效果
以下是关键原码和原始文件,感兴趣的朋友可以看看:Fire_ok.as:
/*
没啥好说的,拿去用吧:)
*/
class Fire_ok extends MovieClip
{
var fireBmp, prevBmp, tempBmp, greyBmp, mtx, pnt, blurF, greyscaleCMF, fireCMF, dispMapF, webcam, fireBmpHolder, createEmptyMovieClip;
var activityLevel_pb, wcGet ;
function Fire_ok ()
{
super ();
fireBmp = new flash.display.BitmapData (400, 400, false, 0);
prevBmp = fireBmp.clone ();
tempBmp = fireBmp.clone ();
greyBmp = new flash.display.BitmapData (400, 400, false, 16743424);
mtx = new flash.geom.Matrix ();
pnt = new flash.geom.Point ();
blurF = new flash.filters.BlurFilter (7, 7, 1);
greyscaleCMF = new flash.filters.ColorMatrixFilter ([0.73, 0.83, 0.93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]);
fireCMF = new flash.filters.ColorMatrixFilter ([0.8, 0.05, 0, 0, 0, 0, 0.65, 0, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1, 0]);
dispMapF = new flash.filters.DisplacementMapFilter (tempBmp, pnt, 1, 2, 10, - 35, "clamp");
/////////////////////////////////////////////////////
}
function configUI ()
{
fireBmpHolder = this.createEmptyMovieClip ("fireBmpHolder", 1);
fireBmpHolder.attachBitmap (fireBmp, 1, "always", false);
fireBmpHolder.blendMode = "add";
}
function onEnterFrame ()
{
tempBmp.copyPixels (prevBmp, prevBmp.rectangle, pnt);
prevBmp.draw (webcam);
if (tempBmp.getPixel (1, 1) < 2)
{
return (undefined);
}
tempBmp.draw (prevBmp, mtx, null, "difference");
tempBmp.applyFilter (tempBmp, tempBmp.rectangle, pnt, greyscaleCMF);
tempBmp.threshold (tempBmp, tempBmp.rectangle, pnt, ">", 1638400, 4289379174, 16711680, false);
tempBmp.applyFilter (tempBmp, tempBmp.rectangle, pnt, blurF);
fireBmp.draw (tempBmp, mtx, null, "add");
tempBmp.perlinNoise (13, 10, 1, random (100) , false, true, 3, false);
tempBmp.draw (greyBmp, mtx, null, "darken");
fireBmp.applyFilter (fireBmp, fireBmp.rectangle, pnt, dispMapF);
fireBmp.applyFilter (fireBmp, fireBmp.rectangle, pnt, fireCMF);
}
static var CLASS_REF = Fire_ok;
static var LINKAGE_ID = "Fire_ok";
}
原文件下载
http://www.webjx.com/upfiles/20070823/20070823230005_webjxcom.rar