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.          * ...
  14.          * @author flashk
  15.          */
  16.         public class Min extends Sprite
  17.         {
  18.                 public var a_mc:MovieClip;
  19.                
  20.                 private var bd:BitmapData;
  21.                 private var bds:BitmapData;
  22.                 private var ps:Array;
  23.                
  24.                 public function Min() {
  25.                         bd = new BitmapData(1420, 300, true);
  26.                         bds = new BitmapData(a_mc.width, a_mc.height, true);
  27.                         bds.draw(a_mc);
  28.                         var bp:Bitmap = new Bitmap();
  29.                         bp.bitmapData = bd;
  30.                         this.addChild(bp);
  31.                         start();
  32.                 }
  33.                 private function start():void {                       
  34.                         ps = new Array();
  35.                         for (var i:int = 1; i <= bds.width; i++) {
  36.                                 for (var j:int = 1; j <= bds.height; j++) {
  37.                                         ps.push(new Po(i, j, bds.getPixel32(i, j),bds.width));
  38.                                 }
  39.                         }
  40.                         this.addEventListener(Event.ENTER_FRAME, render);
  41.                         this.removeChild(a_mc);
  42.                 }
  43.                 private function render(event:Event):void {
  44.                         var po;
  45.                         //bd.fillRect(new Rectangle(0, 0, bd.width, bd.height), 0);
  46.                         bd.applyFilter(bd, new Rectangle(0, 0, bd.width, bd.height), new Point(0, 0), new BlurFilter(2, 2, 1));
  47.                         bd.lock();
  48.                         var len = ps.length;
  49.                         for (var i:int = 0 ; i < len; i+=1) {
  50.                                 po = ps[i];
  51.                                 po.move();
  52.                                 bd.setPixel32(po.x, po.y+80, po.color);
  53.                         }
  54.                         bd.unlock();
  55.                 }
  56.         }
  57.        
  58. }
  59. class Po {
  60.         public var x:Number;
  61.         public var y:Number;
  62.         public var color:uint;
  63.         private var speed:Number;
  64.         private var r:Number = 0;
  65.         private var by:Number;
  66.        
  67.         public function Po(x:Number, y:Number, color:uint,w:Number) {
  68.                 this.x = x;
  69.                 this.y = y;
  70.                 this.color = color;
  71.                 this.speed = Math.random() * 10 - (w - x) / 2;
  72.                 //r = Math.random() * 50;
  73.                 this.by = y;
  74.         }
  75.         public function move():void {
  76.                 speed += 0.5;
  77.                 if(speed>0){
  78.                         this.x += speed;
  79.                         r += 10;
  80.                         this.y = this.by + Math.sin(r* Math.PI/180)*50;
  81.                 }
  82.         }
  83. }

原文来自flex培训中心