WEB开发网
开发学院图形图像Flash Flash AS实例教程:用纯AS制作火焰特效 阅读

Flash AS实例教程:用纯AS制作火焰特效

 2007-08-25 11:08:45 来源:WEB开发网   
核心提示:本文示例源代码或素材下载 首先申明不是偶原创,偶只是把效果综合了一下,Flash AS实例教程:用纯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";
}

Tags:Flash AS 实例

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接