notice: Flash editor updated! Join the development! Thanks to MiniBuilder


embed

FAVORITE BY
:
:
:
:
:
:
キラキラキラキラ
:
Particleキラキラパーティクル!雪!
:
当たり判定
:
:
:
effectきらきら
:
:
:
:
:
:
yılbaşı için iyi bir efekt
:
:
:
きれい
:
きらきらの雪がつもる
:
particlesテキスト
:
:
particlesnowsaqooshaneigeparticulesbeautiful particles use
:
bitmapdataparticles
:
particle
:
:
snow雪が降って文字浮き上がり
:
snow particle
:
:
:
:
Snow - Falls from top and builds on text
:
:
キラキラができるからくりが面白い
:
:
:
snowgetpixelsetpixelこれはすごい
:
Snow!
:
勉強になります
:
いつもお世話になっております
:
キラキラ雪がきれい!
:
これはwonderfl!!
FORKED
  1. // forked from Saqoosha's Snow
  2. package {
  3.     
  4.     import flash.display.Bitmap;
  5.     import flash.display.BitmapData;
  6.     import flash.display.BlendMode;
  7.     import flash.display.PixelSnapping;
  8.     import flash.display.Sprite;
  9.     import flash.events.Event;
  10.     import flash.filters.BlurFilter;
  11.     import flash.geom.Matrix;
  12.     import flash.geom.Point;
  13.     import flash.text.TextField;
  14.     import flash.text.TextFieldAutoSize;
  15.     import flash.text.TextFormat;
  16.         import net.hires.debug.Stats;
  17.     [SWF(width=465, height=465, backgroundColor=0x0, frameRate=120)]
  18.     public class Saq001 extends Sprite {
  19.         
  20.         private static const GRAVITY:Number = 20;
  21.         private static const DRAG:Number = 0.3;
  22.         
  23.         private var _canvas:BitmapData;
  24.         private var _glow:BitmapData;
  25.         private var _glowMtx:Matrix;
  26.         private var _forceMap:BitmapData;
  27.         private var _snow:Array;
  28.         
  29.         public function Saq001() {
  30.             this._canvas = new BitmapData(465465false, 0x0); // カンバスをつくる。ここに 1 pixel ずつ描いていくよ
  31.             this.addChild(new Bitmap(this._canvas)) as  Bitmap;  // stage に配置
  32.             
  33.             this._glow = new BitmapData(465 / 4465 / 4false, 0x0); // キラキラを描く用のん。カンバスの 4 分の 1 のサイズ
  34.             var bm:Bitmap = this.addChild(new Bitmap(this._glow, PixelSnapping.NEVER, true)) as Bitmap; // smoothing を true にして配置
  35.             bm.scaleX = bm.scaleY = 4// 4 倍にする。
  36.             bm.blendMode = BlendMode.ADD; // 加算モードで合成
  37.             this._glowMtx = new Matrix(0.25000.25);
  38.             
  39.             // 雪を積もらせるかたちを BitmapData に描く。
  40.             var tf:TextField = new TextField();
  41.             tf.defaultTextFormat = new TextFormat('Verdana'64, 0xffffff, true); 
  42.             tf.autoSize = TextFieldAutoSize.LEFT;
  43.             tf.text = 'Wonderfl!!';
  44.             tf.x = (465 - tf.width) / 2;
  45.             tf.y = (465 - tf.height) / 2;
  46.             this._forceMap = new BitmapData(465465false, 0x0);
  47.             this._forceMap.draw(tf, tf.transform.matrix);
  48.             this._forceMap.applyFilter(this._forceMap, this._forceMap.rect, new Point(00), new BlurFilter(88));
  49.             
  50.             this._snow = []; // 雪パーティクルはここにいれておくよ。
  51.             
  52.                         this.addChild(new Stats());
  53.             this.addEventListener(Event.ENTER_FRAME, this.update); // 毎フレーム update を呼ぶよ
  54.         }
  55.         
  56.         // 雪を 1 粒発生させる関数
  57.         public function emitParticle(ex:Number, ey:Number, s:Number = 1, c:int = 0xffffff, vx:Number = 0, vy:Number = 0):void {
  58.             var p:SnowParticle = new SnowParticle(); // 作って
  59.             // パラメータ設定して
  60.             p.x = ex;
  61.             p.y = ey;
  62.             p.vx = vx;
  63.             p.vy = vy;
  64.             p.s = s;
  65.             p.c = c;
  66.             this._snow.push(p); // 保存
  67.         }
  68.         
  69.         // 雪を動かすよーー
  70.         public function update(e:Event):void {
  71.             this._canvas.lock(); // いっぱい setPixel するときは必ず lock しよう
  72.             this._canvas.fillRect(this._canvas.rect, 0x0); // カンバスをクリア
  73.             var n:int = this._snow.length;
  74.             var d:Number;
  75.             var gravity:Number = GRAVITY / 1000// あらかじめ計算しとく
  76.             while (n--) {
  77.                 var p:SnowParticle = this._snow[n];
  78.                 p.vy += gravity * p.s; // まず重力を加える
  79.                 p.vx *= 0.99// 空気抵抗
  80.                 p.vy *= 0.99// y 方向にも
  81.                 d = 1 - (this._forceMap.getPixel(p.x, p.y) / 0xffffff) * DRAG; // forceMap にもとづいて抵抗値を計算。黒→速い、白→遅い。
  82.                 p.vx *= d; // forceMap から得た抵抗値を適用
  83.                 p.vy *= d; // y 方向にも
  84.                 p.x += p.vx; // 動かす
  85.                 p.y += p.vy;
  86.                 this._canvas.setPixel(p.x, p.y, p.c); // 雪 1 粒描く
  87.                 if (p.y > this.stage.stageHeight) { // もし画面外にでちゃったら
  88.                     this._snow.splice(n, 1); // とりのぞく
  89.                 }
  90.             }
  91.             this._canvas.unlock(); // lock したやつは必ず unlock
  92.             this._glow.draw(this._canvas, this._glowMtx); // キラキラを描く
  93.             
  94.             // 雪を発生させますよ
  95.             n = 10;
  96.             while (n--) {
  97.                 this.emitParticle(Math.random() * this.stage.stageWidth, 0, Math.random() + 0.5);
  98.             }
  99.         }
  100.     }
  101. }
  102. class SnowParticle {
  103.     
  104.     public var x:Number;
  105.     public var y:Number;
  106.     public var vx:Number;
  107.     public var vy:Number;
  108.     public var s:Number;
  109.     public var c:int;
  110.     
  111.     public function SnowParticle() {
  112.         this.x = 0;
  113.         this.y = 0;
  114.         this.vx = 0;
  115.         this.vy = 0;
  116.         this.s = 1;
  117.         this.c = 0xffffff;
  118.     }
  119. }
noswf
  1. // forked from Saqoosha's Snow
  2. package {
  3.     
  4.     import flash.display.Bitmap;
  5.     import flash.display.BitmapData;
  6.     import flash.display.BlendMode;
  7.     import flash.display.PixelSnapping;
  8.     import flash.display.Sprite;
  9.     import flash.events.Event;
  10.     import flash.filters.BlurFilter;
  11.     import flash.geom.Matrix;
  12.     import flash.geom.Point;
  13.     import flash.text.TextField;
  14.     import flash.text.TextFieldAutoSize;
  15.     import flash.text.TextFormat;
  16.         import net.hires.debug.Stats;
  17.     [SWF(width=465, height=465, backgroundColor=0x0, frameRate=120)]
  18.     public class Saq001 extends Sprite {
  19.         
  20.         private static const GRAVITY:Number = 20;
  21.         private static const DRAG:Number = 0.3;
  22.         
  23.         private var _canvas:BitmapData;
  24.         private var _glow:BitmapData;
  25.         private var _glowMtx:Matrix;
  26.         private var _forceMap:BitmapData;
  27.         private var _snow:Array;
  28.         
  29.         public function Saq001() {
  30.             this._canvas = new BitmapData(465465false, 0x0); // カンバスをつくる。ここに 1 pixel ずつ描いていくよ
  31.             this.addChild(new Bitmap(this._canvas)) as  Bitmap;  // stage に配置
  32.             
  33.             this._glow = new BitmapData(465 / 4465 / 4false, 0x0); // キラキラを描く用のん。カンバスの 4 分の 1 のサイズ
  34.             var bm:Bitmap = this.addChild(new Bitmap(this._glow, PixelSnapping.NEVER, true)) as Bitmap; // smoothing を true にして配置
  35.             bm.scaleX = bm.scaleY = 4// 4 倍にする。
  36.             bm.blendMode = BlendMode.ADD; // 加算モードで合成
  37.             this._glowMtx = new Matrix(0.25000.25);
  38.             
  39.             // 雪を積もらせるかたちを BitmapData に描く。
  40.             var tf:TextField = new TextField();
  41.             tf.defaultTextFormat = new TextFormat('Verdana'64, 0xffffff, true); 
  42.             tf.autoSize = TextFieldAutoSize.LEFT;
  43.             tf.text = 'うんこ!';
  44.             tf.x = (465 - tf.width) / 2;
  45.             tf.y = (465 - tf.height) / 2;
  46.             this._forceMap = new BitmapData(465465false, 0x0);
  47.             this._forceMap.draw(tf, tf.transform.matrix);
  48.             this._forceMap.applyFilter(this._forceMap, this._forceMap.rect, new Point(00), new BlurFilter(88));
  49.             
  50.             this._snow = []; // 雪パーティクルはここにいれておくよ。
  51.             
  52.                         this.addChild(new Stats());
  53.             this.addEventListener(Event.ENTER_FRAME, this.update); // 毎フレーム update を呼ぶよ
  54.         }
  55.         
  56.         // 雪を 1 粒発生させる関数
  57.         public function emitParticle(ex:Number, ey:Number, s:Number = 1, c:int = 0xffffff, vx:Number = 0, vy:Number = 0):void {
  58.             var p:SnowParticle = new SnowParticle(); // 作って
  59.             // パラメータ設定して
  60.             p.x = ex;
  61.             p.y = ey;
  62.             p.vx = vx;
  63.             p.vy = vy;
  64.             p.s = s;
  65.             p.c = c;
  66.             this._snow.push(p); // 保存
  67.         }
  68.         
  69.         // 雪を動かすよーー
  70.         public function update(e:Event):void {
  71.             this._canvas.lock(); // いっぱい setPixel するときは必ず lock しよう
  72.             this._canvas.fillRect(this._canvas.rect, 0x0); // カンバスをクリア
  73.             var n:int = this._snow.length;
  74.             var d:Number;
  75.             var gravity:Number = GRAVITY / 1000// あらかじめ計算しとく
  76.             while (n--) {
  77.                 var p:SnowParticle = this._snow[n];
  78.                 p.vy += gravity * p.s; // まず重力を加える
  79.                 p.vx *= 0.99// 空気抵抗
  80.                 p.vy *= 0.99// y 方向にも
  81.                 d = 1 - (this._forceMap.getPixel(p.x, p.y) / 0xffffff) * DRAG; // forceMap にもとづいて抵抗値を計算。黒→速い、白→遅い。
  82.                 p.vx *= d; // forceMap から得た抵抗値を適用
  83.                 p.vy *= d; // y 方向にも
  84.                 p.x += p.vx; // 動かす
  85.                 p.y += p.vy;
  86.                 this._canvas.setPixel(p.x, p.y, p.c); // 雪 1 粒描く
  87.                 if (p.y > this.stage.stageHeight) { // もし画面外にでちゃったら
  88.                     this._snow.splice(n, 1); // とりのぞく
  89.                 }
  90.             }
  91.             this._canvas.unlock(); // lock したやつは必ず unlock
  92.             this._glow.draw(this._canvas, this._glowMtx); // キラキラを描く
  93.             
  94.             // 雪を発生させますよ
  95.             n = 10;
  96.             while (n--) {
  97.                 this.emitParticle(Math.random() * this.stage.stageWidth, 0, Math.random() + 0.5);
  98.             }
  99.         }
  100.     }
  101. }
  102. class SnowParticle {
  103.     
  104.     public var x:Number;
  105.     public var y:Number;
  106.     public var vx:Number;
  107.     public var vy:Number;
  108.     public var s:Number;
  109.     public var c:int;
  110.     
  111.     public function SnowParticle() {
  112.         this.x = 0;
  113.         this.y = 0;
  114.         this.vx = 0;
  115.         this.vy = 0;
  116.         this.s = 1;
  117.         this.c = 0xffffff;
  118.     }
  119. }
noswf
  1. // forked from Saqoosha's Snow
  2. package {
  3.     
  4.     import flash.display.Bitmap;
  5.     import flash.display.BitmapData;
  6.     import flash.display.BlendMode;
  7.     import flash.display.PixelSnapping;
  8.     import flash.display.Sprite;
  9.     import flash.events.Event;
  10.     import flash.filters.BlurFilter;
  11.     import flash.geom.Matrix;
  12.     import flash.geom.Point;
  13.     import flash.text.TextField;
  14.     import flash.text.TextFieldAutoSize;
  15.     import flash.text.TextFormat;
  16.         import net.hires.debug.Stats;
  17.     [SWF(width=465, height=465, backgroundColor=0x0, frameRate=120)]
  18.     public class Saq001 extends Sprite {
  19.         
  20.         private static const GRAVITY:Number = 20;
  21.         private static const DRAG:Number = 0.3;
  22.         
  23.         private var _canvas:BitmapData;
  24.         private var _glow:BitmapData;
  25.         private var _glowMtx:Matrix;
  26.         private var _forceMap:BitmapData;
  27.         private var _snow:Array;
  28.         
  29.         public function Saq001() {
  30.             this._canvas = new BitmapData(465465false, 0x0); // カンバスをつくる。ここに 1 pixel ずつ描いていくよ
  31.             this.addChild(new Bitmap(this._canvas)) as  Bitmap;  // stage に配置
  32.             
  33.             this._glow = new BitmapData(465 / 4465 / 4false, 0x0); // キラキラを描く用のん。カンバスの 4 分の 1 のサイズ
  34.             var bm:Bitmap = this.addChild(new Bitmap(this._glow, PixelSnapping.NEVER, true)) as Bitmap; // smoothing を true にして配置
  35.             bm.scaleX = bm.scaleY = 4// 4 倍にする。
  36.             bm.blendMode = BlendMode.ADD; // 加算モードで合成
  37.             this._glowMtx = new Matrix(0.25000.25);
  38.             
  39.             // 雪を積もらせるかたちを BitmapData に描く。
  40.             var tf:TextField = new TextField();
  41.             tf.defaultTextFormat = new TextFormat('Verdana'64, 0xffffff, true); 
  42.             tf.autoSize = TextFieldAutoSize.LEFT;
  43.             tf.text = 'Wonderfl!!';
  44.             tf.x = (465 - tf.width) / 2;
  45.             tf.y = (465 - tf.height) / 2;
  46.             this._forceMap = new BitmapData(465465false, 0x0);
  47.             this._forceMap.draw(tf, tf.transform.matrix);
  48.             this._forceMap.applyFilter(this._forceMap, this._forceMap.rect, new Point(00), new BlurFilter(88));
  49.             
  50.             this._snow = []; // 雪パーティクルはここにいれておくよ。
  51.             
  52.                         this.addChild(new Stats());
  53.             this.addEventListener(Event.ENTER_FRAME, this.update); // 毎フレーム update を呼ぶよ
  54.         }
  55.         
  56.         // 雪を 1 粒発生させる関数
  57.         public function emitParticle(ex:Number, ey:Number, s:Number = 1, c:int = 0xffffff, vx:Number = 0, vy:Number = 0):void {
  58.             var p:SnowParticle = new SnowParticle(); // 作って
  59.             // パラメータ設定して
  60.             p.x = ex;
  61.             p.y = ey;
  62.             p.vx = vx;
  63.             p.vy = vy;
  64.             p.s = s;
  65.             p.c = c;
  66.             this._snow.push(p); // 保存
  67.         }
  68.         
  69.         // 雪を動かすよーー
  70.         public function update(e:Event):void {
  71.             this._canvas.lock(); // いっぱい setPixel するときは必ず lock しよう
  72.             this._canvas.fillRect(this._canvas.rect, 0x0); // カンバスをクリア
  73.             var n:int = this._snow.length;
  74.             var d:Number;
  75.             var gravity:Number = GRAVITY / 1000// あらかじめ計算しとく
  76.             while (n--) {
  77.                 var p:SnowParticle = this._snow[n];
  78.                 p.vy += gravity * p.s; // まず重力を加える
  79.                 p.vx *= 0.99// 空気抵抗
  80.                 p.vy *= 0.99// y 方向にも
  81.                 d = 1 - (this._forceMap.getPixel(p.x, p.y) / 0xffffff) * DRAG; // forceMap にもとづいて抵抗値を計算。黒→速い、白→遅い。
  82.                 p.vx *= d; // forceMap から得た抵抗値を適用
  83.                 p.vy *= d; // y 方向にも
  84.                 p.x += p.vx; // 動かす
  85.                 p.y += p.vy;
  86.                 this._canvas.setPixel(p.x, p.y, p.c); // 雪 1 粒描く
  87.                 if (p.y > this.stage.stageHeight) { // もし画面外にでちゃったら
  88.                     this._snow.splice(n, 1); // とりのぞく
  89.                 }
  90.             }
  91.             this._canvas.unlock(); // lock したやつは必ず unlock
  92.             this._glow.draw(this._canvas, this._glowMtx); // キラキラを描く
  93.             
  94.             // 雪を発生させますよ
  95.             n = 10;
  96.             while (n--) {
  97.                 this.emitParticle(Math.random() * this.stage.stageWidth, 0, Math.random() + 0.5);
  98.             }
  99.         }
  100.     }
  101. }
  102. class SnowParticle {
  103.     
  104.     public var x:Number;
  105.     public var y:Number;
  106.     public var vx:Number;
  107.     public var vy:Number;
  108.     public var s:Number;
  109.     public var c:int;
  110.     
  111.     public function SnowParticle() {
  112.         this.x = 0;
  113.         this.y = 0;
  114.         this.vx = 0;
  115.         this.vy = 0;
  116.         this.s = 1;
  117.         this.c = 0xffffff;
  118.     }
  119. }
noswf
  1. // forked from Saqoosha's Snow
  2. package {
  3.     
  4.     import flash.display.Bitmap;
  5.     import flash.display.BitmapData;
  6.     import flash.display.BlendMode;
  7.     import flash.display.PixelSnapping;
  8.     import flash.display.Sprite;
  9.     import flash.events.Event;
  10.     import flash.filters.BlurFilter;
  11.     import flash.geom.Matrix;
  12.     import flash.geom.Point;
  13.     import flash.text.TextField;
  14.     import flash.text.TextFieldAutoSize;
  15.     import flash.text.TextFormat;
  16.         import net.hires.debug.Stats;
  17.     [SWF(width=465, height=465, backgroundColor=0x0, frameRate=120)]
  18.     public class Saq001 extends Sprite {
  19.         
  20.         private static const GRAVITY:Number = 20;
  21.         private static const DRAG:Number = 0.3;
  22.         
  23.         private var _canvas:BitmapData;
  24.         private var _glow:BitmapData;
  25.         private var _glowMtx:Matrix;
  26.         private var _forceMap:BitmapData;
  27.         private var _snow:Array;
  28.         
  29.         public function Saq001() {
  30.             this._canvas = new BitmapData(465465false, 0x0); // カンバスをつくる。ここに 1 pixel ずつ描いていくよ
  31.             this.addChild(new Bitmap(this._canvas)) as  Bitmap;  // stage に配置
  32.             
  33.             this._glow = new BitmapData(465 / 4465 / 4false, 0x0); // キラキラを描く用のん。カンバスの 4 分の 1 のサイズ
  34.             var bm:Bitmap = this.addChild(new Bitmap(this._glow, PixelSnapping.NEVER, true)) as Bitmap; // smoothing を true にして配置
  35.             bm.scaleX = bm.scaleY = 4// 4 倍にする。
  36.             bm.blendMode = BlendMode.ADD; // 加算モードで合成
  37.             this._glowMtx = new Matrix(0.25000.25);
  38.             
  39.             // 雪を積もらせるかたちを BitmapData に描く。
  40.             var tf:TextField = new TextField();
  41.             tf.defaultTextFormat = new TextFormat('Verdana'64, 0xffffff, true); 
  42.             tf.autoSize = TextFieldAutoSize.LEFT;
  43.             tf.text = 'Wonderfl!!';
  44.             tf.x = (465 - tf.width) / 2;
  45.             tf.y = (465 - tf.height) / 2;
  46.             this._forceMap = new BitmapData(465465false, 0x0);
  47.             this._forceMap.draw(tf, tf.transform.matrix);
  48.             this._forceMap.applyFilter(this._forceMap, this._forceMap.rect, new Point(00), new BlurFilter(88));
  49.             
  50.             this._snow = []; // 雪パーティクルはここにいれておくよ。
  51.             
  52.                         this.addChild(new Stats());
  53.             this.addEventListener(Event.ENTER_FRAME, this.update); // 毎フレーム update を呼ぶよ
  54.         }
  55.         
  56.         // 雪を 1 粒発生させる関数
  57.         public function emitParticle(ex:Number, ey:Number, s:Number = 1, c:int = 0xffffff, vx:Number = 0, vy:Number = 0):void {
  58.             var p:SnowParticle = new SnowParticle(); // 作って
  59.             // パラメータ設定して
  60.             p.x = ex;
  61.             p.y = ey;
  62.             p.vx = vx;
  63.             p.vy = vy;
  64.             p.s = s;
  65.             p.c = c;
  66.             this._snow.push(p); // 保存
  67.         }
  68.         
  69.         // 雪を動かすよーー
  70.         public function update(e:Event):void {
  71.             this._canvas.lock(); // いっぱい setPixel するときは必ず lock しよう
  72.             this._canvas.fillRect(this._canvas.rect, 0x0); // カンバスをクリア
  73.             var n:int = this._snow.length;
  74.             var d:Number;
  75.             var gravity:Number = GRAVITY / 1000// あらかじめ計算しとく
  76.             while (n--) {
  77.                 var p:SnowParticle = this._snow[n];
  78.                 p.vy += gravity * p.s; // まず重力を加える
  79.                 p.vx *= 0.99// 空気抵抗
  80.                 p.vy *= 0.99// y 方向にも
  81.                 d = 1 - (this._forceMap.getPixel(p.x, p.y) / 0xffffff) * DRAG; // forceMap にもとづいて抵抗値を計算。黒→速い、白→遅い。
  82.                 p.vx *= d; // forceMap から得た抵抗値を適用
  83.                 p.vy *= d; // y 方向にも
  84.                 p.x += p.vx; // 動かす
  85.                 p.y += p.vy;
  86.                 this._canvas.setPixel(p.x, p.y, p.c); // 雪 1 粒描く
  87.                 if (p.y > this.stage.stageHeight) { // もし画面外にでちゃったら
  88.                     this._snow.splice(n, 1); // とりのぞく
  89.                 }
  90.             }
  91.             this._canvas.unlock(); // lock したやつは必ず unlock
  92.             this._glow.draw(this._canvas, this._glowMtx); // キラキラを描く
  93.             
  94.             // 雪を発生させますよ
  95.             n = 10;
  96.             while (n--) {
  97.                 this.emitParticle(Math.random() * this.stage.stageWidth, 0, Math.random() + 0.5);
  98.             }
  99.         }
  100.     }
  101. }
  102. class SnowParticle {
  103.     
  104.     public var x:Number;
  105.     public var y:Number;
  106.     public var vx:Number;
  107.     public var vy:Number;
  108.     public var s:Number;
  109.     public var c:int;
  110.     
  111.     public function SnowParticle() {
  112.         this.x = 0;
  113.         this.y = 0;
  114.         this.vx = 0;
  115.         this.vy = 0;
  116.         this.s = 1;
  117.         this.c = 0xffffff;
  118.     }
  119. }
noswf
  1. // forked from Saqoosha's Snow
  2. package {
  3.     
  4.     import flash.display.Bitmap;
  5.     import flash.display.BitmapData;
  6.     import flash.display.BlendMode;
  7.     import flash.display.PixelSnapping;
  8.     import flash.display.Sprite;
  9.     import flash.events.Event;
  10.     import flash.filters.BlurFilter;
  11.     import flash.geom.Matrix;
  12.     import flash.geom.Point;
  13.     import flash.text.TextField;
  14.     import flash.text.TextFieldAutoSize;
  15.     import flash.text.TextFormat;
  16.         import net.hires.debug.Stats;
  17.     [SWF(width=465, height=465, backgroundColor=0x0, frameRate=120)]
  18.     public class Saq001 extends Sprite {
  19.         
  20.         private static const GRAVITY:Number = 20;
  21.         private static const DRAG:Number = 0.3;
  22.         
  23.         private var _canvas:BitmapData;
  24.         private var _glow:BitmapData;
  25.         private var _glowMtx:Matrix;
  26.         private var _forceMap:BitmapData;
  27.         private var _snow:Array;
  28.         
  29.         public function Saq001() {
  30.             this._canvas = new BitmapData(465465false, 0x0); // カンバスをつくる。ここに 1 pixel ずつ描いていくよ
  31.             this.addChild(new Bitmap(this._canvas)) as  Bitmap;  // stage に配置
  32.             
  33.             this._glow = new BitmapData(465 / 4465 / 4false, 0x0); // キラキラを描く用のん。カンバスの 4 分の 1 のサイズ
  34.             var bm:Bitmap = this.addChild(new Bitmap(this._glow, PixelSnapping.NEVER, true)) as Bitmap; // smoothing を true にして配置
  35.             bm.scaleX = bm.scaleY = 4// 4 倍にする。
  36.             bm.blendMode = BlendMode.ADD; // 加算モードで合成
  37.             this._glowMtx = new Matrix(0.25000.25);
  38.             
  39.             // 雪を積もらせるかたちを BitmapData に描く。
  40.             var tf:TextField = new TextField();
  41.             tf.defaultTextFormat = new TextFormat('Verdana'300, 0xffffff, true); 
  42.             tf.autoSize = TextFieldAutoSize.LEFT;
  43.             tf.text = '24';
  44.             tf.x = (465 - tf.width) / 2;
  45.             tf.y = (465 - tf.height) / 2;
  46.             this._forceMap = new BitmapData(465465false, 0x0);
  47.             this._forceMap.draw(tf, tf.transform.matrix);
  48.             this._forceMap.applyFilter(this._forceMap, this._forceMap.rect, new Point(00), new BlurFilter(88));
  49.             
  50.             this._snow = []; // 雪パーティクルはここにいれておくよ。
  51.             
  52.                         this.addChild(new Stats());
  53.             this.addEventListener(Event.ENTER_FRAME, this.update); // 毎フレーム update を呼ぶよ
  54.         }
  55.         
  56.         // 雪を 1 粒発生させる関数
  57.         public function emitParticle(ex:Number, ey:Number, s:Number = 1, c:int = 0xffffff, vx:Number = 0, vy:Number = 0):void {
  58.             var p:SnowParticle = new SnowParticle(); // 作って
  59.             // パラメータ設定して
  60.             p.x = ex;
  61.             p.y = ey;
  62.             p.vx = vx;
  63.             p.vy = vy;
  64.             p.s = s;
  65.             p.c = c;
  66.             this._snow.push(p); // 保存
  67.         }
  68.         
  69.         // 雪を動かすよーー
  70.         public function update(e:Event):void {
  71.             this._canvas.lock(); // いっぱい setPixel するときは必ず lock しよう
  72.             this._canvas.fillRect(this._canvas.rect, 0x0); // カンバスをクリア
  73.             var n:int = this._snow.length;
  74.             var d:Number;
  75.             var gravity:Number = GRAVITY / 1000// あらかじめ計算しとく
  76.             while (n--) {
  77.                 var p:SnowParticle = this._snow[n];
  78.                 p.vy += gravity * p.s; // まず重力を加える
  79.                 p.vx *= 0.99// 空気抵抗
  80.                 p.vy *= 0.99// y 方向にも
  81.                 d = 1 - (this._forceMap.getPixel(p.x, p.y) / 0xffffff) * DRAG; // forceMap にもとづいて抵抗値を計算。黒→速い、白→遅い。
  82.                 p.vx *= d; // forceMap から得た抵抗値を適用
  83.                 p.vy *= d; // y 方向にも
  84.                 p.x += p.vx; // 動かす
  85.                 p.y += p.vy;
  86.                 this._canvas.setPixel(p.x, p.y, p.c); // 雪 1 粒描く
  87.                 if (p.y > this.stage.stageHeight) { // もし画面外にでちゃったら
  88.                     this._snow.splice(n, 1); // とりのぞく
  89.                 }
  90.             }
  91.             this._canvas.unlock(); // lock したやつは必ず unlock
  92.             this._glow.draw(this._canvas, this._glowMtx); // キラキラを描く
  93.             
  94.             // 雪を発生させますよ
  95.             n = 10;
  96.             while (n--) {
  97.                 this.emitParticle(Math.random() * this.stage.stageWidth, 0, Math.random() + 0.5);
  98.             }
  99.         }
  100.     }
  101. }
  102. class SnowParticle {
  103.     
  104.     public var x:Number;
  105.     public var y:Number;
  106.     public var vx:Number;
  107.     public var vy:Number;
  108.     public var s:Number;
  109.     public var c:int;
  110.     
  111.     public function SnowParticle() {
  112.         this.x = 0;
  113.         this.y = 0;
  114.         this.vx = 0;
  115.         this.vy = 0;
  116.         this.s = 1;
  117.         this.c = 0xffffff;
  118.     }
  119. }
noswf
Get Adobe Flash Player