[AS3.0] 黒板とチョーク (1)

黒板とチョークみたいなのをAS3.0クラスで作ってみる。 :bouzu:

blackBoard1

:caution: 要 Flash Player 11.8 以上

This movie requires Flash Player 11.8.0

Main.as
package {

  import flash.display.Sprite;
  import flash.display.Shape;
  import flash.display.BitmapData;
  import flash.display.Bitmap;
  import flash.geom.Point;


  [SWF(backgroundColor="#FFFFFF", width="600", height="420", frameRate="30")]

  public class Main extends Sprite {
    [Embed(source = "assets/image.png")]
    private var Image:Class;
    // プロパティ
    private var bitmapData:BitmapData;
    private var bitmap:Bitmap;
    private static var point:Point = new Point();

    // コンストラクタ
    public function Main() {
      init();
    }

    // メソッド
    private function init():void {
      var board:Shape = new Shape();
      board.graphics.beginFill(0x005500);
      board.graphics.drawRect(0, 0, 600, 400);
      board.graphics.endFill();
      addChild(board);
      var base:Shape = new Shape();
      base.graphics.beginFill(0x996633);
      base.graphics.drawRect(0, 400, 600, 20);
      base.graphics.endFill();
      addChild(base);
      bitmapData = new BitmapData(400, 400, true, 0x00000000);
      bitmap = new Bitmap(bitmapData);
      addChild(bitmap);
      bitmap.x = 100;
      var image:Bitmap = new Image();
      var bd:BitmapData = image.bitmapData;
      var seed:uint = uint(Math.random()*10000);
      bitmapData.lock();
      bitmapData.pixelDissolve(bd, bd.rect, point, seed, 400*400*0.4);
      bitmapData.unlock();
    }

  }

}


This movie requires Flash Player 11.8.0

Main.as
package {

  import flash.display.Sprite;
  import flash.display.Shape;
  import flash.display.BitmapData;
  import flash.display.Bitmap;
  import flash.geom.Point;


  [SWF(backgroundColor="#FFFFFF", width="600", height="420", frameRate="30")]

  public class Main extends Sprite {
    [Embed(source = "assets/image.png")]
    private var Image:Class;
    // プロパティ
    private var bitmapData:BitmapData;
    private var bitmap:Bitmap;
    private static var point:Point = new Point();

    // コンストラクタ
    public function Main() {
      init();
    }

    // メソッド
    private function init():void {
      var board:Shape = new Shape();
      board.graphics.beginFill(0x005500);
      board.graphics.drawRect(0, 0, 600, 400);
      board.graphics.endFill();
      addChild(board);
      var base:Shape = new Shape();
      base.graphics.beginFill(0x996633);
      base.graphics.drawRect(0, 400, 600, 20);
      base.graphics.endFill();
      addChild(base);
      bitmapData = new BitmapData(400, 400, true, 0x00000000);
      bitmap = new Bitmap(bitmapData);
      addChild(bitmap);
      bitmap.x = 100;
      var image:Bitmap = new Image();
      var bd:BitmapData = image.bitmapData;
      var seed:uint = uint(Math.random()*10000);
      var color:uint = 0xFFFFFF66;
      bitmapData.lock();
      bitmapData.pixelDissolve(bd, bd.rect, point, seed, 400*400*0.4);
      bitmapData.threshold(bitmapData, bitmapData.rect, point, ">", 0x00000000, color, 0x00FFFFFF);
      bitmapData.unlock();
    }

  }

}

image.png (透過PNG)
blackBoard_image