用户名: 密码: 验证码: QQ--程序群:31736530 动画群:38836599
闪无忧
 
首 页 业界新闻 业界杂谈 Flash教程 Flash源码 Flash图书 Flash酷站 Flex & AIR 供求信息
   本栏目通告:   有意向写收费精品教程的朋友,请联系本站合作
当前位置 :首页>flash教程>Flash动画特效>列表

Bitmap打造被风吹散flash特效

[来源: | 作者: | 时间:2009-05-13 | 点击:  | 收藏本文  【 】]
5uflash文章摘要:Bitmap特效,被风吹散效果。 详细代码: package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.MovieClip; import flash.display.Sprite;
Bitmap特效,被风吹散效果。

详细代码:

  1. package

  2. {

  3. import flash.display.Bitmap;

  4. import flash.display.BitmapData;

  5. import flash.display.MovieClip;

  6. import flash.display.Sprite;

  7. import flash.events.Event;

  8. import flash.filters.BlurFilter;

  9. import flash.geom.Point;

  10. import flash.geom.Rectangle;



  11. /**

  12. * ...

  13. * @author flashk

  14. */

  15. public class Min extends Sprite

  16. {

  17. public var a_mc:MovieClip;



  18. private var bd:BitmapData;

  19. private var bds:BitmapData;

  20. private var ps:Array;



  21. public function Min() {

  22. bd = new BitmapData(1420, 300, true);

  23. bds = new BitmapData(a_mc.width, a_mc.height, true);

  24. bds.draw(a_mc);

  25. var bp:Bitmap = new Bitmap();

  26. bp.bitmapData = bd;

  27. this.addChild(bp);

  28. start();

  29. }

  30. private function start():void {

  31. ps = new Array();

  32. for (var i:int = 1; i <= bds.width; i++) {

  33. for (var j:int = 1; j <= bds.height; j++) {

  34. ps.push(new Po(i, j, bds.getPixel32(i, j),bds.width));

  35. }

  36. }

  37. this.addEventListener(Event.ENTER_FRAME, render);

  38. this.removeChild(a_mc);

  39. }

  40. private function render(event:Event):void {

  41. var po;

  42. //bd.fillRect(new Rectangle(0, 0, bd.width, bd.height), 0);

  43. bd.applyFilter(bd, new Rectangle(0, 0, bd.width, bd.height), new Point(0, 0), new BlurFilter(2, 2, 1));

  44. bd.lock();

  45. var len = ps.length;

  46. for (var i:int = 0 ; i < len; i+=1) {

  47. po = ps[i];

  48. po.move();

  49. bd.setPixel32(po.x, po.y+80, po.color);

  50. }

  51. bd.unlock();

  52. }

  53. }



  54. }

  55. class Po {

  56. public var x:Number;

  57. public var y:Number;

  58. public var color:uint;

  59. private var speed:Number;

  60. private var r:Number = 0;

  61. private var by:Number;



  62. public function Po(x:Number, y:Number, color:uint,w:Number) {

  63. this.x = x;

  64. this.y = y;

  65. this.color = color;

  66. this.speed = Math.random() * 10 - (w - x) / 2;

  67. //r = Math.random() * 50;

  68. this.by = y;

  69. }

  70. public function move():void {

  71. speed += 0.5;

  72. if(speed>0){

  73. this.x += speed;

  74. r += 10;

  75. this.y = this.by + Math.sin(r* Math.PI/180)*50;

  76. }

  77. }

  78. }

源文件和swf下载s2demo.rar

再来玩个加鼠标控制的,美女被风吹散...
  1. package

  2. {

  3. import flash.display.Bitmap;

  4. import flash.display.BitmapData;

  5. import flash.display.MovieClip;

  6. import flash.display.Sprite;

  7. import flash.events.Event;

  8. import flash.filters.BlurFilter;

  9. import flash.filters.ColorMatrixFilter;

  10. import flash.geom.ColorTransform;

  11. import flash.geom.Point;

  12. import flash.geom.Rectangle;



  13. /**

  14. * ...

  15. * @author flashk

  16. */

  17. public class Min extends Sprite

  18. {

  19. public var a_mc:MovieClip;



  20. private var bd:BitmapData;

  21. private var bds:BitmapData;

  22. private var ps:Array;

  23. private var ns:uint;

  24. private var checks:Array;

  25. private var noise:BitmapData;

  26. private var randomSeed:Number;

  27. private var image:BitmapData;

  28. private var rect:Rectangle;

  29. private var cTra:ColorTransform;

  30. private var vectorList:Array;

  31. private var num:uint = 10000;



  32. public function Min() {



  33. noise = new BitmapData(a_mc.width, a_mc.height, false, 0x000000);

  34. randomSeed = Math.floor(Math.random() * 0xFFFF);

  35. noise.perlinNoise(a_mc.width, a_mc.height, 4, randomSeed, false, false, 1 | 2 | 0 | 0 );

  36. image = new BitmapData(465, 465, true, 0);

  37. this.addChild(new Bitmap(image));

  38. rect = new Rectangle( 0, 0, 465, 465 )

  39. cTra = new ColorTransform(1, 1, 1, 0.9, 0, 0, 0, 0)



  40. bd = new BitmapData(600, 450, true);

  41. bds = new BitmapData(a_mc.width, a_mc.height, true,0x00FFFFFF);

  42. bds.draw(a_mc);

  43. var bp:Bitmap = new Bitmap();

  44. bp.bitmapData = bd;

  45. ps = new Array();

  46. start(1);

  47. this.removeChild(a_mc);

  48. }

  49. private function start(s:uint):void {

  50. ns = s;

  51. vectorList = [];

  52. for (var i:int = s; i <= bds.width; i++) {

  53. for (var j:int = 1; j <= bds.height; j++) {

  54. vectorList.push(new Po(i, j, bds.getPixel32(i, j),bds.width,this));

  55. }

  56. }

  57. this.addEventListener(Event.ENTER_FRAME, render);

  58. }

  59. private function render(event:Event):void {

  60. image.colorTransform( rect, cTra );

  61. image.lock();

  62. var len:uint = vectorList.length;

  63. for (var i:uint = 0; i < len; i++) {

  64. var body:Po = vectorList[i];

  65. body.speed += 0.4;

  66. if(body.speed>0){

  67. var col:Number = noise.getPixel(body.px, body.py);

  68. body.ax += ((col >> 16 & 0xFF) - 128)/1000;

  69. body.ay += ((col >> 8 & 0xFF) -128)/1000;



  70. body.vx += body.ax;

  71. body.vy += body.ay;

  72. body.px += body.vx;

  73. body.py += body.vy;



  74. body.ax *= .975;

  75. body.ay *= .975;

  76. body.vx *= .92;

  77. body.vy *= .92;

  78. }

  79. if (body.px < 0) {

  80. vectorList.splice(i, 1);

  81. len -= 1;

  82. }

  83. image.setPixel32( body.px, body.py+100, body.color );

  84. }

  85. image.unlock();

  86. }

  87. }

  88. }

  89. class Po {

  90. public var x:Number;

  91. public var y:Number;

  92. public var color:uint;

  93. public var speed:Number;

  94. private var r:Number = 0;

  95. private var by:Number;

  96. public var vx:Number = 0;

  97. public var vy:Number = 0;

  98. public var ax:Number = 0;

  99. public var ay:Number = 0;

  100. public var px:Number;

  101. public var py:Number;



  102. public function Po(x:Number, y:Number, color:uint,w:Number,eventLis:Object) {

  103. this.x = x;

  104. this.y = y;

  105. this.px = x;

  106. this.py = y;

  107. this.color = color;

  108. this.speed = Math.random() * 15 - (w - x) / 3 -20;

  109. this.by = y;

  110. }

  111. }

鼠标控制swf效果:s2wind-mouseControl.rar

文章如果有错误或者缺少文件,请发邮件提交给我们
上一篇:最逼真透明雪花飘落特效
下一篇:仿真艺术设计3.1--遮罩运用打造旋转的地球
>>> 最新评论:(共有 0 位网友发表了评论)      查看所有评论
  发表评论
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
·本站发布内容均为客观表达作者观点,不代表闪无忧立场,请勿攻击和漫骂
·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任
·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据
·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为
  教程分类
  基础操作   动画特效
  应用开发   组件学习
  As程序   动画教程
  Flash cs3   AS 3.0
  FCS/FMS教程   Loading教程
  Flash与Web   Flash教程连载
  Flash 3d
  相关文章
·falsh制作数字落下黑客帝国动画
·flash打造最逼真的鼠标划过水波
·flash旋转立体字效果
·星球大战文字flash动画特效
·庆祝春节仿真flash烟花动画教程
·flash渐变制作烟雾效果
·flash格式化的烟雾效果制作
·flash打造蒸汽效果
·AS3 Waterfall类打造瀑布效果
·flash cs4打造扑克牌简易翻转的
  热门文章
·Flash进度条的制作详细讲解(组图)
·Flex 3 AdvancedDataGrid的使用(第二
·全Flash动画网站实现的基础教学
·FLV播放器汇总
·FLASH+XML相册(附源码)
·flash幻灯片网页效果
·超酷flash光晕移动效果
·Flash打造简单的飘雪动画视觉特效
·flash水影效果字
·flash春雷闪电效果
·Flash制作大雪纷飞效果动画
关于我们 - 免责声明 - 网站地图 - 商务服务 - 联系我们 - RSS地图
©CopyRight 2006-2008, 5UFlash.COM, Inc. All Rights Reserved
鲁ICP备06034971号