论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Flash AS教程
Tag:2.0,3.0菜鸟,游戏,,cs,技巧,源码,,文本,文字,函数,音乐,随机,拖拽,asp,access,xml,mc,视频教程

利用Bitmap特效 之 美女被风吹散

文章类别:Flash AS | 发表日期:2009-8-3 10:11:31

利用Bitmap特效 之 美女被风吹散

以下是我在学Flash as中整理出的一个用Bitmap特效制作出来的“美女被风吹散”的小游戏,跟大家分享一下。

代码:
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, 300, 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() * 10 - (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;
}
}
}

视频教程列表
文章教程搜索
 
Flash AS推荐教程
Flash AS热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058