Checkmate

Takayuki Fukatsu

Professional
Flashにおいてドットパターン表現はあまり模索されていません。付属のBitmapPatternBuilderというクラスを使って、flashにおけるドットパターンを用いた表現の可能性を模索してください。
Professional
Dot pattern expression of flash is yet-to-be explored. Pursue the possibility of dot pattern expression, with given class "BitmapPatternBuilder."
Checkmateの遊び方
CHECKMATEはKingの称号をもつActionScript Masterたちの、問題にFORKする(プログラムを書き換える)ことで、回答していくFlash詰め将棋です。
下記にあるKingの書いたActionScriptにForkボタンをクリックして、プログラムを改造して、Kingをうならせてください。
How to participate CHECKMATE
CHECKMATE is chess like quiz solving contest by FORKing, meaning re-writing programs, to the quiz statement given by Kings, masters of ActionScript. Click "Fork" button and re-write scripts written by King, and impress him.
Checkmate Challengers
Schedule
Fork acceptance period: 2009-07-07/24 | Judging period: 2009-07-24/31 | Result presentation: 2009-07-31
結果発表 Result presentation
fladdict.professional

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


embed

FORKED
  1. // forked from checkmate's fladdict challenge for professionals
  2. /**
  3.  * Theme:
  4.  * Play with BitmapPatterBuilder.
  5.  * Purpose of this trial is to find the possibility of the dot pattern.
  6.  *
  7.  * by Takayuki Fukatsu aka fladdict
  8.  **/
  9. package {
  10.     import flash.display.Bitmap;
  11.     import flash.display.BitmapData;
  12.     import flash.display.Graphics;
  13.     import flash.display.Sprite;
  14.     import flash.display.StageScaleMode;
  15.     
  16.     
  17.     public class Professional extends Sprite {
  18.         public function Professional() {
  19.             stage.scaleMode = StageScaleMode.NO_SCALE;
  20.             
  21.             //generate bitmap pattern.
  22.             var pattern:BitmapData = sample1();
  23.             //var pattern:BitmapData = sample2();
  24.             //var pattern:BitmapData = sample3();
  25.             
  26.             var g:Graphics = graphics;
  27.             g.beginBitmapFill(pattern);
  28.             g.drawRect(0,0,480,480);
  29.             g.endFill();
  30.         }
  31.         
  32.         //most simple patern
  33.         public function sample1():BitmapData{
  34.             return BitmapPatternBuilder.build(
  35.                 [[1,0],
  36.                  [0,1]],
  37.                 [0xff000000, 0xffffffff]
  38.             );
  39.         }
  40.     
  41.         //larger pattern
  42.         public function sample2():BitmapData{
  43.              return BitmapPatternBuilder.build(
  44.                 [[1,0,0,1,],
  45.                  [0,1,1,0,],
  46.                  [0,1,1,0,],
  47.                  [1,0,0,1,]],
  48.                 [0xff000000, 0xffffff00]
  49.                 );
  50.         }
  51.     
  52.         //complex pattern
  53.         public function sample3():BitmapData{
  54.              return BitmapPatternBuilder.build(
  55.                 [[1,1,1,1,1,0],
  56.                  [1,2,2,2,1,0],
  57.                  [1,2,1,2,1,0],
  58.                  [1,2,2,2,1,0],
  59.                  [1,1,1,1,1,0],
  60.                  [0,0,0,0,0,0]],
  61.                 [0xff000000, 0xffffffff, 0xffff0000]
  62.                 );
  63.         }
  64.     }
  65. }
  66. /**-----------------------------------------------------
  67.  * Use following BitmapPatternBuilder class 
  68.  * 
  69.  * DO NOT CHANGE any codes below this comment.
  70.  *
  71.  * -----------------------------------------------------
  72. */
  73. import flash.display.Bitmap;
  74. import flash.display.BitmapData;
  75. import flash.display.Graphics;
  76.     
  77. class BitmapPatternBuilder{
  78.     /**
  79.      * creates BitmapData filled with dot pattern.
  80.      * First parameter is 2d array that contains color index for each pixels;
  81.      * Second parameter contains color reference table.
  82.      *
  83.      * @parameter pattern:Array 2d array that contains color index for each pixel.
  84.      * @parameter colors:Array 1d array that contains color table.
  85.      * @returns BitmapData
  86.      */
  87.     public static function build(pattern:Array, colors:Array):BitmapData{
  88.         var bitmapW:int = pattern[0].length;
  89.         var bitmapH:int = pattern.length;
  90.         var bmd:BitmapData = new BitmapData(bitmapW,bitmapH,true,0x000000);
  91.         for(var yy:int=0; yy<bitmapH; yy++){
  92.             for(var xx:int=0; xx<bitmapW; xx++){
  93.                 var color:int = colors[pattern[yy][xx]];
  94.                 bmd.setPixel32(xx, yy, color);
  95.             }
  96.         }
  97.         return bmd;
  98.     }
  99.     
  100.     /**
  101.      * short cut function for Graphics.beginBitmapFill with pattern.
  102.      */
  103.     public static function beginBitmapFill(pattern:Array, colors:Array, graphics:Graphics):void{
  104.         var bmd:BitmapData = build(pattern, colors);
  105.         graphics.beginBitmapFill(bmd);
  106.         bmd.dispose();        
  107.     }
  108. }
noswf
  1. // forked from checkmate's fladdict challenge for professionals
  2. /**
  3.  * Theme:
  4.  * Play with BitmapPatterBuilder.
  5.  * Purpose of this trial is to find the possibility of the dot pattern.
  6.  *
  7.  * by Takayuki Fukatsu aka fladdict
  8.  **/
  9. package {
  10.     import flash.display.Bitmap;
  11.     import flash.display.BitmapData;
  12.     import flash.display.Graphics;
  13.     import flash.display.Sprite;
  14.     import flash.display.StageScaleMode;
  15.     
  16.     
  17.     public class Professional extends Sprite {
  18.         public function Professional() {
  19.             stage.scaleMode = StageScaleMode.NO_SCALE;
  20.             
  21.             //generate bitmap pattern.
  22.             var pattern:BitmapData = sample1();
  23.             //var pattern:BitmapData = sample2();
  24.             //var pattern:BitmapData = sample3();
  25.             
  26.             var g:Graphics = graphics;
  27.             g.beginBitmapFill(pattern);
  28.             g.drawRect(0,0,480,480);
  29.             g.endFill();
  30.         }
  31.         
  32.         //most simple patern
  33.         public function sample1():BitmapData{
  34.             return BitmapPatternBuilder.build(
  35.                 [[1,0],
  36.                  [0,1]],
  37.                 [0xff000000, 0xffffffff]
  38.             );
  39.         }
  40.     
  41.         //larger pattern
  42.         public function sample2():BitmapData{
  43.              return BitmapPatternBuilder.build(
  44.                 [[1,0,0,1,],
  45.                  [0,1,1,0,],
  46.                  [0,1,1,0,],
  47.                  [1,0,0,1,]],
  48.                 [0xff000000, 0xffffff00]
  49.                 );
  50.         }
  51.     
  52.         //complex pattern
  53.         public function sample3():BitmapData{
  54.              return BitmapPatternBuilder.build(
  55.                 [[1,1,1,1,1,0],
  56.                  [1,2,2,2,1,0],
  57.                  [1,2,1,2,1,0],
  58.                  [1,2,2,2,1,0],
  59.                  [1,1,1,1,1,0],
  60.                  [0,0,0,0,0,0]],
  61.                 [0xff000000, 0xffffffff, 0xffff0000]
  62.                 );
  63.         }
  64.     }
  65. }
  66. /**-----------------------------------------------------
  67.  * Use following BitmapPatternBuilder class 
  68.  * 
  69.  * DO NOT CHANGE any codes below this comment.
  70.  *
  71.  * -----------------------------------------------------
  72. */
  73. import flash.display.Bitmap;
  74. import flash.display.BitmapData;
  75. import flash.display.Graphics;
  76.     
  77. class BitmapPatternBuilder{
  78.     /**
  79.      * creates BitmapData filled with dot pattern.
  80.      * First parameter is 2d array that contains color index for each pixels;
  81.      * Second parameter contains color reference table.
  82.      *
  83.      * @parameter pattern:Array 2d array that contains color index for each pixel.
  84.      * @parameter colors:Array 1d array that contains color table.
  85.      * @returns BitmapData
  86.      */
  87.     public static function build(pattern:Array, colors:Array):BitmapData{
  88.         var bitmapW:int = pattern[0].length;
  89.         var bitmapH:int = pattern.length;
  90.         var bmd:BitmapData = new BitmapData(bitmapW,bitmapH,true,0x000000);
  91.         for(var yy:int=0; yy<bitmapH; yy++){
  92.             for(var xx:int=0; xx<bitmapW; xx++){
  93.                 var color:int = colors[pattern[yy][xx]];
  94.                 bmd.setPixel32(xx, yy, color);
  95.             }
  96.         }
  97.         return bmd;
  98.     }
  99.     
  100.     /**
  101.      * short cut function for Graphics.beginBitmapFill with pattern.
  102.      */
  103.     public static function beginBitmapFill(pattern:Array, colors:Array, graphics:Graphics):void{
  104.         var bmd:BitmapData = build(pattern, colors);
  105.         graphics.beginBitmapFill(bmd);
  106.         bmd.dispose();        
  107.     }
  108. }
noswf
  1. // forked from checkmate's fladdict challenge for professionals
  2. /**
  3.  * Theme:
  4.  * Play with BitmapPatterBuilder.
  5.  * Purpose of this trial is to find the possibility of the dot pattern.
  6.  *
  7.  * by Takayuki Fukatsu aka fladdict
  8.  **/
  9. package {
  10.     import flash.display.Bitmap;
  11.     import flash.display.BitmapData;
  12.     import flash.display.Graphics;
  13.     import flash.display.Sprite;
  14.     import flash.display.StageScaleMode;
  15.     
  16.     
  17.     public class Professional extends Sprite {
  18.         public function Professional() {
  19.             stage.scaleMode = StageScaleMode.NO_SCALE;
  20.             
  21.             //generate bitmap pattern.
  22.             //var pattern:BitmapData = sample1();
  23.             var pattern:BitmapData = sample2();
  24.             //var pattern:BitmapData = sample3();
  25.             
  26.             var g:Graphics = graphics;
  27.             g.beginBitmapFill(pattern);
  28.             g.drawRect(0,0,480,480);
  29.             g.endFill();
  30.         }
  31.         
  32.         //most simple patern
  33.         public function sample1():BitmapData{
  34.             return BitmapPatternBuilder.build(
  35.                 [[1,0],
  36.                  [0,1]],
  37.                 [0xff000000, 0xffffffff]
  38.             );
  39.         }
  40.     
  41.         //larger pattern
  42.         public function sample2():BitmapData{
  43.              return BitmapPatternBuilder.build(
  44.                 [[1,0,0,1,],
  45.                  [0,1,1,0,],
  46.                  [0,1,1,0,],
  47.                  [1,0,0,1,]],
  48.                 [0xff000000, 0xffffff00]
  49.                 );
  50.         }
  51.     
  52.         //complex pattern
  53.         public function sample3():BitmapData{
  54.              return BitmapPatternBuilder.build(
  55.                 [[1,1,1,1,1,0],
  56.                  [1,2,2,2,1,0],
  57.                  [1,2,1,2,1,0],
  58.                  [1,2,2,2,1,0],
  59.                  [1,1,1,1,1,0],
  60.                  [0,0,0,0,0,0]],
  61.                 [0xff000000, 0xffffffff, 0xffff0000]
  62.                 );
  63.         }
  64.     }
  65. }
  66. /**-----------------------------------------------------
  67.  * Use following BitmapPatternBuilder class 
  68.  * 
  69.  * DO NOT CHANGE any codes below this comment.
  70.  *
  71.  * -----------------------------------------------------
  72. */
  73. import flash.display.Bitmap;
  74. import flash.display.BitmapData;
  75. import flash.display.Graphics;
  76.     
  77. class BitmapPatternBuilder{
  78.     /**
  79.      * creates BitmapData filled with dot pattern.
  80.      * First parameter is 2d array that contains color index for each pixels;
  81.      * Second parameter contains color reference table.
  82.      *
  83.      * @parameter pattern:Array 2d array that contains color index for each pixel.
  84.      * @parameter colors:Array 1d array that contains color table.
  85.      * @returns BitmapData
  86.      */
  87.     public static function build(pattern:Array, colors:Array):BitmapData{
  88.         var bitmapW:int = pattern[0].length;
  89.         var bitmapH:int = pattern.length;
  90.         var bmd:BitmapData = new BitmapData(bitmapW,bitmapH,true,0x000000);
  91.         for(var yy:int=0; yy<bitmapH; yy++){
  92.             for(var xx:int=0; xx<bitmapW; xx++){
  93.                 var color:int = colors[pattern[yy][xx]];
  94.                 bmd.setPixel32(xx, yy, color);
  95.             }
  96.         }
  97.         return bmd;
  98.     }
  99.     
  100.     /**
  101.      * short cut function for Graphics.beginBitmapFill with pattern.
  102.      */
  103.     public static function beginBitmapFill(pattern:Array, colors:Array, graphics:Graphics):void{
  104.         var bmd:BitmapData = build(pattern, colors);
  105.         graphics.beginBitmapFill(bmd);
  106.         bmd.dispose();        
  107.     }
  108. }
noswf

fladdict challenge for professionals マトリックスっぽいの [diff(253)]

  1. /**
  2.  * Theme:
  3.  * Play with BitmapPatterBuilder.
  4.  * Purpose of this trial is to find the possibility of the dot pattern.
  5.  *
  6.  * by Takayuki Fukatsu aka fladdict
  7.  **/
  8. package {
  9.     import com.flashdynamix.motion.Tweensy;
  10.     import com.flashdynamix.motion.TweensyTimeline;
  11.     import fl.motion.easing.Cubic;
  12.     import flash.display.Bitmap;
  13.     import flash.display.BitmapData;
  14.     import flash.display.BitmapDataChannel;
  15.     import flash.display.Graphics;
  16.     import flash.display.Shape;
  17.     import flash.display.Sprite;
  18.     import flash.display.StageScaleMode;
  19.     import flash.events.Event;
  20.     import flash.filters.BlurFilter;
  21.     import flash.geom.ColorTransform;
  22.     import flash.geom.Matrix;
  23.     import flash.geom.Point;
  24.     import flash.text.TextField;
  25.     import flash.text.TextFieldAutoSize;
  26.     
  27.     /**
  28.      * 間に合わんかった上に作りたかったものとちょっとちがう。
  29.      * さらにソースが汚すぎる。
  30.      * 朝ワンの時間だけで作るのは無理だな。
  31.      */
  32.     [SWF(width = "465", height = "465", backgroundColor = "0x0", frameRate = "30")]
  33.     public class Professional extends Sprite {
  34.         
  35.         private var patterns: Array;
  36.         private var texts: Array;
  37.         private var txtMatrix: Array;
  38.         private var txtMatrix2: Matrix = new Matrix();
  39.         private var length: int;
  40.         private var grid: BitmapData;
  41.         private var matrix: Matrix;
  42.         private var frame: int;
  43.         private var phase: int;
  44.         private var scale: int;
  45.         private var shape: Shape;
  46.         private var maskSp: Sprite;
  47.         private var bmd: BitmapData;
  48.         private var tmpBmd: BitmapData;
  49.         private var tmpBmd2: BitmapData;
  50.         private var point: Point = new Point();
  51.         private var blur: BlurFilter = new BlurFilter();
  52.         
  53.         public function Professional() {
  54.             stage.scaleMode = StageScaleMode.NO_SCALE;
  55.             patterns = makePatterns();
  56.             grid     = makeGrid();
  57.             shape = new Shape();
  58.             addChild(new Bitmap(bmd = new BitmapData(465465true, 0x0), "auto"true));
  59.             tmpBmd = bmd.clone();
  60.             tmpBmd2 = bmd.clone();
  61.             matrix = new Matrix();
  62.             scale = 100;
  63.             makeTexts();
  64.             addEventListener(Event.ENTER_FRAME, loop);
  65.         }
  66.         
  67.         private function makeTexts(): void
  68.         {
  69.             texts = [], txtMatrix = [];
  70.             var txt: TextField = new TextField(), str: String = "MATRIX", i: int, w: Number = 0, bmd: BitmapData, m: Matrix;
  71.             for (i = 0; i < str.length; i++ )
  72.             {
  73.                 txt.text = str.charAt(i);
  74.                 txt.autoSize = TextFieldAutoSize.LEFT;
  75.                 //txt.textColor = 0xFFFFFF;
  76.                 txt.scaleX = txt.scaleY = 4;
  77.                 bmd = new BitmapData(txt.width, txt.height, true, 0x0);
  78.                 bmd.draw(txt, txt.transform.matrix);
  79.                 texts.push(bmd);
  80.                 w += bmd.width + 50;
  81.             }
  82.             w /= 2;
  83.             w -= 78;
  84.             var timeline: TweensyTimeline;
  85.             for (i = 0; i < texts.length; i++ )
  86.             {
  87.                 bmd = texts[i];
  88.                 m = new Matrix();
  89.                 m.tx = (465 - w) / 2;
  90.                 m.ty = - 100;
  91.                 txtMatrix.push(m);
  92.                 w -= bmd.width
  93.                 switch (i)
  94.                 {
  95.                     case 0:
  96.                         w -= 40;
  97.                     break;
  98.                     case 1:
  99.                     case 2:
  100.                         w -= 20;
  101.                     break;
  102.                     case 3:
  103.                         w -= 30;
  104.                     break;
  105.                     case 4:
  106.                         w -= 10;
  107.                     break;
  108.                 }
  109.                 timeline = Tweensy.to(m, { ty: (465 - bmd.height) / 2 }, 1, Cubic.easeIn, Math.random() * 3);
  110.                 timeline.onComplete = onComp;
  111.             }
  112.         }
  113.         
  114.         private function onComp(): void
  115.         {
  116.             phase ++;
  117.         }
  118.         
  119.         private function loop(e:Event):void 
  120.         {
  121.             var b: BitmapData;
  122.             var m: Matrix;
  123.             switch (phase)
  124.             {
  125.                 case 6:
  126.                     scale ++;
  127.                     if (scale > 600) phase = 7;
  128.                 break;
  129.                 case 7:
  130.                     scale --;
  131.                     if (scale < 2) phase = 6;
  132.                 break;
  133.             }
  134.             matrix.a = matrix.d = scale / 300;
  135.             matrix.tx = matrix.ty = 232
  136.             var g:Graphics = shape.graphics;
  137.             var pattern: BitmapData = patterns[frame % length];
  138.             g.clear();
  139.             g.beginBitmapFill(pattern, matrix, truetrue);
  140.             g.drawRect(00480480);
  141.             g.endFill();
  142.             g.beginBitmapFill(grid);
  143.             g.drawRect(00480480);
  144.             tmpBmd.lock();
  145.             tmpBmd.fillRect(tmpBmd.rect, 0x0);
  146.             var n: int = texts.length, i: int;
  147.             for (i = 0; i < n; i++ )
  148.             {
  149.                 b = texts[i];
  150.                 m = txtMatrix[i];
  151.                 tmpBmd.draw(b, m, nullnullnulltrue);
  152.             }
  153.             tmpBmd.unlock();
  154.             tmpBmd2.lock();
  155.             txtMatrix2.a = txtMatrix2.d = Cubic.easeIn(scale, 0.3150600);
  156.             txtMatrix2.tx = txtMatrix2.ty = (465 - 465 * txtMatrix2.a) / 2;
  157.             tmpBmd2.draw(tmpBmd, txtMatrix2, nullnullnulltrue);
  158.             tmpBmd2.applyFilter(tmpBmd2, tmpBmd2.rect, point, blur);
  159.             tmpBmd2.colorTransform(tmpBmd2.rect, new ColorTransform(1111000, -10));
  160.             tmpBmd2.unlock();
  161.             bmd.lock();
  162.             bmd.fillRect(bmd.rect, 0x0);
  163.             bmd.draw(shape);
  164.             bmd.copyChannel(tmpBmd2, tmpBmd2.rect, point, BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
  165.             bmd.unlock();
  166.             frame++;
  167.         }
  168.         public function makePatterns(): Array
  169.         {
  170.             patterns = [];
  171.             var i: int, a: Array, j: int, n: int = 13;
  172.             length = patternArray.length / n;
  173.             for (i = 0; i < length; i++ )
  174.             {
  175.                 patterns.push(BitmapPatternBuilder.build(patternArray, colorArray));
  176.                 for (j = 0; j < n; j++ )
  177.                 {
  178.                     a = patternArray.pop();
  179.                     patternArray.unshift(a);
  180.                 }
  181.             }
  182.             return patterns;
  183.         }
  184.         
  185.         public function makeGrid(): BitmapData
  186.         {
  187.             return BitmapPatternBuilder.build([[001], [001], [111]], [0x20000000, 0xC0000000]);
  188.         }
  189.         
  190.         private const patternArray: Array = [[0,0,0,1,2,3,3,3,4,5,5,5,5,5,5,5,5,3,3,3,3,1,1,0,0,0,0,0,0,0,1,1,2,2,3,3,3,3,3,3,3,3,3,3,3,2,1,0,0,0,0,0],
  191.         [0,1,1,3,3,3,5,5,5,5,5,5,6,6,5,5,5,5,5,5,3,3,2,1,0,0,0,0,1,1,2,3,3,3,4,5,5,5,5,5,5,5,5,5,3,3,3,1,0,0,0,0],
  192.         [1,2,3,3,5,5,5,5,6,6,6,6,6,6,6,6,6,6,5,5,5,4,3,3,1,1,1,1,2,3,3,4,5,5,5,5,5,6,6,6,6,6,5,5,5,4,3,2,1,0,0,0],
  193.         [2,3,3,5,5,5,6,6,7,7,7,7,7,7,7,7,7,6,6,6,5,5,5,3,3,2,2,3,3,3,5,5,5,5,6,6,6,6,7,7,7,6,6,6,5,5,3,3,1,0,0,0],
  194.         [3,3,5,5,6,6,7,7,8,8,8,8,8,8,8,8,8,7,7,6,6,5,5,5,3,3,3,3,3,5,5,5,6,6,7,7,7,8,8,8,8,7,7,6,6,5,5,3,2,0,0,1],
  195.         [3,5,5,6,6,7,8,8,9,10,11,11,11,11,11,11,10,8,8,7,7,6,5,5,5,3,3,3,5,5,6,6,7,7,8,8,8,9,9,12,13,11,10,7,6,5,5,3,3,1,1,2],
  196.         [5,5,6,6,7,8,9,13,11,11,11,11,11,11,11,11,11,11,14,8,8,7,6,5,5,5,3,5,5,5,6,7,7,8,8,9,13,11,11,11,11,11,13,7,6,6,5,4,3,1,1,3],
  197.         [5,6,6,7,8,9,11,11,11,11,11,11,11,11,11,11,11,11,11,13,8,8,7,6,5,5,5,5,5,6,6,15,10,11,11,11,11,11,11,11,11,11,10,8,7,6,5,5,3,2,2,3],
  198.         [5,6,7,8,9,11,11,11,11,11,11,13,14,14,11,11,11,11,11,11,13,8,7,6,6,5,5,5,5,6,8,11,11,11,11,11,11,11,11,11,11,11,13,8,7,6,5,5,3,2,3,4],
  199.         [6,7,8,9,10,11,11,11,11,11,16,14,14,14,14,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,6,11,11,11,11,11,11,11,11,11,11,11,10,9,7,6,5,5,3,3,3,5],
  200.         [6,7,8,14,11,11,11,11,11,11,13,14,14,14,14,11,11,11,11,11,11,11,9,8,7,6,5,5,5,6,6,7,8,14,10,11,11,11,11,11,11,11,13,9,8,6,5,5,3,3,4,5],
  201.         [7,8,9,11,11,11,11,11,11,11,14,9,9,9,14,13,11,11,11,11,11,11,14,8,7,6,5,5,5,5,6,7,8,9,14,11,11,11,11,11,11,11,13,9,8,6,5,5,3,3,5,5],
  202.         [7,8,14,11,11,11,11,11,11,16,14,9,9,9,9,14,11,11,11,11,11,11,16,9,8,6,6,5,5,5,6,6,7,9,14,13,11,11,11,11,11,11,13,9,8,6,5,5,3,3,5,6],
  203.         [7,9,10,11,11,11,11,11,11,13,9,9,8,8,9,14,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,8,9,13,11,11,11,11,11,11,13,9,8,6,5,5,4,5,5,6],
  204.         [8,9,11,11,11,11,11,11,11,13,9,8,8,8,9,9,11,11,11,11,11,11,11,14,8,7,6,5,5,5,5,6,7,8,9,13,11,11,11,11,11,11,10,9,8,6,5,5,4,5,5,6],
  205.         [8,9,11,11,11,11,11,11,11,14,9,8,7,8,8,9,16,11,11,11,11,11,11,10,9,7,6,5,5,5,5,6,6,8,9,13,11,11,11,11,11,11,10,9,8,6,5,5,5,5,5,6],
  206.         [8,14,11,11,11,11,11,11,11,14,9,8,7,7,8,9,10,11,11,11,11,11,11,11,9,8,6,5,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,5,5,5,5,5,6],
  207.         [8,13,11,11,11,11,11,11,11,9,8,8,7,7,8,9,13,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,5,5,5,5,6,7],
  208.         [9,10,11,11,11,11,11,11,11,9,8,7,7,7,8,9,13,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,5,5,5,5,6,7],
  209.         [9,13,11,11,11,11,11,11,11,9,8,7,7,7,8,9,13,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,5,5,5,5,6,7],
  210.         [9,13,11,11,11,11,11,11,11,9,8,7,7,7,8,9,13,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,6,5,5,5,6,7],
  211.         [9,13,11,11,11,11,11,11,11,9,8,7,7,7,8,9,13,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,6,5,5,5,6,7],
  212.         [9,13,11,11,11,11,11,11,11,9,8,7,7,7,8,9,13,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,5,5,5,5,6,7],
  213.         [9,13,11,11,11,11,11,11,11,9,8,7,7,7,8,9,13,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,5,5,5,5,6,7],
  214.         [8,13,11,11,11,11,11,11,11,9,8,8,7,7,8,9,13,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,5,5,5,5,6,7],
  215.         [8,14,11,11,11,11,11,11,11,14,9,8,7,7,8,9,10,11,11,11,11,11,11,11,9,8,6,5,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,6,5,5,5,5,5,6],
  216.         [8,9,11,11,11,11,11,11,11,14,9,8,7,8,8,9,16,11,11,11,11,11,11,13,9,7,6,5,5,4,5,5,6,7,9,13,11,11,11,11,11,11,10,9,8,6,5,5,5,5,5,6],
  217.         [8,9,11,11,11,11,11,11,11,13,9,8,8,8,9,9,11,11,11,11,11,11,11,13,8,7,6,5,5,4,5,5,6,7,9,13,11,11,11,11,11,11,10,9,8,7,6,5,5,5,5,6],
  218.         [7,9,10,11,11,11,11,11,11,13,9,9,8,8,9,14,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,5,6,8,9,13,11,11,11,11,11,11,10,9,8,7,6,5,5,5,5,6],
  219.         [7,8,14,11,11,11,11,11,11,16,14,9,9,9,9,14,11,11,11,11,11,11,11,9,8,6,6,5,5,5,5,6,7,8,9,13,11,11,11,11,11,11,16,9,8,7,6,5,5,5,5,6],
  220.         [7,8,9,11,11,11,11,11,11,11,14,9,9,9,14,13,11,11,11,11,11,11,14,8,7,6,5,5,5,5,5,6,7,8,9,13,11,11,11,11,11,11,16,9,8,7,6,5,5,5,5,5],
  221.         [6,7,8,14,11,11,11,11,11,11,13,14,14,14,14,11,11,11,11,11,11,11,9,8,7,6,5,5,5,5,6,6,7,8,9,13,11,11,11,11,11,11,11,14,8,7,6,6,5,5,5,5],
  222.         [6,7,8,9,16,11,11,11,11,11,16,14,14,14,14,11,11,11,11,11,11,14,8,7,6,5,5,5,5,5,6,7,7,8,9,13,11,11,11,11,11,11,11,14,9,8,7,6,5,5,5,5],
  223.         [5,6,7,8,9,11,11,11,11,11,11,13,14,14,11,11,11,11,11,11,10,8,7,7,6,5,5,5,5,5,6,7,8,9,14,11,11,11,11,11,11,11,11,14,9,8,7,6,6,5,5,5],
  224.         [5,6,6,7,8,9,11,11,11,11,11,11,11,11,11,11,11,11,11,13,8,8,7,6,5,5,5,5,5,6,7,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,17,6,5,5,5],
  225.         [5,5,6,6,7,8,9,13,11,11,11,11,11,11,11,11,11,11,14,8,8,7,6,5,5,5,5,5,5,6,15,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,6,5,5,5],
  226.         [4,5,5,6,6,7,8,8,9,10,11,11,11,11,11,11,10,8,8,7,7,6,5,5,5,3,3,5,5,5,6,10,10,10,10,14,14,13,13,13,13,14,14,10,10,10,10,17,6,5,5,4],
  227.         [3,4,5,5,6,6,7,7,8,8,8,9,9,9,9,8,8,8,7,7,6,5,5,5,3,3,3,4,5,5,6,6,7,7,8,8,9,9,9,9,9,9,8,8,8,7,6,6,5,5,5,3],
  228.         [3,3,4,5,5,6,6,7,7,7,8,8,8,8,8,8,7,7,6,6,5,5,5,3,3,3,3,3,5,5,6,6,7,7,7,8,8,8,8,8,8,8,8,8,7,7,6,6,5,5,4,3],
  229.         [2,3,3,5,5,5,6,6,7,7,7,8,8,8,8,7,7,6,6,5,5,5,3,3,2,2,3,3,5,5,5,6,6,7,7,8,8,8,8,8,8,8,8,7,7,6,6,6,5,5,3,3],
  230.         [3,3,3,5,5,5,6,6,7,7,7,8,8,8,8,7,7,6,6,5,5,3,3,1,1,1,3,3,5,5,6,6,7,7,7,8,8,8,8,8,8,8,8,7,7,7,6,6,5,5,3,3],
  231.         [3,3,5,5,5,6,6,7,7,8,8,8,8,8,8,8,7,6,6,5,5,3,2,1,1,2,3,3,5,5,6,6,7,8,8,8,9,9,9,9,9,9,8,8,8,7,6,6,5,5,3,3],
  232.         [3,4,5,5,6,6,7,7,8,8,9,9,9,10,11,11,12,7,6,5,5,3,2,1,1,2,3,5,5,6,6,7,8,8,9,10,11,11,11,11,11,11,10,9,8,8,7,6,6,5,5,3],
  233.         [3,5,5,5,6,7,7,8,9,14,10,11,11,11,11,11,12,7,6,6,5,3,3,1,2,3,4,5,6,6,7,8,8,10,11,11,11,11,11,11,11,11,11,11,10,8,8,7,6,6,5,5],
  234.         [5,5,5,6,7,12,10,11,11,11,11,11,11,11,11,11,14,8,7,6,5,4,3,2,3,3,5,5,6,7,8,9,11,11,11,11,11,11,11,11,11,11,11,11,11,11,9,8,7,6,5,5],
  235.         [5,5,5,6,12,11,11,11,11,11,11,11,11,11,11,11,14,8,7,6,5,5,3,3,3,5,5,6,7,8,9,13,11,11,11,11,11,11,14,14,11,11,11,11,11,11,13,9,8,7,6,5],
  236.         [5,5,5,6,17,11,11,11,11,11,11,11,11,11,11,11,14,8,7,6,5,5,3,3,3,5,6,6,7,8,13,11,11,11,11,11,11,14,14,14,14,11,11,11,11,11,11,14,8,7,6,6],
  237.         [5,5,5,6,6,7,8,14,16,11,11,11,11,11,11,11,13,8,7,6,5,5,3,3,5,5,6,7,8,9,11,11,11,11,11,11,13,14,14,14,14,13,11,11,11,11,11,11,9,8,7,6],
  238.         [5,5,5,6,6,7,8,9,14,11,11,11,11,11,11,11,13,8,7,6,5,5,3,3,5,5,6,7,8,10,11,11,11,11,11,11,14,14,9,9,14,14,11,11,11,11,11,11,10,8,7,6],
  239.         [5,5,5,5,6,7,8,9,14,11,11,11,11,11,11,11,13,9,7,6,5,5,3,4,5,6,7,8,9,11,11,11,11,11,11,11,14,9,9,9,9,14,11,11,11,11,11,11,11,9,8,7],
  240.         [6,5,5,5,6,6,7,8,14,11,11,11,11,11,11,11,13,9,7,6,5,5,3,5,5,6,7,8,14,11,11,11,11,11,11,11,9,9,8,8,9,9,11,11,11,11,11,11,11,14,8,7],
  241.         [6,5,5,5,5,6,7,8,9,16,11,11,11,11,11,11,13,9,7,6,5,5,4,5,5,6,7,9,10,11,11,11,11,11,11,13,9,8,8,8,8,9,10,11,11,11,11,11,11,10,9,7],
  242.         [6,5,5,5,5,6,7,8,9,16,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,6,8,9,11,11,11,11,11,11,11,13,9,8,8,8,8,9,13,11,11,11,11,11,11,11,9,8],
  243.         [6,5,5,5,5,6,7,8,9,10,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,9,11,11,11,11,11,11,11,13,9,8,7,7,8,9,13,11,11,11,11,11,11,11,9,8],
  244.         [6,5,5,5,5,6,6,8,9,10,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,9,11,11,11,11,11,11,11,14,9,8,7,7,8,9,14,11,11,11,11,11,11,11,9,8],
  245.         [6,5,5,5,5,5,6,8,9,13,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,13,11,11,11,11,11,11,11,14,9,8,7,7,8,9,14,11,11,11,11,11,11,11,14,8],
  246.         [7,6,5,5,5,5,6,8,9,13,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,13,11,11,11,11,11,11,11,14,8,8,7,7,8,8,14,11,11,11,11,11,11,11,13,8],
  247.         [7,6,5,5,5,5,6,8,9,13,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,13,11,11,11,11,11,11,11,14,8,7,7,7,7,8,14,11,11,11,11,11,11,11,13,8],
  248.         [7,6,5,5,5,5,6,8,9,13,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,13,11,11,11,11,11,11,11,14,8,7,7,7,7,8,14,11,11,11,11,11,11,11,13,8],
  249.         [7,6,5,5,5,5,6,8,9,13,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,13,11,11,11,11,11,11,11,14,8,8,7,7,8,8,14,11,11,11,11,11,11,11,13,8],
  250.         [6,5,5,5,5,5,6,8,9,13,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,13,11,11,11,11,11,11,11,14,9,8,7,7,8,9,14,11,11,11,11,11,11,11,13,8],
  251.         [6,5,5,5,5,5,6,8,9,13,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,9,11,11,11,11,11,11,11,14,9,8,7,7,8,9,14,11,11,11,11,11,11,11,9,8],
  252.         [6,5,5,5,5,5,6,8,9,13,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,9,11,11,11,11,11,11,11,13,9,8,7,7,8,9,13,11,11,11,11,11,11,11,9,8],
  253.         [6,5,5,4,5,5,6,8,9,10,11,11,11,11,11,11,13,9,7,6,5,5,5,5,6,7,8,9,11,11,11,11,11,11,11,13,9,8,8,8,8,9,13,11,11,11,11,11,11,11,9,8],
  254.         [6,5,5,4,5,6,7,8,9,10,11,11,11,11,11,11,13,9,7,6,5,5,5,5,5,6,7,9,13,11,11,11,11,11,11,13,9,8,8,8,8,9,10,11,11,11,11,11,11,13,9,7],
  255.         [6,5,5,5,5,6,7,8,9,10,11,11,11,11,11,11,13,9,8,6,5,5,5,5,5,6,7,8,14,11,11,11,11,11,11,11,9,9,8,8,9,9,11,11,11,11,11,11,11,14,8,7],
  256.         [5,5,5,5,5,6,7,8,9,16,11,11,11,11,11,11,13,9,8,7,6,5,5,5,5,6,7,8,9,11,11,11,11,11,11,11,14,9,9,9,9,14,11,11,11,11,11,11,11,9,8,7],
  257.         [5,5,5,5,5,6,7,8,9,16,11,11,11,11,11,11,13,9,8,7,6,5,5,5,5,6,6,7,9,10,11,11,11,11,11,11,14,14,9,9,14,14,11,11,11,11,11,11,10,9,7,6],
  258.         [5,5,5,5,6,6,7,8,14,11,11,11,11,11,11,11,13,9,8,7,6,6,5,5,5,5,6,7,8,9,11,11,11,11,11,11,13,14,14,14,14,13,11,11,11,11,11,11,9,8,7,6],
  259.         [5,5,5,5,6,7,8,9,14,11,11,11,11,11,11,11,13,9,8,7,7,6,5,5,5,5,6,6,7,8,13,11,11,11,11,11,11,14,14,14,14,11,11,11,11,11,11,13,8,7,6,6],
  260.         [5,5,5,6,6,7,8,9,14,11,11,11,11,11,11,11,11,14,9,8,7,6,5,5,5,5,5,6,7,8,9,11,11,11,11,11,11,11,14,14,11,11,11,11,11,11,11,9,8,7,6,5],
  261.         [5,5,5,6,17,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,7,6,5,5,5,5,5,6,7,8,9,11,11,11,11,11,11,11,11,11,11,11,11,11,11,9,8,7,6,5,5],
  262.         [5,5,5,6,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,15,6,5,5,5,5,5,6,6,7,8,8,10,11,11,11,11,11,11,11,11,11,11,10,8,8,7,6,6,5,5],
  263.         [4,5,5,6,18,10,10,10,13,14,14,14,14,14,14,14,14,10,10,10,10,6,5,5,5,3,4,5,5,6,6,7,8,8,9,10,11,11,11,11,11,11,10,9,8,8,7,6,6,5,5,3],
  264.         [3,5,5,5,6,6,7,7,8,8,8,8,8,8,8,8,8,8,7,7,6,6,5,5,4,3,3,3,5,5,6,6,7,7,8,8,8,8,8,8,8,8,8,8,7,7,6,6,5,5,3,3],
  265.         [3,3,5,5,5,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6,5,5,5,3,3,3,3,3,5,5,5,6,6,7,7,7,7,7,7,7,7,7,7,6,6,5,5,5,3,3,3],
  266.         [3,3,4,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,3,3,2,2,2,3,3,4,5,5,5,6,6,6,6,6,6,6,6,6,6,5,5,5,4,3,3,2,1],
  267.         [2,3,3,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3,3,3,1,1,1,1,2,3,3,5,5,5,5,5,5,6,6,5,5,5,5,5,5,3,3,2,1,0,0]];
  268.         
  269.         private const colorArray: Array = [0x0, 0x8000, 0xC000, 0xE000, 0x2000E000, 0x2000FF00, 0x4000FF00, 0x6000FF00, 0x8000FF00, 0xA000FF00, 0xE000E000, 0xFF00FF00, 0xC000E000, 0xE000FF00, 0xC000FF00, 0xA000E000, 0xFF00E000, 0x8000E000, 0x6000E000];
  270.     }
  271. }
  272. /**-----------------------------------------------------
  273.  * Use following BitmapPatternBuilder class 
  274.  * 
  275.  * DO NOT CHANGE any codes below this comment.
  276.  *
  277.  * -----------------------------------------------------
  278. */
  279. import flash.display.Bitmap;
  280. import flash.display.BitmapData;
  281. import flash.display.Graphics;
  282.     
  283. class BitmapPatternBuilder{
  284.     /**
  285.      * creates BitmapData filled with dot pattern.
  286.      * First parameter is 2d array that contains color index for each pixels;
  287.      * Second parameter contains color reference table.
  288.      *
  289.      * @parameter pattern:Array 2d array that contains color index for each pixel.
  290.      * @parameter colors:Array 1d array that contains color table.
  291.      * @returns BitmapData
  292.      */
  293.     public static function build(pattern:Array, colors:Array):BitmapData{
  294.         var bitmapW:int = pattern[0].length;
  295.         var bitmapH:int = pattern.length;
  296.         var bmd:BitmapData = new BitmapData(bitmapW,bitmapH,true,0x000000);
  297.         for(var yy:int=0; yy<bitmapH; yy++){
  298.             for(var xx:int=0; xx<bitmapW; xx++){
  299.                 var color:int = colors[pattern[yy][xx]];
  300.                 bmd.setPixel32(xx, yy, color);
  301.             }
  302.         }
  303.         return bmd;
  304.     }
  305.     
  306.     /**
  307.      * short cut function for Graphics.beginBitmapFill with pattern.
  308.      */
  309.     public static function beginBitmapFill(pattern:Array, colors:Array, graphics:Graphics):void{
  310.         var bmd:BitmapData = build(pattern, colors);
  311.         graphics.beginBitmapFill(bmd);
  312.         bmd.dispose();        
  313.     }
  314. }
noswf
  1. // forked from checkmate's fladdict challenge for professionals
  2. /**
  3.  * Theme:
  4.  * Play with BitmapPatterBuilder.
  5.  * Purpose of this trial is to find the possibility of the dot pattern.
  6.  *
  7.  * by Takayuki Fukatsu aka fladdict
  8.  **/
  9.  
  10. /**
  11.  * (forked from Murai's code)
  12.  * http://wonderfl.net/code/e9dee3eb5c7414aea0248344f204c1b397adc0ac
  13.  */
  14. package {
  15.     import flash.display.Bitmap;
  16.     import flash.display.BitmapData;
  17.     import flash.display.BlendMode;
  18.     import flash.display.Graphics;
  19.     import flash.display.Sprite;
  20.     import flash.display.StageScaleMode;
  21.     import flash.events.*;
  22.     import flash.geom.Matrix;
  23.     
  24.     [SWF(width=465,height=465,frameRate=60,backgroundColor=0x000000)]
  25.     public class ProfessionalAnim extends Sprite {
  26.         private var poses:Array = [
  27.             [
  28.                  [0,0,0,0,0,0,0,0,0,0],
  29.                 [0,0,0,0,1,1,0,0,0,0],
  30.                 [0,0,0,0,1,1,0,0,0,0],
  31.                 [0,0,0,1,1,1,1,0,0,0],
  32.                 [0,0,1,0,1,1,0,1,0,0],
  33.                 [0,0,1,0,1,1,0,1,0,0],
  34.                 [0,0,0,0,1,1,0,0,0,0],
  35.                 [0,0,0,1,0,0,1,0,0,0],
  36.                 [0,0,0,1,0,0,1,0,0,0],
  37.                 [0,0,0,0,0,0,0,0,0,0]
  38.             ],[
  39.                 [0,0,0,0,0,0,0,0,0,0],
  40.                 [0,0,0,0,1,1,0,0,0,0],
  41.                 [0,0,0,0,1,1,0,0,0,0],
  42.                 [0,0,0,1,1,1,1,0,0,0],
  43.                 [0,0,1,0,1,1,0,1,0,0],
  44.                 [0,0,0,1,1,0,1,0,0,0],
  45.                 [0,0,0,0,1,1,0,0,0,0],
  46.                 [0,0,0,1,0,0,1,0,0,0],
  47.                 [0,0,0,1,0,1,0,0,0,0],
  48.                 [0,0,0,0,0,0,0,0,0,0]
  49.             ],[
  50.                 [0,0,0,0,0,0,0,0,0,0],
  51.                 [0,0,0,0,1,1,0,0,0,0],
  52.                 [0,0,0,0,1,1,0,0,0,0],
  53.                 [0,0,0,1,1,1,1,0,0,0],
  54.                 [0,1,1,0,1,1,0,1,0,0],
  55.                 [0,0,0,0,1,1,1,0,0,0],
  56.                 [0,0,0,0,1,1,0,0,0,0],
  57.                 [0,0,0,1,0,0,1,0,0,0],
  58.                 [0,0,1,0,0,1,0,0,0,0],
  59.                 [0,0,0,0,0,0,0,0,0,0]
  60.             ],[
  61.                 [0,0,0,0,0,0,0,0,0,0],
  62.                 [0,0,0,0,1,1,0,0,0,0],
  63.                 [0,0,0,0,1,1,0,0,0,0],
  64.                 [0,0,0,1,1,1,1,0,0,0],
  65.                 [0,0,1,0,1,1,0,1,0,0],
  66.                 [0,0,1,0,1,1,0,1,0,0],
  67.                 [0,0,0,0,1,1,0,0,0,0],
  68.                 [0,0,0,1,0,0,1,0,0,0],
  69.                 [0,0,0,1,0,0,1,0,0,0],
  70.                 [0,0,0,0,0,0,0,0,0,0]
  71.             ],[
  72.                 [0,0,0,0,0,0,0,0,0,0],
  73.                 [0,0,0,0,1,1,0,0,0,0],
  74.                 [0,0,0,0,1,1,0,0,0,0],
  75.                 [0,0,0,1,1,1,1,0,0,0],
  76.                 [0,0,1,0,1,1,0,1,0,0],
  77.                 [0,0,1,0,1,1,0,0,0,0],
  78.                 [0,0,0,0,1,1,0,0,0,0],
  79.                 [0,0,0,1,0,0,1,0,0,0],
  80.                 [0,0,0,1,0,0,0,1,0,0],
  81.                 [0,0,0,0,0,0,0,0,0,0]
  82.             ],[
  83.                 [0,0,0,0,0,0,0,0,0,0],
  84.                 [0,0,0,0,1,1,0,0,0,0],
  85.                 [0,0,0,0,1,1,0,0,1,0],
  86.                 [0,0,0,1,1,1,1,1,0,0],
  87.                 [0,0,1,0,1,1,0,0,0,0],
  88.                 [0,0,1,0,1,1,0,0,0,0],
  89.                 [0,0,0,0,1,1,1,0,0,0],
  90.                 [0,0,0,1,0,0,0,0,0,0],
  91.                 [0,0,0,1,0,0,0,0,0,0],
  92.                 [0,0,0,0,0,0,0,0,0,0]
  93.             ],[
  94.                 [0,0,0,0,0,0,0,0,0,0],
  95.                 [0,0,0,0,1,1,0,0,0,0],
  96.                 [0,0,0,0,1,1,0,1,0,0],
  97.                 [0,0,0,1,1,1,1,1,0,0],
  98.                 [0,0,1,0,1,1,0,0,0,0],
  99.                 [0,0,1,0,1,1,0,0,0,0],
  100.                 [0,0,0,0,1,1,1,0,0,0],
  101.                 [0,0,0,1,0,0,1,0,0,0],
  102.                 [0,0,0,1,0,0,0,0,0,0],
  103.                 [0,0,0,0,0,0,0,0,0,0]
  104.             ],[
  105.                 [0,0,0,0,0,0,0,0,0,0],
  106.                 [0,0,0,0,1,1,0,0,0,0],
  107.                 [0,0,0,0,1,1,0,0,1,0],
  108.                 [0,0,0,1,1,1,1,1,0,0],
  109.                 [0,0,1,0,1,1,0,0,0,0],
  110.                 [0,0,1,0,1,1,0,0,0,0],
  111.                 [0,0,0,0,1,1,1,0,0,0],
  112.                 [0,0,0,1,0,0,1,0,0,0],
  113.                 [0,0,0,1,0,0,0,0,0,0],
  114.                 [0,0,0,0,0,0,0,0,0,0]
  115.             ]
  116.         ];
  117.         
  118.         private var pattern:BitmapData;
  119.         private var pos:Number = 0;
  120.         private var spd:Number = 0;
  121.         private var film0:Film;
  122.         private var film3:Film;
  123.         
  124.         public function ProfessionalAnim() {
  125.             stage.scaleMode = StageScaleMode.NO_SCALE;
  126.             
  127.             var map:Array = [];
  128.             for each (var pose:Array in poses) {
  129.                 for (var i:int=0; i<pose.length; i++) {
  130.                     map[i] ||= [];
  131.                     for (var j:int=0; j<5; j++) {
  132.                         map[i] = map[i].concat(pose[i]);
  133.                     }
  134.                 }
  135.             }
  136.             pattern = BitmapPatternBuilder.build( map, [0xFFFFFFFF, 0xFF000000] );
  137.             
  138.             film0 = new Film(pattern, 465465);
  139.             film3 = new Film(pattern, 465 / 820);
  140.             film3.scaleX = film3.scaleY = 8;
  141.             film3.blendMode = BlendMode.MULTIPLY;
  142.             addChild(film0);
  143.             addChild(film3);
  144.             film3.y = 150;
  145.             
  146.             addEventListener(Event.ENTER_FRAME, function(event:Event):void {
  147.                 var spd2:Number = mouseX / 465 * 10 * 5;
  148.                 spd += (spd2 - spd) * 0.04;
  149.                 pos += spd * 2;
  150.                 pos %= (pattern.width * 2);
  151.                 film0.update(pos);
  152.                 film3.update(pos);
  153.                 film3.alpha = 1 - Math.abs((spd2 + 10) % 20 - 10);
  154.             });
  155.         }
  156.     }
  157. }
  158. import flash.display.Shape;
  159. import flash.geom.Matrix;
  160. class Film extends Shape {
  161.     private var pattern:BitmapData;
  162.     private var drawWidth:int;
  163.     private var drawHeight:int;
  164.     
  165.     public function Film(pattern:BitmapData, drawWidth:int, drawHeight:int) {
  166.         this.pattern = pattern;
  167.         this.drawWidth  = drawWidth;
  168.         this.drawHeight = drawHeight;
  169.     }
  170.     
  171.     public function update(scroll:Number):void {
  172.         var mtx:Matrix = new Matrix();
  173.         mtx.a = mtx.d = 2;
  174.         mtx.tx = -scroll;
  175.         graphics.clear();
  176.         graphics.beginBitmapFill(pattern, mtx);
  177.         graphics.drawRect(00, drawWidth, drawHeight);
  178.         graphics.endFill();
  179.     }
  180. }
  181. /**-----------------------------------------------------
  182.  * Use following BitmapPatternBuilder class 
  183.  * 
  184.  * DO NOT CHANGE any codes below this comment.
  185.  *
  186.  * -----------------------------------------------------
  187. */
  188. import flash.display.Bitmap;
  189. import flash.display.BitmapData;
  190. import flash.display.Graphics;
  191.     
  192. class BitmapPatternBuilder{
  193.     /**
  194.      * creates BitmapData filled with dot pattern.
  195.      * First parameter is 2d array that contains color index for each pixels;
  196.      * Second parameter contains color reference table.
  197.      *
  198.      * @parameter pattern:Array 2d array that contains color index for each pixel.
  199.      * @parameter colors:Array 1d array that contains color table.
  200.      * @returns BitmapData
  201.      */
  202.     public static function build(pattern:Array, colors:Array):BitmapData{
  203.         var bitmapW:int = pattern[0].length;
  204.         var bitmapH:int = pattern.length;
  205.         var bmd:BitmapData = new BitmapData(bitmapW,bitmapH,true,0x000000);
  206.         for(var yy:int=0; yy<bitmapH; yy++){
  207.             for(var xx:int=0; xx<bitmapW; xx++){
  208.                 var color:int = colors[pattern[yy][xx]];
  209.                 bmd.setPixel32(xx, yy, color);
  210.             }
  211.         }
  212.         return bmd;
  213.     }
  214.     
  215.     /**
  216.      * short cut function for Graphics.beginBitmapFill with pattern.
  217.      */
  218.     public static function beginBitmapFill(pattern:Array, colors:Array, graphics:Graphics):void{
  219.         var bmd:BitmapData = build(pattern, colors);
  220.         graphics.beginBitmapFill(bmd);
  221.         bmd.dispose();        
  222.     }
  223. }
noswf

ad ad

Get Adobe Flash Player