快速业务通道

Bitmap特效:被风吹散效果

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-07
ate var randomSeed:Number;
  • private var image:BitmapData;
  • private var rect:Rectangle;
  • private var cTra:ColorTransform;
  • private var vectorList:Array;
  • private var num:uint = 10000;
  • public function Min() {
  • noise = new BitmapData(a_mc.width, a_mc.height, false, 0x000000);
  • randomSeed = Math.floor(Math.random() * 0xFFFF);
  • noise.perlinNoise(a_mc.width, a_mc.height, 4, randomSeed, false, false, 1 | 2 | 0 | 0 );
  • image = new BitmapData(465, 465, true, 0);
  • this.addChild(new Bitmap(image));
  • rect = new Rectangle( 0, 0, 465, 465 )
  • cTra = new ColorTransform(1, 1, 1, 0.9, 0, 0, 0, 0)
  • bd = new BitmapData(600, 450, true);
  • bds = new BitmapData(a_mc.width, a_mc.height, true,0x00FFFFFF);
  • bds.draw(a_mc);
  • var bp:Bitmap = new Bitmap();
  • bp.bitmapData = bd;
  • ps = new Array();
  • start(1);
  • this.removeChild(a_mc);
  • }
  • private function start(s:uint):void {
  • ns = s;
  • vectorList = [];
  • for (var i:int = s; i <= bds.width; i++) {
  • for (var j:int = 1; j <= bds.height; j++) {
  • vectorList.push(new Po(i, j, bds.getPixel32(i, j),bds.width,this));
  • }
  • }
  • this.addEventListener(Event.ENTER_FRAME, render);
  • }
  • private function render(event:Event):void {
  • image.colorTransform( rect, cTra );
  • image.lock();
  • var len:uint = vectorList.length;
  • for (var i:uint = 0; i < len; i++) {
  • var body:Po = vectorList[i];
  • body.speed += 0.4;
  • if(body.speed>0){
  • var col:Number = noise.getPixel(body.px, body.py);
  • body.ax += ((col >> 16 & 0xFF) - 128)/1000;
  • body.ay += ((col >> 8 & 0xFF) -128)/1000;
  • body.vx += body.ax;
  • body.vy += body.ay;
  • body.px += body.vx;
  • body.py += body.vy;
  • body.ax *= .975;
  • body.ay *= .975;
  • body.vx *= .92;
  • body.vy *= .92;
  • }
  • if (body.px < 0) {
  • vectorList.splice(i, 1);
  • len -= 1;
  • }
  • image.setPixel32( body.px, body.py+100, body.color );
  • }
  • image.unlock();
  • }
  • }
  • }
  • class Po {
  • public var x:Number;
  • public var y:Number;
  • public var color:uint;
  • public var speed:Number;
  • private var r:Number = 0;
  • private var by:Number;
  • public var vx:Number = 0;
  • public var vy:Number = 0;
  • public var ax:Number = 0;
  • public var ay:Number = 0;
  • public var px:Number;
  • public var py:Number;
  • public function Po(x:Number, y:Number, color:uint,w:Number,eventLis:Object) {
  • this.x = x;
  • this.y = y;
  • this.px = x;
  • this.py = y;
  • this.color = color;
  • this.speed = Math.random() * 15 - (w - x) / 3 -20;
  • this.by = y;
  • }
  • }
  • 鼠标控制swf效果: s2wind-mouseControl.rar 关键词:

    凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站: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号