网页教学网
 当前位置: 网页教学网 >> 动画制作 >> Flash action技术 >> 阅读:Flash有趣实验:用视频阻挡泡泡特效
[ HTML ] [ FW ] [ DW ] [ FP ] [ JS ] [ XML ] [ CSS ] [ 图象 ] [ FLASH ] [ .NET ] [ ASP ] [ JSP ] [ PHP ] [ 数据 ] [ 系统 ] [ 安全 ] [ 素材 ] [ 建站 ] [ 主机 ] [ 入门 ] [ 技巧 ]

Flash有趣实验:用视频阻挡泡泡特效

http://www.webjx.com  更新日期:2007-06-19 22:11  出处:闪吧BBS  作者:终极讨厌 收藏本文

有摄像头才可以试验哦!!

下面是代码:

var cam:Camera = Camera.get();
cam.setMode(cam.width, cam.height, 25);
video.attachVideo(cam);
var depth_num:Number = 0;
var list_array:Array;
list_array = new Array();
m = new flash.geom.Matrix();
now = new flash.display.BitmapData(video._width, video._height);
out = new flash.display.BitmapData(video._width, video._height);
this.createEmptyMovieClip("out_mc", 50);
out_mc.attachBitmap(out, 1);
out_mc._x = 160;
this.onEnterFrame = function() {
now.draw(video, m);
done = now.clone();
done.draw(before, m, null, "difference");
done.threshold(done, done.rectangle, done.rectangle.topLeft, ">", 4.279309E+009, 4.294902E+009, 16777215, false);
list_array.push(done.clone());
if (list_array.length>5) {
  list_array.shift().dispose();
}
var r_num9 = list_array.length;
var r_num8 = 255;
var r_num7;
out.fillRect(out.rectangle, 0);
before = now.clone();
for (var c:Number = 0; c<r_num9; c++) {
  r_num7 = c*r_num8;
  out.threshold(list_array[c], out.rectangle, out.rectangle.topLeft, "==", 4.294902E+009, -16777216 | r_num7 << 16 | 0 | 0, 16777215, false);
}
depth_num++;
attachMovie("pao_mc", "pao_mc"+depth_num, depth_num+100, {_x:Math.random()*550, _y:Math.random()*400, _xspeed:3-(Math.random()*6+1), _yspeed:Math.random()*3+1, _scale:Math.random()*20+20});
var color:Color = new Color(this["pao_mc"+depth_num]);
color.setRGB(Math.random()*0xffffff);
this["pao_mc"+depth_num]._xscale = this["pao_mc"+depth_num]._yscale=this["pao_mc"+depth_num]._xscale._scale;
this["pao_mc"+depth_num].onEnterFrame = function() {
  this._xscale += this._scale/60;
  this._yscale = this._xscale;
  this._alpha = 166-this._xscale;
  trace(out.getPixel(this._x, this._y));
  if (out.getPixel(this._x, this._y)<=0) {
   this._x -= this._xspeed;
   this._y -= this._yspeed;
  }
  if (this._x<=0 || this._y<=0 || this._x>=550) {
   this.removeMovieClip();
  }
};
};
stop();

源文件下载:点击这里下载源文件

关键词:
推荐给好友】【关闭
最新五条评论
查看全部评论
评论总数 0
您的评论
用户名: 新注册) 密 码: 匿名:
·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任
·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据
·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为