快速业务通道

Bitmap特效:被风吹散效果

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-07

详细代码:
  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. priv

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号