Use flash as to create a code for the effect

Source: Internet
Author: User
Tags addchild

The wind blows away the effect.

Detailed code:


Package

{

Import Flash.display.Bitmap;

Import Flash.display.BitmapData;

Import Flash.display.MovieClip;

Import Flash.display.Sprite;

Import flash.events.Event;

Import Flash.filters.BlurFilter;

Import Flash.geom.Point;

Import Flash.geom.Rectangle;

/**

* ...

* @author Flashk

*/

public class Min extends Sprite

{

public Var A_mc:movieclip;

private Var Bd:bitmapdata;

private Var Bds:bitmapdata;

private Var Ps:array;

Public Function Min () {

BD = new BitmapData (1420, true);

BDS = new BitmapData (A_mc.width, A_mc.height, true);

Bds.draw (A_MC);

var bp:bitmap = new Bitmap ();

Bp.bitmapdata = BD;

This.addchild (BP);

Start ();

}

Private function Start (): void {

PS = new Array ();

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

for (var j:int = 1; J <= Bds.height; j + +) {

Ps.push (New Po (i, J, Bds.getpixel32 (I, J), Bds.width));

}

}

This.addeventlistener (Event.enter_frame, Render);

This.removechild (A_MC);

}

Private function Render (event:event): void {

var po;

Bd.fillrect (New Rectangle (0, 0, Bd.width, bd.height), 0);

Bd.applyfilter (BD, New Rectangle (0, 0, Bd.width, bd.height), new Point (0, 0), New Blurfilter (2, 2, 1));

Bd.lock ();

var len = ps.length;

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

PO = ps[i];

Po.move ();

Bd.setpixel32 (po.x, po.y+80, Po.color);

}

Bd.unlock ();

}

}

}

Class Po {

public Var X:number;

public Var Y:number;

public Var color:uint;

private Var Speed:number;

private var r:number = 0;

private Var By:number;

Public Function Po (X:number, Y:number, Color:uint,w:number) {

this.x = x;

This.y = y;

This.color = color;

This.speed = Math.random () *-(W-X)/2;

R = Math.random () * 50;

this.by = y;

}

Public function Move (): void {

Speed + 0.5;

if (speed>0) {

This.x + = speed;

R + 10;

This.y = this.by + Math.sin (r* math.pi/180) *50;

}

}

}

source file and swf download S2demo.rar:

Again play a mouse control, beauty by the wind blown scattered ...

Package

{

Import Flash.display.Bitmap;

Import Flash.display.BitmapData;

Import Flash.display.MovieClip;

Import Flash.display.Sprite;

Import flash.events.Event;

Import Flash.filters.BlurFilter;

Import Flash.filters.ColorMatrixFilter;

Import Flash.geom.ColorTransform;

Import Flash.geom.Point;

Import Flash.geom.Rectangle;

/**

* ...

* @author Flashk

*/

public class Min extends Sprite

{

public Var A_mc:movieclip;

private Var Bd:bitmapdata;

private Var Bds:bitmapdata;

private Var Ps:array;

private Var Ns:uint;

private Var Checks:array;

private Var Noise:bitmapdata;

private 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 (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 >> & 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 () *-(W-X)/3-20;

this.by = y;

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.