※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

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


forked from : checkmate's Checkmate vol4 Massmedian [diff(74)]

ad

TALK
>miyaoka : 別タブで音楽再生してるとcomputeSpectrumのセキュリティエラーで見れないので閉じてから 
おぉ!たまに見れないと思ったら、これが原因だったんですね。ありがとうございます。
at 2009/10/16 20:23:55 by
at 2009/12/23 04:22:56 by
Thank you for your reporting. I've sent them a complaint mail.
at 2009/12/23 15:46:00 by
FAVORITE BY
:
綺麗だ。
:
:
:
Sound
:
かわいい!メリー!
:
ゆめいっぱい
:
よいアイデア
:
良いアイデア
:
:
:
ウマイ!
:
別タブで音楽再生してるとcomputeSpectrumのセキュリティエラーで見れないので閉じてから
:
発想すごい好き
:
fucking cool, but too early
:
きれい!
FORKED
  1. // forked from osamX's ChristmasSpectrum
  2. // forked from checkmate's Checkmate vol4 Massmedian
  3. /*
  4.  * BGM: 夢いっぱいの箱
  5.  *      フリー音楽素材 H/MIX GALLERY
  6.  *      http://www.hmix.net/
  7.  */
  8. package {
  9.     import flash.display.*;
  10.     import flash.events.*;
  11.     import flash.net.*;
  12.     import flash.geom.*;
  13.     
  14.     import flash.media.Sound;
  15.     import flash.media.SoundMixer;
  16.     import flash.media.SoundChannel;
  17.     import flash.utils.ByteArray;
  18.     import flash.system.Security;
  19.     
  20.     [SWF(width="465", height="465", frameRate="60", backgroundColor="0x00")]
  21.     public class FlashTest extends Sprite {
  22.         /*
  23.          * [Checkmate Vol4 by MASSMEDIAN]
  24.          * Please produce the illumination freely with a color palette. 
  25.          *
  26.          * usage of Palette class
  27.          *   A single value is used.
  28.          *     var white:uint = Palette.WHITE;
  29.          *     var green:uint = Palette.GREEN;
  30.          *     var red:uint = Palette.RED;
  31.          *     var gold:uint = Palette.GOLD;
  32.          *     var silver:uint = Palette.SILVER;
  33.          *     var black:uint = Palette.BLACK;
  34.          *   All the values are used.
  35.          *     var colors:Array = Palette.getColors();
  36.          */
  37.         private function init( e:Event = null ):void {
  38.             resize();
  39.             //drawXmasTree()
  40.             createSnow();
  41.             //showPaletteMap();
  42.             loadSound();
  43.         }
  44.         
  45.         public var rect:Rectangle= new Rectangle();
  46.         public var center:Point = new Point();
  47.         
  48.         private const SLOW_LENGTH:int = 1000;
  49.         private var _snow:Vector.<Snow> = new Vector.<Snow>();
  50.         
  51.         private var _twincles:BitmapData;
  52.         private var _canvas:BitmapData;
  53.         
  54.         private var _matrix:Matrix;
  55.         private var _ctf:ColorTransform = new ColorTransform( 0.750.80.80.95 );
  56.         
  57.         private const COLORS:Array = Palette.getColors();
  58.         private var s:Sound;
  59.         private const star:Array = [
  60.             [000010000],
  61.             [000010000],
  62.             [000111000],
  63.             [111111 ,1 ,1 ,1],
  64.             [011111110],
  65.             [001111100],
  66.             [001111100],
  67.             [011101110],
  68.             [010000010]];
  69.         
  70.         private function createSnow():void {
  71.             // The value used for generation is prepared.
  72.             const RADIAN:Number = Math.PI*2;
  73.             
  74.             // The canvas to draw in illumination.
  75.             var snow:Snow, speed:Number, angle:Number;
  76.             forvar i :int = 0; i<SLOW_LENGTH; ++i ) {
  77.                 snow = new Snow();
  78.                 snow.x   = (Math.random()-0.5)*50 + center.x;
  79.                 snow.y   = Math.random()*rect.height;
  80.                 snow.vx = (Math.random()-0.5) * 4;
  81.                 snow.vy = Math.random()*-2;
  82.                 snow.color = Palette.WHITE;
  83.                 _snow.push( snow );
  84.             }
  85.             
  86.             // The canvas to draw in illumination.
  87.             _canvas = new BitmapData( rect.height, rect.height, true0 );
  88.             var cbm :Bitmap = addChild( new Bitmap( _canvas ) ) as Bitmap;
  89.             cbm.smoothing = true;
  90.             
  91.             // The canvas to draw in twincles.
  92.             _twincles = new BitmapData( rect.width/4>>0, rect.height/4>>0true0 );
  93.             var tbm:Bitmap = addChild( new Bitmap( _twincles ) ) as Bitmap;
  94.             tbm.scaleX = tbm.scaleY = 4;
  95.             tbm.smoothing = true;
  96.             tbm.blendMode = BlendMode.ADD;
  97.             
  98.             // Matrix to draw by size of 1/4
  99.             _matrix = new Matrix(0.25000.25);
  100.         }
  101.         
  102.         private function updateSnow(e:Event):void {
  103.             _canvas.lock();
  104.             for eachvar snow:Snow in _snow ) {
  105.                 // The Brownian motion is added.
  106.                 snow.vx += (Math.random()-0.5)*0.04;
  107.                 snow.vy += (Math.random()-0.5)*0.04;
  108.                 
  109.                 // Gravity is added.
  110.                 snow.vy += 0.015;
  111.                 
  112.                 // The wind drag is added.
  113.                 snow.vx *= 0.987;
  114.                 snow.vy *= 0.987;
  115.                 
  116.                 // The speed is added to the position. 
  117.                 snow.x += snow.vx;
  118.                 snow.y += snow.vy;
  119.                 
  120.                 // draw to canvas in position.
  121.                 _canvas.setPixel32( snow.x, snow.y, snow.color | 0xFF<<24 );
  122.                 
  123.                 // It resets it when going out of the area. 
  124.                 if( snow.x < rect.x -50 ||  snow.y < rect.y -50 || snow.x > rect.width +50 || snow.y > rect.height + 50 ) {
  125.                     snow.x = center.y + (Math.random() -0.5) * 10;
  126.                     snow.y = Math.random() *-30;
  127.                     snow.vx = (Math.random() -0.5) * 3;
  128.                     snow.vy = Math.random() *-3;
  129.                 }
  130.             }
  131.             
  132.             const OY:uint = 80;
  133.             var ba:ByteArray = new ByteArray();
  134.             SoundMixer.computeSpectrum(ba, false0);
  135.             drawTree(ba, OY, true);//left
  136.             drawTree(ba, OY, false);//right
  137.             
  138.             // draw star
  139.             for (var j:uint = 0; j < 9; j++) {
  140.                 for (var i:uint = 0; i < 9; i++ ) {
  141.                     if (star[j][i]) {
  142.                         _canvas.setPixel32( i*4+2+center.x-8*4/2, j*4+2+OY, Palette.GOLD | 0xFF<<24 );
  143.                     }
  144.                 }
  145.             }
  146.             
  147.             // ColorTransform(effect that dose blackout) is made to adjust. 
  148.             _canvas.colorTransform( _canvas.rect, _ctf );
  149.             _canvas.unlock();
  150.             
  151.              // draw to canvas in twincles by using Matrix.
  152.             _twincles.draw( _canvas, _matrix );
  153.         }
  154.         
  155.         private function drawTree(ba:ByteArray, oy:uint, lr:Boolean):void {
  156.         const H:int = 100;
  157.         var spectrum:Number = 0;
  158.         for (var j:uint = 0; j < 256; j++) {
  159.             if((ba.position/ba.length-1)) spectrum = (j/256)*ba.readFloat() * H + j/20;
  160.             for (var i:uint = 0; i < spectrum ; i++) {
  161.                 lr?
  162.                 _canvas.setPixel32( int(-i*4+2+center.x), int(j+32+oy), COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 ):
  163.                 _canvas.setPixel32( int(i*4+2+center.x), int(j+32+oy), COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 );
  164.             }
  165.         }
  166.     }
  167.         
  168.         
  169.         private function resize( e:Event = null ):void {
  170.             rect.width = stage.stageWidth;
  171.             rect.height= stage.stageHeight;
  172.             
  173.             center.x = rect.width /2>>0;
  174.             center.y = rect.height /2>>0;
  175.         }
  176.         
  177.         private function drawXmasTree():void {
  178.             var loader :Loader = new Loader();
  179.             addChild( loader );
  180.             loader.load( new URLRequest("http://swf-dev.wonderfl.net/static/assets/checkmate04/tree.jpg") );
  181.         }
  182.         private function showPaletteMap():void {
  183.             var colors:Array = Palette.getColors();
  184.             var palette:Sprite = addChild( new ColorMap( colors ) ) as Sprite;
  185.             palette.x = ( rect.width - palette.width )  /2 >>0;
  186.             palette.y = ( rect.height- palette.height ) /2 >>0;
  187.         }
  188.         
  189.         public function FlashTest() {
  190.             if( stage ) init();
  191.             else addEventListener( Event.ADDED_TO_STAGE, init );
  192.         }
  193.         
  194.         private function loadSound():void {
  195.         Security.loadPolicyFile("http://flash-scope.com/wonderfl/crossdomain.xml");
  196.         s = new Sound();
  197.         var sc:SoundChannel = new SoundChannel();
  198.         s.addEventListener(Event.COMPLETE, function(e:Event):void{
  199.             sc = s.play(0,9999);
  200.             //sc.stop();
  201.             addEventListener( Event.ENTER_FRAME, updateSnow );
  202.         });
  203.         s.load(new URLRequest("http://flash-scope.com/wonderfl/ChristmasSpectrum/o13.mp3"));
  204.     }
  205.     }
  206. }
  207. /* for Checkmate */
  208. class Palette {
  209.     public static const WHITE:uint = 0xF0F0F0;
  210.     public static const GREEN:uint = 0x008800;
  211.     public static const RED:uint = 0xCC0000;
  212.     public static const GOLD:uint = 0xFFCC66;
  213.     public static const SILVER:uint = 0xCCCCCC;
  214.     public static const BLACK:uint = 0x101010;
  215.     public static const COLORS:Array = [ WHITE, GREEN,  RED, GOLD, SILVER, BLACK ];
  216.     public static function getColors():Array { return COLORS.slice(); }
  217. }
  218. /* for Example. */
  219. class Snow {
  220.     public var x:Number = 0;
  221.     public var y:Number = 0;
  222.     public var vx:Number = 0;
  223.     public var vy:Number = 0;
  224.     public var color:uint = 0x00;
  225. }
  226. /* for debug. */
  227. import flash.display.*;
  228. class ColorMap extends Sprite {
  229.     public function ColorMap(colors:Array) {
  230.         var l:int = colors.length;
  231.         var rect:Sprite;
  232.         forvar i:int=0; i<l; ++i ) {
  233.             addChild( rect = new ColorRect( colors[ i ] ) );
  234.             rect.x =i * ColorRect.WIDTH;
  235.             rect.y =0;
  236.         }
  237.     }
  238. }
  239. /* for debug. */
  240. class ColorRect extends Sprite {
  241.     public static const WIDTH:int = 40;
  242.     public static const HEIGHT:int = 40;
  243.     public function ColorRect( color:uint ) {
  244.         super();
  245.         graphics.beginFill( color, 1 );
  246.         graphics.drawRect( 00, WIDTH, HEIGHT );
  247.         graphics.endFill();
  248.     }
  249. }
noswf
  1. // forked from osamX's ChristmasSpectrum
  2. // forked from checkmate's Checkmate vol4 Massmedian
  3. /*
  4.  * BGM: 夢いっぱいの箱
  5.  *      フリー音楽素材 H/MIX GALLERY
  6.  *      http://www.hmix.net/
  7.  */
  8. package {
  9.     import flash.display.*;
  10.     import flash.events.*;
  11.     import flash.net.*;
  12.     import flash.geom.*;
  13.     
  14.     import flash.media.Sound;
  15.     import flash.media.SoundMixer;
  16.     import flash.media.SoundChannel;
  17.     import flash.utils.ByteArray;
  18.     import flash.system.Security;
  19.     
  20.     [SWF(width="465", height="465", frameRate="60", backgroundColor="0x00")]
  21.     public class FlashTest extends Sprite {
  22.         /*
  23.          * [Checkmate Vol4 by MASSMEDIAN]
  24.          * Please produce the illumination freely with a color palette. 
  25.          *
  26.          * usage of Palette class
  27.          *   A single value is used.
  28.          *     var white:uint = Palette.WHITE;
  29.          *     var green:uint = Palette.GREEN;
  30.          *     var red:uint = Palette.RED;
  31.          *     var gold:uint = Palette.GOLD;
  32.          *     var silver:uint = Palette.SILVER;
  33.          *     var black:uint = Palette.BLACK;
  34.          *   All the values are used.
  35.          *     var colors:Array = Palette.getColors();
  36.          */
  37.         private function init( e:Event = null ):void {
  38.             resize();
  39.             //drawXmasTree()
  40.             createSnow();
  41.             //showPaletteMap();
  42.             loadSound();
  43.         }
  44.         
  45.         public var rect:Rectangle= new Rectangle();
  46.         public var center:Point = new Point();
  47.         
  48.         private const SLOW_LENGTH:int = 1000;
  49.         private var _snow:Vector.<Snow> = new Vector.<Snow>();
  50.         
  51.         private var _twincles:BitmapData;
  52.         private var _canvas:BitmapData;
  53.         
  54.         private var _matrix:Matrix;
  55.         private var _ctf:ColorTransform = new ColorTransform( 0.750.80.80.95 );
  56.         
  57.         private const COLORS:Array = Palette.getColors();
  58.         private var s:Sound;
  59.         private const star:Array = [
  60.             [000010000],
  61.             [000010000],
  62.             [000111000],
  63.             [111111 ,1 ,1 ,1],
  64.             [011111110],
  65.             [001111100],
  66.             [001111100],
  67.             [011101110],
  68.             [010000010]];
  69.         
  70.         private function createSnow():void {
  71.             // The value used for generation is prepared.
  72.             const RADIAN:Number = Math.PI*2;
  73.             
  74.             // The canvas to draw in illumination.
  75.             var snow:Snow, speed:Number, angle:Number;
  76.             forvar i :int = 0; i<SLOW_LENGTH; ++i ) {
  77.                 snow = new Snow();
  78.                 snow.x   = (Math.random()-0.5)*50 + center.x;
  79.                 snow.y   = Math.random()*rect.height;
  80.                 snow.vx = (Math.random()-0.5) * 4;
  81.                 snow.vy = Math.random()*-2;
  82.                 snow.color = Palette.WHITE;
  83.                 _snow.push( snow );
  84.             }
  85.             
  86.             // The canvas to draw in illumination.
  87.             _canvas = new BitmapData( rect.height, rect.height, true0 );
  88.             var cbm :Bitmap = addChild( new Bitmap( _canvas ) ) as Bitmap;
  89.             cbm.smoothing = true;
  90.             
  91.             // The canvas to draw in twincles.
  92.             _twincles = new BitmapData( rect.width/4>>0, rect.height/4>>0true0 );
  93.             var tbm:Bitmap = addChild( new Bitmap( _twincles ) ) as Bitmap;
  94.             tbm.scaleX = tbm.scaleY = 4;
  95.             tbm.smoothing = true;
  96.             tbm.blendMode = BlendMode.ADD;
  97.             
  98.             // Matrix to draw by size of 1/4
  99.             _matrix = new Matrix(0.25000.25);
  100.         }
  101.         
  102.         private function updateSnow(e:Event):void {
  103.             _canvas.lock();
  104.             for eachvar snow:Snow in _snow ) {
  105.                 // The Brownian motion is added.
  106.                 snow.vx += (Math.random()-0.5)*0.04;
  107.                 snow.vy += (Math.random()-0.5)*0.04;
  108.                 
  109.                 // Gravity is added.
  110.                 snow.vy += 0.015;
  111.                 
  112.                 // The wind drag is added.
  113.                 snow.vx *= 0.987;
  114.                 snow.vy *= 0.987;
  115.                 
  116.                 // The speed is added to the position. 
  117.                 snow.x += snow.vx;
  118.                 snow.y += snow.vy;
  119.                 
  120.                 // draw to canvas in position.
  121.                 _canvas.setPixel32( snow.x, snow.y, snow.color | 0xFF<<24 );
  122.                 
  123.                 // It resets it when going out of the area. 
  124.                 if( snow.x < rect.x -50 ||  snow.y < rect.y -50 || snow.x > rect.width +50 || snow.y > rect.height + 50 ) {
  125.                     snow.x = center.y + (Math.random() -0.5) * 10;
  126.                     snow.y = Math.random() *-30;
  127.                     snow.vx = (Math.random() -0.5) * 3;
  128.                     snow.vy = Math.random() *-3;
  129.                 }
  130.             }
  131.             
  132.             const OY:uint = 80;
  133.             var ba:ByteArray = new ByteArray();
  134.             SoundMixer.computeSpectrum(ba, false0);
  135.             drawTree(ba, OY, true);//left
  136.             drawTree(ba, OY, false);//right
  137.             
  138.             // draw star
  139.             for (var j:uint = 0; j < 9; j++) {
  140.                 for (var i:uint = 0; i < 9; i++ ) {
  141.                     if (star[j][i]) {
  142.                         _canvas.setPixel32( i*4+2+center.x-8*4/2, j*4+2+OY, Palette.GOLD | 0xFF<<24 );
  143.                     }
  144.                 }
  145.             }
  146.             
  147.             // ColorTransform(effect that dose blackout) is made to adjust. 
  148.             _canvas.colorTransform( _canvas.rect, _ctf );
  149.             _canvas.unlock();
  150.             
  151.              // draw to canvas in twincles by using Matrix.
  152.             _twincles.draw( _canvas, _matrix );
  153.         }
  154.         
  155.         private function drawTree(ba:ByteArray, oy:uint, lr:Boolean):void {
  156.         const H:int = 100;
  157.         var spectrum:Number = 0;
  158.         for (var j:uint = 0; j < 256; j++) {
  159.             if((ba.position/ba.length-1)) spectrum = (j/256)*ba.readFloat() * H + j/20;
  160.             for (var i:uint = 0; i < spectrum ; i++) {
  161.                 lr?
  162.                 _canvas.setPixel32( int(-i*4+2+center.x), int(j+32+oy), COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 ):
  163.                 _canvas.setPixel32( int(i*4+2+center.x), int(j+32+oy), COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 );
  164.             }
  165.         }
  166.     }
  167.         
  168.         
  169.         private function resize( e:Event = null ):void {
  170.             rect.width = stage.stageWidth;
  171.             rect.height= stage.stageHeight;
  172.             
  173.             center.x = rect.width /2>>0;
  174.             center.y = rect.height /2>>0;
  175.         }
  176.         
  177.         private function drawXmasTree():void {
  178.             var loader :Loader = new Loader();
  179.             addChild( loader );
  180.             loader.load( new URLRequest("http://swf-dev.wonderfl.net/static/assets/checkmate04/tree.jpg") );
  181.         }
  182.         private function showPaletteMap():void {
  183.             var colors:Array = Palette.getColors();
  184.             var palette:Sprite = addChild( new ColorMap( colors ) ) as Sprite;
  185.             palette.x = ( rect.width - palette.width )  /2 >>0;
  186.             palette.y = ( rect.height- palette.height ) /2 >>0;
  187.         }
  188.         
  189.         public function FlashTest() {
  190.             if( stage ) init();
  191.             else addEventListener( Event.ADDED_TO_STAGE, init );
  192.         }
  193.         
  194.         private function loadSound():void {
  195.         Security.loadPolicyFile("http://flash-scope.com/wonderfl/crossdomain.xml");
  196.         s = new Sound();
  197.         var sc:SoundChannel = new SoundChannel();
  198.         s.addEventListener(Event.COMPLETE, function(e:Event):void{
  199.             sc = s.play(0,9999);
  200.             //sc.stop();
  201.             addEventListener( Event.ENTER_FRAME, updateSnow );
  202.         });
  203.         s.load(new URLRequest("http://flash-scope.com/wonderfl/ChristmasSpectrum/o13.mp3"));
  204.     }
  205.     }
  206. }
  207. /* for Checkmate */
  208. class Palette {
  209.     public static const WHITE:uint = 0xF0F0F0;
  210.     public static const GREEN:uint = 0x008800;
  211.     public static const RED:uint = 0xCC0000;
  212.     public static const GOLD:uint = 0xFFCC66;
  213.     public static const SILVER:uint = 0xCCCCCC;
  214.     public static const BLACK:uint = 0x101010;
  215.     public static const COLORS:Array = [ WHITE, GREEN,  RED, GOLD, SILVER, BLACK ];
  216.     public static function getColors():Array { return COLORS.slice(); }
  217. }
  218. /* for Example. */
  219. class Snow {
  220.     public var x:Number = 0;
  221.     public var y:Number = 0;
  222.     public var vx:Number = 0;
  223.     public var vy:Number = 0;
  224.     public var color:uint = 0x00;
  225. }
  226. /* for debug. */
  227. import flash.display.*;
  228. class ColorMap extends Sprite {
  229.     public function ColorMap(colors:Array) {
  230.         var l:int = colors.length;
  231.         var rect:Sprite;
  232.         forvar i:int=0; i<l; ++i ) {
  233.             addChild( rect = new ColorRect( colors[ i ] ) );
  234.             rect.x =i * ColorRect.WIDTH;
  235.             rect.y =0;
  236.         }
  237.     }
  238. }
  239. /* for debug. */
  240. class ColorRect extends Sprite {
  241.     public static const WIDTH:int = 40;
  242.     public static const HEIGHT:int = 40;
  243.     public function ColorRect( color:uint ) {
  244.         super();
  245.         graphics.beginFill( color, 1 );
  246.         graphics.drawRect( 00, WIDTH, HEIGHT );
  247.         graphics.endFill();
  248.     }
  249. }
noswf
  1. // forked from osamX's ChristmasSpectrum
  2. // forked from checkmate's Checkmate vol4 Massmedian
  3. /*
  4.  * BGM: 夢ぁE��ぱぁE�E箱
  5.  *      フリー音楽素杁EH/MIX GALLERY
  6.  *      http://www.hmix.net/
  7.  */
  8. package {
  9.     import flash.display.*;
  10.     import flash.events.*;
  11.     import flash.net.*;
  12.     import flash.geom.*;
  13.     import flash.media.Sound;
  14.     import flash.media.SoundMixer;
  15.     import flash.media.SoundChannel;
  16.     import flash.utils.ByteArray;
  17.     import flash.system.Security;
  18.     
  19.     [SWF(width="465", height="465", frameRate="60", backgroundColor="0x00")]
  20.     public class FlashTest extends Sprite {
  21.         /*
  22.          * [Checkmate Vol4 by MASSMEDIAN]
  23.          * Please produce the illumination freely with a color palette. 
  24.          *
  25.          * usage of Palette class
  26.          *   A single value is used.
  27.          *     var white:uint = Palette.WHITE;
  28.          *     var green:uint = Palette.GREEN;
  29.          *     var red:uint = Palette.RED;
  30.          *     var gold:uint = Palette.GOLD;
  31.          *     var silver:uint = Palette.SILVER;
  32.          *     var black:uint = Palette.BLACK;
  33.          *   All the values are used.
  34.          *     var colors:Array = Palette.getColors();
  35.          */
  36.         private function init( e:Event = null ):void {
  37.             resize();
  38.             //drawXmasTree()
  39.             createSnow();
  40.             //showPaletteMap();
  41.             loadSound();
  42.         }
  43.         
  44.         public var rect:Rectangle= new Rectangle();
  45.         public var center:Point = new Point();
  46.         
  47.         private const SLOW_LENGTH:int = 1000;
  48.         private var _snow:Vector.<Snow> = new Vector.<Snow>();
  49.         
  50.         private var _twincles:BitmapData;
  51.         private var _canvas:BitmapData;
  52.         
  53.         private var _matrix:Matrix;
  54.         private var _ctf:ColorTransform = new ColorTransform( 0.750.80.80.95 );
  55.         
  56.         private const COLORS:Array = Palette.getColors();
  57.         private var s:Sound;
  58.         private const star:Array = [
  59.         [000010000],
  60.         [000010000],
  61.             [000111000],
  62.         [111111 ,1 ,1 ,1],
  63.         [011111110],
  64.         [001111100],
  65.         [001111100],
  66.         [011101110],
  67.         [010000010]];
  68.         
  69.         private function createSnow():void {
  70.             // The value used for generation is prepared.
  71.             const RADIAN:Number = Math.PI*2;
  72.             
  73.             // The canvas to draw in illumination.
  74.             var snow:Snow, speed:Number, angle:Number;
  75.             forvar i :int = 0; i<SLOW_LENGTH; ++i ) {
  76.                 snow = new Snow();
  77.                 snow.x   = (Math.random()-0.5)*50 + center.x;
  78.                 snow.y   = Math.random()*rect.height;
  79.                 snow.vx = (Math.random()-0.5) * 4;
  80.                 snow.vy = Math.random()*-2;
  81.                 snow.color = Palette.WHITE;
  82.                 _snow.push( snow );
  83.             }
  84.             
  85.             // The canvas to draw in illumination.
  86.             _canvas = new BitmapData( rect.height, rect.height, true0 );
  87.             var cbm :Bitmap = addChild( new Bitmap( _canvas ) ) as Bitmap;
  88.             cbm.smoothing = true;
  89.             
  90.             // The canvas to draw in twincles.
  91.             _twincles = new BitmapData( rect.width/4>>0, rect.height/4>>0true0 );
  92.             var tbm:Bitmap = addChild( new Bitmap( _twincles ) ) as Bitmap;
  93.             tbm.scaleX = tbm.scaleY = 4;
  94.             tbm.smoothing = true;
  95.             tbm.blendMode = BlendMode.ADD;
  96.             
  97.             // Matrix to draw by size of 1/4
  98.             _matrix = new Matrix(0.25000.25);
  99.         }
  100.         
  101.         private function updateSnow(e:Event):void {
  102.             _canvas.lock();
  103.             for eachvar snow:Snow in _snow ) {
  104.                 // The Brownian motion is added.
  105.                 snow.vx += (Math.random()-0.5)*0.04;
  106.                 snow.vy += (Math.random()-0.5)*0.04;
  107.                 
  108.                 // Gravity is added.
  109.                 snow.vy += 0.015;
  110.                 
  111.                 // The wind drag is added.
  112.                 snow.vx *= 0.987;
  113.                 snow.vy *= 0.987;
  114.                 
  115.                 // The speed is added to the position. 
  116.                 snow.x += snow.vx;
  117.                 snow.y += snow.vy;
  118.                 
  119.                 // draw to canvas in position.
  120.                 _canvas.setPixel32( snow.x, snow.y, snow.color | 0xFF<<24 );
  121.                 
  122.                 // It resets it when going out of the area. 
  123.                 if( snow.x < rect.x -50 ||  snow.y < rect.y -50 || snow.x > rect.width +50 || snow.y > rect.height + 50 ) {
  124.                     snow.x = center.y + (Math.random() -0.5) * 10;
  125.                     snow.y = Math.random() *-30;
  126.                     snow.vx = (Math.random() -0.5) * 3;
  127.                     snow.vy = Math.random() *-3;
  128.                 }
  129.             }
  130.             
  131.             const OY:uint = 80;
  132.         var ba:ByteArray = new ByteArray();
  133.         SoundMixer.computeSpectrum(ba, false0);
  134.         drawTree(ba, OY, true);//left
  135.         drawTree(ba, OY, false);//right
  136.             // draw star
  137.         for (var j:uint = 0; j < 9; j++) {
  138.             for (var i:uint = 0; i < 9; i++ ) {
  139.             if (star[j][i]) {
  140.                         _canvas.setPixel32( i*4+2+center.x-8*4/2, j*4+2+OY, Palette.GOLD | 0xFF<<24 );
  141.             }
  142.         }
  143.         }
  144.             // ColorTransform(effect that dose blackout) is made to adjust. 
  145.             _canvas.colorTransform( _canvas.rect, _ctf );
  146.             _canvas.unlock();
  147.             
  148.              // draw to canvas in twincles by using Matrix.
  149.             _twincles.draw( _canvas, _matrix );
  150.         }
  151.         
  152.         private function drawTree(ba:ByteArray, oy:uint, lr:Boolean):void {
  153.         const H:int = 100;
  154.         var spectrum:Number;
  155.         for (var j:uint = 0; j < 256; j++) {
  156.             spectrum = (j/256)*ba.readFloat() * H + j/20;
  157.         for (var i:uint = 0; i < spectrum ; i++) {
  158.             lr?
  159.             _canvas.setPixel32( -i*4+2+center.x, j+32+oy, COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 ):
  160.             _canvas.setPixel32( i*4+2+center.x, j+32+oy, COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 );
  161.         }
  162.         }
  163.     }
  164.         
  165.         
  166.         private function resize( e:Event = null ):void {
  167.             rect.width = stage.stageWidth;
  168.             rect.height= stage.stageHeight;
  169.             
  170.             center.x = rect.width /2>>0;
  171.             center.y = rect.height /2>>0;
  172.         }
  173.         
  174.         private function drawXmasTree():void {
  175.             var loader :Loader = new Loader();
  176.             addChild( loader );
  177.             loader.load( new URLRequest("http://swf-dev.wonderfl.net/static/assets/checkmate04/tree.jpg") );
  178.         }
  179.         private function showPaletteMap():void {
  180.             var colors:Array = Palette.getColors();
  181.             var palette:Sprite = addChild( new ColorMap( colors ) ) as Sprite;
  182.             palette.x = ( rect.width - palette.width )  /2 >>0;
  183.             palette.y = ( rect.height- palette.height ) /2 >>0;
  184.         }
  185.         
  186.         public function FlashTest() {
  187.             if( stage ) init();
  188.             else addEventListener( Event.ADDED_TO_STAGE, init );
  189.         }
  190.         
  191.         private function loadSound():void {
  192.         Security.loadPolicyFile("http://flash-scope.com/wonderfl/crossdomain.xml");
  193.         s = new Sound();
  194.         var sc:SoundChannel = new SoundChannel();
  195.         s.addEventListener(Event.COMPLETE, function(e:Event):void{
  196.             sc = s.play(0,9999);
  197.         //sc.stop();
  198.         addEventListener( Event.ENTER_FRAME, updateSnow );
  199.         });
  200.         s.load(new URLRequest("http://flash-scope.com/wonderfl/ChristmasSpectrum/o13.mp3"));
  201.     }
  202.     }
  203. }
  204. /* for Checkmate */
  205. class Palette {
  206.     public static const WHITE:uint = 0xF0F0F0;
  207.     public static const GREEN:uint = 0x008800;
  208.     public static const RED:uint = 0xCC0000;
  209.     public static const GOLD:uint = 0xFFCC66;
  210.     public static const SILVER:uint = 0xCCCCCC;
  211.     public static const BLACK:uint = 0x101010;
  212.     public static const COLORS:Array = [ WHITE, GREEN,  RED, GOLD, SILVER, BLACK ];
  213.     public static function getColors():Array { return COLORS.slice(); }
  214. }
  215. /* for Example. */
  216. class Snow {
  217.     public var x:Number = 0;
  218.     public var y:Number = 0;
  219.     public var vx:Number = 0;
  220.     public var vy:Number = 0;
  221.     public var color:uint = 0x00;
  222. }
  223. /* for debug. */
  224. import flash.display.*;
  225. class ColorMap extends Sprite {
  226.     public function ColorMap(colors:Array) {
  227.         var l:int = colors.length;
  228.         var rect:Sprite;
  229.         forvar i:int=0; i<l; ++i ) {
  230.             addChild( rect = new ColorRect( colors[ i ] ) );
  231.             rect.x =i * ColorRect.WIDTH;
  232.             rect.y =0;
  233.         }
  234.     }
  235. }
  236. /* for debug. */
  237. class ColorRect extends Sprite {
  238.     public static const WIDTH:int = 40;
  239.     public static const HEIGHT:int = 40;
  240.     public function ColorRect( color:uint ) {
  241.         super();
  242.         graphics.beginFill( color, 1 );
  243.         graphics.drawRect( 00, WIDTH, HEIGHT );
  244.         graphics.endFill();
  245.     }
  246. }
noswf
  1. // forked from osamX's ChristmasSpectrum
  2. // forked from checkmate's Checkmate vol4 Massmedian
  3. /*
  4.  * BGM: 夢いっぱいの箱
  5.  *      フリー音楽素材 H/MIX GALLERY
  6.  *      http://www.hmix.net/
  7.  */
  8. package {
  9.     import flash.display.*;
  10.     import flash.events.*;
  11.     import flash.net.*;
  12.     import flash.geom.*;
  13.     
  14.     import flash.media.Sound;
  15.     import flash.media.SoundMixer;
  16.     import flash.media.SoundChannel;
  17.     import flash.utils.ByteArray;
  18.     import flash.system.Security;
  19.     
  20.     [SWF(width="465", height="465", frameRate="60", backgroundColor="0x00")]
  21.     public class FlashTest extends Sprite {
  22.         /*
  23.          * [Checkmate Vol4 by MASSMEDIAN]
  24.          * Please produce the illumination freely with a color palette. 
  25.          *
  26.          * usage of Palette class
  27.          *   A single value is used.
  28.          *     var white:uint = Palette.WHITE;
  29.          *     var green:uint = Palette.GREEN;
  30.          *     var red:uint = Palette.RED;
  31.          *     var gold:uint = Palette.GOLD;
  32.          *     var silver:uint = Palette.SILVER;
  33.          *     var black:uint = Palette.BLACK;
  34.          *   All the values are used.
  35.          *     var colors:Array = Palette.getColors();
  36.          */
  37.         private function init( e:Event = null ):void {
  38.             resize();
  39.             //drawXmasTree()
  40.             createSnow();
  41.             //showPaletteMap();
  42.             loadSound();
  43.         }
  44.         
  45.         public var rect:Rectangle= new Rectangle();
  46.         public var center:Point = new Point();
  47.         
  48.         private const SLOW_LENGTH:int = 1000;
  49.         private var _snow:Vector.<Snow> = new Vector.<Snow>();
  50.         
  51.         private var _twincles:BitmapData;
  52.         private var _canvas:BitmapData;
  53.         
  54.         private var _matrix:Matrix;
  55.         private var _ctf:ColorTransform = new ColorTransform( 0.750.80.80.95 );
  56.         
  57.         private const COLORS:Array = Palette.getColors();
  58.         private var s:Sound;
  59.         private const star:Array = [
  60.         [000010000],
  61.         [000010000],
  62.             [000111000],
  63.         [111111 ,1 ,1 ,1],
  64.         [011111110],
  65.         [001111100],
  66.         [001111100],
  67.         [011101110],
  68.         [010000010]];
  69.         
  70.         private function createSnow():void {
  71.             // The value used for generation is prepared.
  72.             const RADIAN:Number = Math.PI*2;
  73.             
  74.             // The canvas to draw in illumination.
  75.             var snow:Snow, speed:Number, angle:Number;
  76.             forvar i :int = 0; i<SLOW_LENGTH; ++i ) {
  77.                 snow = new Snow();
  78.                 snow.x   = (Math.random()-0.5)*50 + center.x;
  79.                 snow.y   = Math.random()*rect.height;
  80.                 snow.vx = (Math.random()-0.5) * 4;
  81.                 snow.vy = Math.random()*-2;
  82.                 snow.color = Palette.RED;
  83.                 _snow.push( snow );
  84.             }
  85.             
  86.             // The canvas to draw in illumination.
  87.             _canvas = new BitmapData( rect.width, rect.height, true0 );
  88.             var cbm :Bitmap = addChild( new Bitmap( _canvas ) ) as Bitmap;
  89.             cbm.smoothing = true;
  90.             
  91.             // The canvas to draw in twincles.
  92.             _twincles = new BitmapData( rect.width/4>>0, rect.height/4>>0true0 );
  93.             var tbm:Bitmap = addChild( new Bitmap( _twincles ) ) as Bitmap;
  94.             tbm.scaleX = tbm.scaleY = 4;
  95.             tbm.smoothing = true;
  96.             tbm.blendMode = BlendMode.ADD;
  97.             
  98.             // Matrix to draw by size of 1/4
  99.             _matrix = new Matrix(0.25000.25);
  100.         }
  101.         
  102.         private function updateSnow(e:Event):void {
  103.             _canvas.lock();
  104.             for eachvar snow:Snow in _snow ) {
  105.                 // The Brownian motion is added.
  106.                 snow.vx += (Math.random()-0.5)*0.04;
  107.                 snow.vy += (Math.random()-0.5)*0.04;
  108.                 
  109.                 // Gravity is added.
  110.                 snow.vy += 0.015;
  111.                 
  112.                 // The wind drag is added.
  113.                 snow.vx *= 0.987;
  114.                 snow.vy *= 0.987;
  115.                 
  116.                 // The speed is added to the position. 
  117.                 snow.x += snow.vx;
  118.                 snow.y += snow.vy;
  119.                 
  120.                 // draw to canvas in position.
  121.                 _canvas.setPixel32( snow.x, snow.y, snow.color | 0xFF<<24 );
  122.                 
  123.                 // It resets it when going out of the area. 
  124.                 if( snow.x < rect.x -50 ||  snow.y < rect.y -50 || snow.x > rect.width +50 || snow.y > rect.height + 50 ) {
  125.                     snow.x = center.y + (Math.random() -0.5) * 10;
  126.                     snow.y = Math.random() *-30;
  127.                     snow.vx = (Math.random() -0.5) * 3;
  128.                     snow.vy = Math.random() *-3;
  129.                 }
  130.             }
  131.             
  132.             const OY:uint = 80;
  133.         var ba:ByteArray = new ByteArray();
  134.         SoundMixer.computeSpectrum(ba, false0);
  135.         drawTree(ba, OY, true);//left
  136.         drawTree(ba, OY, false);//right
  137.             // draw star
  138.         for (var j:uint = 0; j < 9; j++) {
  139.             for (var i:uint = 0; i < 9; i++ ) {
  140.             if (star[j][i]) {
  141.                         _canvas.setPixel32( i*4+2+center.x-8*4/2, j*4+2+OY, Palette.GOLD | 0xFF<<24 );
  142.             }
  143.         }
  144.         }
  145.             // ColorTransform(effect that dose blackout) is made to adjust. 
  146.             _canvas.colorTransform( _canvas.rect, _ctf );
  147.             _canvas.unlock();
  148.             
  149.              // draw to canvas in twincles by using Matrix.
  150.             _twincles.draw( _canvas, _matrix );
  151.         }
  152.         
  153.         private function drawTree(ba:ByteArray, oy:uint, lr:Boolean):void {
  154.         const H:int = 100;
  155.         var spectrum:Number;
  156.         for (var j:uint = 0; j < 256; j++) {
  157.             spectrum = (j/256)*ba.readFloat() * H + j/20;
  158.         for (var i:uint = 0; i < spectrum ; i++) {
  159.             lr?
  160.             _canvas.setPixel32( -i*4+2+center.x, j+32+oy, COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 ):
  161.             _canvas.setPixel32( i*4+2+center.x, j+32+oy, COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 );
  162.         }
  163.         }
  164.     }
  165.         
  166.         
  167.         private function resize( e:Event = null ):void {
  168.             rect.width = stage.stageWidth;
  169.             rect.height= stage.stageHeight;
  170.             
  171.             center.x = rect.width /2>>0;
  172.             center.y = rect.height /2>>0;
  173.         }
  174.         
  175.         private function drawXmasTree():void {
  176.             var loader :Loader = new Loader();
  177.             addChild( loader );
  178.             loader.load( new URLRequest("http://swf-dev.wonderfl.net/static/assets/checkmate04/tree.jpg") );
  179.         }
  180.         private function showPaletteMap():void {
  181.             var colors:Array = Palette.getColors();
  182.             var palette:Sprite = addChild( new ColorMap( colors ) ) as Sprite;
  183.             palette.x = ( rect.width - palette.width )  /2 >>0;
  184.             palette.y = ( rect.height- palette.height ) /2 >>0;
  185.         }
  186.         
  187.         public function FlashTest() {
  188.             if( stage ) init();
  189.             else addEventListener( Event.ADDED_TO_STAGE, init );
  190.         }
  191.         
  192.         private function loadSound():void {
  193.         Security.loadPolicyFile("http://flash-scope.com/wonderfl/crossdomain.xml");
  194.         s = new Sound();
  195.         var sc:SoundChannel = new SoundChannel();
  196.         s.addEventListener(Event.COMPLETE, function(e:Event):void{
  197.             sc = s.play(0,9999);
  198.         //sc.stop();
  199.         addEventListener( Event.ENTER_FRAME, updateSnow );
  200.         });
  201.         s.load(new URLRequest("http://flash-scope.com/wonderfl/ChristmasSpectrum/o13.mp3"));
  202.     }
  203.     }
  204. }
  205. /* for Checkmate */
  206. class Palette {
  207.     public static const WHITE:uint = 0xF0F0F0;
  208.     public static const GREEN:uint = 0x008800;
  209.     public static const RED:uint = 0xCC0000;
  210.     public static const GOLD:uint = 0xFFCC66;
  211.     public static const SILVER:uint = 0xCCCCCC;
  212.     public static const BLACK:uint = 0x101010;
  213.     public static const COLORS:Array = [ WHITE, GREEN,  RED, GOLD, SILVER, BLACK ];
  214.     public static function getColors():Array { return COLORS.slice(); }
  215. }
  216. /* for Example. */
  217. class Snow {
  218.     public var x:Number = 0;
  219.     public var y:Number = 0;
  220.     public var vx:Number = 0;
  221.     public var vy:Number = 0;
  222.     public var color:uint = 0x00;
  223. }
  224. /* for debug. */
  225. import flash.display.*;
  226. class ColorMap extends Sprite {
  227.     public function ColorMap(colors:Array) {
  228.         var l:int = colors.length;
  229.         var rect:Sprite;
  230.         forvar i:int=0; i<l; ++i ) {
  231.             addChild( rect = new ColorRect( colors[ i ] ) );
  232.             rect.x =i * ColorRect.WIDTH;
  233.             rect.y =0;
  234.         }
  235.     }
  236. }
  237. /* for debug. */
  238. class ColorRect extends Sprite {
  239.     public static const WIDTH:int = 40;
  240.     public static const HEIGHT:int = 40;
  241.     public function ColorRect( color:uint ) {
  242.         super();
  243.         graphics.beginFill( color, 1 );
  244.         graphics.drawRect( 00, WIDTH, HEIGHT );
  245.         graphics.endFill();
  246.     }
  247. }
noswf
  1. // forked from osamX's ChristmasSpectrum
  2. // forked from checkmate's Checkmate vol4 Massmedian
  3. /*
  4.  * BGM: 夢いっぱいの箱
  5.  *      フリー音楽素材 H/MIX GALLERY
  6.  *      http://www.hmix.net/
  7.  */
  8. package {
  9.     import flash.display.*;
  10.     import flash.events.*;
  11.     import flash.net.*;
  12.     import flash.geom.*;
  13.     
  14.     import flash.media.Sound;
  15.     import flash.media.SoundMixer;
  16.     import flash.media.SoundChannel;
  17.     import flash.utils.ByteArray;
  18.     import flash.system.Security;
  19.     
  20.     [SWF(width="465", height="465", frameRate="60", backgroundColor="0x00")]
  21.     public class FlashTest extends Sprite {
  22.         /*
  23.          * [Checkmate Vol4 by MASSMEDIAN]
  24.          * Please produce the illumination freely with a color palette. 
  25.          *
  26.          * usage of Palette class
  27.          *   A single value is used.
  28.          *     var white:uint = Palette.WHITE;
  29.          *     var green:uint = Palette.GREEN;
  30.          *     var red:uint = Palette.RED;
  31.          *     var gold:uint = Palette.GOLD;
  32.          *     var silver:uint = Palette.SILVER;
  33.          *     var black:uint = Palette.BLACK;
  34.          *   All the values are used.
  35.          *     var colors:Array = Palette.getColors();
  36.          */
  37.         private function init( e:Event = null ):void {
  38.             resize();
  39.             //drawXmasTree()
  40.             createSnow();
  41.             //showPaletteMap();
  42.             loadSound();
  43.         }
  44.         
  45.         public var rect:Rectangle= new Rectangle();
  46.         public var center:Point = new Point();
  47.         
  48.         private const SLOW_LENGTH:int = 1000;
  49.         private var _snow:Vector.<Snow> = new Vector.<Snow>();
  50.         
  51.         private var _twincles:BitmapData;
  52.         private var _canvas:BitmapData;
  53.         
  54.         private var _matrix:Matrix;
  55.         private var _ctf:ColorTransform = new ColorTransform( 0.750.80.80.95 );
  56.         
  57.         private const COLORS:Array = Palette.getColors();
  58.         private var s:Sound;
  59.         private const star:Array = [
  60.         [000011100],
  61.         [000010000],
  62.             [000111000],
  63.         [111111 ,1 ,1 ,1],
  64.         [011111110],
  65.         [001111100],
  66.         [001111100],
  67.         [011101110],
  68.         [010000010]];
  69.         
  70.         private function createSnow():void {
  71.             // The value used for generation is prepared.
  72.             const RADIAN:Number = Math.PI*2;
  73.             
  74.             // The canvas to draw in illumination.
  75.             var snow:Snow, speed:Number, angle:Number;
  76.             forvar i :int = 0; i<SLOW_LENGTH; ++i ) {
  77.                 snow = new Snow();
  78.                 snow.x   = (Math.random()-0.5)*50 + center.x;
  79.                 snow.y   = Math.random()*rect.height;
  80.                 snow.vx = (Math.random()-0.5) * 4;
  81.                 snow.vy = Math.random()*-2;
  82.                 snow.color = Palette.WHITE;
  83.                 _snow.push( snow );
  84.             }
  85.             
  86.             // The canvas to draw in illumination.
  87.             _canvas = new BitmapData( rect.height, rect.height, true0 );
  88.             var cbm :Bitmap = addChild( new Bitmap( _canvas ) ) as Bitmap;
  89.             cbm.smoothing = true;
  90.             
  91.             // The canvas to draw in twincles.
  92.             _twincles = new BitmapData( rect.width/4>>0, rect.height/4>>0true0 );
  93.             var tbm:Bitmap = addChild( new Bitmap( _twincles ) ) as Bitmap;
  94.             tbm.scaleX = tbm.scaleY = 4;
  95.             tbm.smoothing = true;
  96.             tbm.blendMode = BlendMode.ADD;
  97.             
  98.             // Matrix to draw by size of 1/4
  99.             _matrix = new Matrix(0.25000.25);
  100.         }
  101.         
  102.         private function updateSnow(e:Event):void {
  103.             _canvas.lock();
  104.             for eachvar snow:Snow in _snow ) {
  105.                 // The Brownian motion is added.
  106.                 snow.vx += (Math.random()-0.5)*0.04;
  107.                 snow.vy += (Math.random()-0.5)*0.04;
  108.                 
  109.                 // Gravity is added.
  110.                 snow.vy += 0.015;
  111.                 
  112.                 // The wind drag is added.
  113.                 snow.vx *= 0.987;
  114.                 snow.vy *= 0.987;
  115.                 
  116.                 // The speed is added to the position. 
  117.                 snow.x += snow.vx;
  118.                 snow.y += snow.vy;
  119.                 
  120.                 // draw to canvas in position.
  121.                 _canvas.setPixel32( snow.x, snow.y, snow.color | 0xFF<<24 );
  122.                 
  123.                 // It resets it when going out of the area. 
  124.                 if( snow.x < rect.x -50 ||  snow.y < rect.y -50 || snow.x > rect.width +50 || snow.y > rect.height + 50 ) {
  125.                     snow.x = center.y + (Math.random() -0.5) * 10;
  126.                     snow.y = Math.random() *-30;
  127.                     snow.vx = (Math.random() -0.5) * 3;
  128.                     snow.vy = Math.random() *-3;
  129.                 }
  130.             }
  131.             
  132.             const OY:uint = 80;
  133.         var ba:ByteArray = new ByteArray();
  134.         SoundMixer.computeSpectrum(ba, false0);
  135.         drawTree(ba, OY, true);//left
  136.         drawTree(ba, OY, false);//right
  137.             // draw star
  138.         for (var j:uint = 0; j < 9; j++) {
  139.             for (var i:uint = 0; i < 9; i++ ) {
  140.             if (star[j][i]) {
  141.                         _canvas.setPixel32( i*4+2+center.x-8*4/280, Palette.GOLD | 0xFF<<24 );
  142.             }
  143.         }
  144.         }
  145.             // ColorTransform(effect that dose blackout) is made to adjust. 
  146.             _canvas.colorTransform( _canvas.rect, _ctf );
  147.             _canvas.unlock();
  148.             
  149.              // draw to canvas in twincles by using Matrix.
  150.             _twincles.draw( _canvas, _matrix );
  151.         }
  152.         
  153.         private function drawTree(ba:ByteArray, oy:uint, lr:Boolean):void {
  154.         const H:int = 100;
  155.         var spectrum:Number;
  156.         for (var j:uint = 0; j < 256; j++) {
  157.             spectrum = (j/256)*ba.readFloat() * H + j/20;
  158.         for (var i:uint = 0; i < spectrum ; i++) {
  159.             lr?
  160.             _canvas.setPixel32( -i*4+2+center.x, j+32+oy, COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 ):
  161.             _canvas.setPixel32( i*4+2+center.x, j+32+oy, COLORS[int(COLORS.length * Math.random())] | 0xFF << 24 );
  162.         }
  163.         }
  164.     }
  165.         
  166.         
  167.         private function resize( e:Event = null ):void {
  168.             rect.width = stage.stageWidth;
  169.             rect.height= stage.stageHeight;
  170.             
  171.             center.x = rect.width /2>>0;
  172.             center.y = rect.height /2>>0;
  173.         }
  174.         
  175.         private function drawXmasTree():void {
  176.             var loader :Loader = new Loader();
  177.             addChild( loader );
  178.             loader.load( new URLRequest("http://swf-dev.wonderfl.net/static/assets/checkmate04/tree.jpg") );
  179.         }
  180.         private function showPaletteMap():void {
  181.             var colors:Array = Palette.getColors();
  182.             var palette:Sprite = addChild( new ColorMap( colors ) ) as Sprite;
  183.             palette.x = ( rect.width - palette.width )  /2 >>0;
  184.             palette.y = ( rect.height- palette.height ) /2 >>0;
  185.         }
  186.         
  187.         public function FlashTest() {
  188.             if( stage ) init();
  189.             else addEventListener( Event.ADDED_TO_STAGE, init );
  190.         }
  191.         
  192.         private function loadSound():void {
  193.         Security.loadPolicyFile("http://flash-scope.com/wonderfl/crossdomain.xml");
  194.         s = new Sound();
  195.         var sc:SoundChannel = new SoundChannel();
  196.         s.addEventListener(Event.COMPLETE, function(e:Event):void{
  197.             sc = s.play(0,9999);
  198.         //sc.stop();
  199.         addEventListener( Event.ENTER_FRAME, updateSnow );
  200.         });
  201.         s.load(new URLRequest("http://flash-scope.com/wonderfl/ChristmasSpectrum/o13.mp3"));
  202.     }
  203.     }
  204. }
  205. /* for Checkmate */
  206. class Palette {
  207.     public static const WHITE:uint = 0xF0F0F0;
  208.     public static const GREEN:uint = 0x008800;
  209.     public static const RED:uint = 0xCC0000;
  210.     public static const GOLD:uint = 0xFFCC66;
  211.     public static const SILVER:uint = 0xCCCCCC;
  212.     public static const BLACK:uint = 0x101010;
  213.     public static const COLORS:Array = [ WHITE, GREEN,  RED, GOLD, SILVER, BLACK ];
  214.     public static function getColors():Array { return COLORS.slice(); }
  215. }
  216. /* for Example. */
  217. class Snow {
  218.     public var x:Number = 0;
  219.     public var y:Number = 0;
  220.     public var vx:Number = 0;
  221.     public var vy:Number = 0;
  222.     public var color:uint = 0x00;
  223. }
  224. /* for debug. */
  225. import flash.display.*;
  226. class ColorMap extends Sprite {
  227.     public function ColorMap(colors:Array) {
  228.         var l:int = colors.length;
  229.         var rect:Sprite;
  230.         forvar i:int=0; i<l; ++i ) {
  231.             addChild( rect = new ColorRect( colors[ i ] ) );
  232.             rect.x =i * ColorRect.WIDTH;
  233.             rect.y =0;
  234.         }
  235.     }
  236. }
  237. /* for debug. */
  238. class ColorRect extends Sprite {
  239.     public static const WIDTH:int = 40;
  240.     public static const HEIGHT:int = 40;
  241.     public function ColorRect( color:uint ) {
  242.         super();
  243.         graphics.beginFill( color, 1 );
  244.         graphics.drawRect( 00, WIDTH, HEIGHT );
  245.         graphics.endFill();
  246.     }
  247. }
noswf

ad

Get Adobe Flash Player