Creek&River Co., Ltd.

この度は、美しい花火、アイディア満載の花火、衝撃的な花火など、いろいろな花火のご投稿ありがとうございました!またそれぞれの作品にforkしてくださった方、コメントしてくださった方もありがとうございます!
forkすることによって、より動きのある作品に変化していく姿も楽しんで見ていました。
1ヶ月で終えるのはとても名残惜しいですが、これからもwondelfulで新しいクリエイティブを生み出し、Action scriptの可能性が広がることを楽しみにしています!

First of all, thank you for submitting many firework works such as beautiful fireworks, full idea of fireworks, crashing fireworks and so on. Also, we appriciate those who forked or left comments!
We enjoyed watching each works's shape that keeps changing by forking.
Although, it is regretful to end this challenge, we are looking forward to the new creation produced by wonderfl from now on, and the widespread of ability of ActionScript!

  1. Queen
    coppieee
    present 書籍『Flash + After Effects』と魚沼産コシヒカリ (書籍提供:ボーンデジタル)
    "Flash + After Effects"(a book written by Chris Jackson, 2009, presented by Born Digital, Inc.) and Koshihikari, Japanese top brand rice.
  2. Bishop
    sekiryou
    present「PUSH」映画鑑賞チケット&DVD「椿姫彩菜ビューティートライアルフィットネスタイチー」とC&R社グッズ(チケット・DVD提供:株式会社プレシディオ)
    Ticket for movie "PUSH," DVD"Ayana Tsubaki's beauty trial fitness 'TaiChi'," and CREEK & RIVER's goods.(Ticket and DVD are presented by PRESIDIO CORPORATION)
  3. Knight
    yd_niku
    presentgolla:Mac13インチバッグ『Black Deal 13』&i-phoneケース『Black SLIMCASE(L) TURQUOISE』 (提供:golla)
    golla, Laptop sleeve "Black Deal 13" for Mac13 and iPhone case "Black SLIMCASE(L) TURQUOISE" (presented by golla)

View All Other Challengers

Queencoppieee

  1. /**
  2.  * たーまやー。
  3.  * 正規表現に苦戦しながらも、twitterでヘルプを求めて出来上がった作品。
  4.  * Twitterで打ち上げたいコメントを、
  5.  * #hanabi [( ゚д゚ )]
  6.  * のように #hanabi [コメント]って書けば打ち上げリストに追加されるよ!
  7.  * []は必須だからちゃんと付けてね!
  8.  * 
  9.  * Tweet hanabi!のボタンを押せばテンプレが表示される。
  10.  * 
  11.  * 花火リスト
  12.  * http://search.twitter.com/search?q=%23hanabi
  13.  * 
  14.  * katan_t irgal_ Horiuchi_H katan_t repeatedly aibou nakawake seisuke uwitenpen beinteractive 
  15.  * に感謝!
  16.  * @author coppieee
  17.  */
  18. package {
  19.     import com.bit101.components.PushButton;
  20.     import flash.display.*;
  21.     import flash.events.*;
  22.     import flash.geom.*;
  23.     import flash.net.*;
  24.     import flash.text.engine.TextBlock;
  25.     import flash.text.engine.TextElement;
  26.     import flash.text.engine.TextLine;
  27.     import flash.text.TextField;
  28.     import flash.text.TextFieldAutoSize;
  29.     import flash.text.TextFormat;
  30.     import flash.utils.*;
  31.     import flash.system.*;
  32.     import com.flashdynamix.utils.*;
  33.     [SWF(backgroundColor=0x000000, frameRate=60)]
  34.     public class Sponsor extends Sprite {
  35.      
  36.         private var _particles:Vector.<Object>;
  37.         private var _gradientMap:BitmapData; 
  38.         private var _timer:Timer; 
  39.    
  40.         private static const PARTICLES_LENGTH:int = 1000;
  41.         //private static const _texts:Array = ["( ゚д゚ )","\(^o^)/","(「・ω・)「",""];
  42.         private var _texts:Array;
  43.         private var _newestTexts:Array;
  44.         private function setup():void {
  45.             //Wonderfl.capture_delay(2);
  46.             _gradientMap= new BitmapData(200,10true0);
  47.              //addChild( new Bitmap( _gradientMap) ); // for debug
  48.             updateGradientFill();
  49.                 
  50.             //shotFirework();
  51.             shotAA();
  52.            
  53.             _timer = new Timer( 50000 );
  54.             _timer.addEventListener( TimerEvent.TIMER, timerHadler );
  55.             _timer.start();
  56.             
  57.             _loader = new Loader();
  58.             _loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadComplete );
  59.             _loader.load( new URLRequest("http://level0.kayac.com/space.jpg"), new LoaderContext(true) );
  60.             
  61.             
  62.             //var textLoader:URLLoader =  new URLLoader(new URLRequest("http://search.twitter.com/search.atom?q=%23hanabi&rpp=100"));
  63.             //textLoader.addEventListener(Event.COMPLETE, function(e:Event):void {
  64.                 //default xml namespace = new Namespace("http://www.w3.org/2005/Atom");
  65.                 //var htmlText:XML = XML(textLoader.data);
  66.                 //var title:XMLList = htmlText.entry.title;
  67.                 //var xs:Array = [];
  68.                 //for each(var c:XML in  title)
  69.                 //{
  70.                     //xs.push.apply(null,scan(c.toString(),/\[(.+)\]/));
  71.                 //}
  72.                 //if (xs.length >= 1)
  73.                 //{
  74.                     //_texts = xs;
  75.                 //}
  76.             //});
  77.             var loadTexts:Function = function (rpp:int, arraySetter:Function):void {
  78.                 var textLoader:URLLoader = new URLLoader(new URLRequest("http://search.twitter.com/search.atom?q=%23hanabi&rpp=" + rpp));
  79.                 textLoader.addEventListener(Event.COMPLETE, function(e:Event):void {
  80.                     default xml namespace = new Namespace("http://www.w3.org/2005/Atom");
  81.                     var htmlText:XML = XML(textLoader.data);
  82.                     var title:XMLList = htmlText.entry.title;
  83.                     var xs:Array = [];
  84.                     for each(var c:XML in  title)
  85.                     {
  86.                         xs.push.apply(null,scan(c.toString(),/\[(.+)\]/));
  87.                     }
  88.                     if (xs.length >= 1)
  89.                     {
  90.                         //_texts = xs;
  91.                         arraySetter(xs);
  92.                     }
  93.                 });
  94.             }
  95.             loadTexts(100function(arr:Array):void { _texts = arr } );
  96.             loadTexts(20function(arr:Array):void { _newestTexts = arr } );
  97.             
  98.             var tweetButton:PushButton = new PushButton(this);
  99.             tweetButton.label = "Tweet Hanabi!";
  100.             tweetButton.alpha = 0.8;
  101.             tweetButton.x = (465 - tweetButton.width) / 2;
  102.             tweetButton.y = (465 - tweetButton.height);
  103.             tweetButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
  104.                 navigateToURL(new URLRequest("http://twitter.com/home/?status=" 
  105.                     + escapeMultiByte("#hanabi [] http://bit.ly/AAHanabi")
  106.                 ));
  107.             });
  108.             
  109.         }
  110.         private var _loader:Loader;
  111.         private function onLoadComplete(e:Event):void {
  112.             addChildAt( _loader.content, 0 ); 
  113.         }
  114.         
  115.         private function shotAA():void
  116.         {
  117.             var text:String = "(・ω・)";
  118.             
  119.             if (_texts != null && _newestTexts != null)
  120.             {
  121.                 if (Math.random() > 0.5)
  122.                 {
  123.                     text = _texts[Math.floor(_texts.length * Math.random())];
  124.                 }else
  125.                 {
  126.                     text = _newestTexts[Math.floor(_newestTexts.length * Math.random())];
  127.                 }
  128.             }
  129.             _particles = new Vector.<Object>();
  130.             
  131.             var tf:TextField = new TextField();
  132.             tf.autoSize = TextFieldAutoSize.LEFT;
  133.             var format:TextFormat = new TextFormat();
  134.             format.size = 20;
  135.             tf.defaultTextFormat = format;
  136.             tf.text = text;
  137.             var b:BitmapData = new BitmapData(tf.width, tf.height, false);
  138.             b.draw(tf);
  139.             const offsetX:int = 0;
  140.             const offsetY:int = - 45;
  141.             const scale:Number = 20/b.width;
  142.             for (var i:int = 0; i < b.width; i++ )
  143.             {
  144.                 for (var j:int = 0; j < b.height; j++ )
  145.                 {
  146.                     if (b.getPixel(i, j) == 0xFFFFFF) { continue ; }
  147.                     
  148.                     var direction:Number = Math.random()*Math.PI*2;
  149.                     var tx:Number = Math.sin(direction);
  150.                     var ty:Number = Math.cos(direction);
  151.                     //var sl:Number = Math.random()* radius +2;
  152.                     var vl:Number = Math.random()/10;
  153.                     
  154.                     var p:Object = {
  155.                         x:_center.x,
  156.                         y:_center.y,
  157.                         vx:(i -b.width / 2) *scale + tx*vl,
  158.                         vy:(j -b.height / 2) *scale +ty*vl,
  159.                         life:Math.random()*30+170
  160.                     };
  161.                     _particles.push(p);
  162.                     
  163.                 }
  164.             }
  165.             b.dispose();
  166.             
  167.         }
  168.         
  169.         private static const FRICTION:Number = 0.96;
  170.         private static const GRAVITY:Number = 0.006;
  171.         private static const WIND:Point = new Point(0.001,0 );
  172.         
  173.         private function updateCalcuration():void{
  174.             for eachvar p:Object in _particles ) {
  175.                 p.vx =  p.vx * FRICTION + WIND.x + Math.random()*0.01-.005;
  176.                 p.vy =  p.vy * FRICTION + WIND.y + GRAVITY + Math.random()*0.01-.005;
  177.                 p.x = p.x + p.vx;
  178.                 p.y = p.y + p.vy;
  179.                 p.life--;
  180.             }
  181.         }
  182.         
  183.         private function updateDrawing():void{
  184.             _canvas.colorTransform( _canvas.rect, CTF );
  185.             _canvas.lock();
  186.             for eachvar p:Object in _particles ) {
  187.                 if( p.life <= 0 ) continue;
  188.                 _canvas.setPixel32( p.x, p.y, getColor(p.life) );
  189.             }
  190.             _canvas.unlock();
  191.         }
  192.          
  193.         private function timerHadler (e:Event):void{
  194.            updateGradientFill();
  195.             _particles = null;
  196.             //shotFirework();
  197.             shotAA();
  198.         }
  199.          
  200.         private function getColor(position:int):uint {
  201.             return _gradientMap.getPixel( position, 0 ) | 0xFF000000;
  202.         }
  203.         
  204.         private const CTF:ColorTransform = new ColorTransform( 0.940.940.940.9 );
  205.         private const COLORS:Array = [ 0xFFCCFF, 0xFF9999, 0xFFFF99, 0x99CCFF, 0xCCFF99 ];
  206.         private function updateGradientFill():void {
  207.             var sp:Shape= new Shape();
  208.             var color:uint = COLORS[ Math.random()*COLORS.length>>0];
  209.             var mtx:Matrix = new Matrix();
  210.             mtx.createGradientBox(2000000);
  211.             sp.graphics.beginGradientFill( GradientType.LINEAR,
  212.                 [ 0x333333, color, color, color*0.9>>0, 0x000000 ],
  213.                 [ 11111 ],
  214.                 [ 864102204255],
  215.                 mtx,
  216.                 InterpolationMethod.RGB
  217.             );
  218.             sp.graphics.drawRect( 0020010 );
  219.             sp.graphics.endFill();
  220.             _gradientMap.draw(sp);
  221.             sp = null;    
  222.         }
  223.         
  224.         private var _canvas:BitmapData;
  225.         private var _center:Point;
  226.         private function init():void{
  227.             _center= new Point();
  228.             _center.x = stage.stageWidth*0.5>>0;
  229.             _center.y = stage.stageHeight*0.5>>0;
  230.             
  231.             _canvas  = new BitmapData( stage.stageWidth, stage.stageHeight, true0 );
  232.             addChild( new Bitmap(_canvas) );
  233.             
  234.             setup();
  235.             addEventListener( Event.ENTER_FRAME, enterFrame);
  236.             
  237.             SWFProfiler.init( this );
  238.         }
  239.         private function enterFrame( e:Event ):void {
  240.             updateCalcuration();
  241.             updateDrawing();
  242.         }
  243.         
  244.         public function Sponsor() {
  245.             addEventListener( Event.ADDED_TO_STAGE, addToStage );
  246.         }
  247.         private function addToStage (e:Event):void {
  248.             init();
  249.         }
  250.     }
  251. }
  252. /**
  253.  * @see http://takumakei.blogspot.com/2009/05/actionscriptrubystringscan.html
  254.  */ 
  255. //package com.blogspot.takumakei.utils
  256. //{
  257.     //public
  258.     function scan(str:String, re:RegExp):Array
  259.     {
  260.         if(!re.global){
  261.             var flags:String = 'g';
  262.             
  263.             if(re.dotall)
  264.                 flags += 's';
  265.             if(re.multiline)
  266.                 flags += 'm';
  267.             if(re.ignoreCase)
  268.                 flags += 'i';
  269.             if(re.extended)
  270.                 flags += 'x';
  271.             re = new RegExp(re.source, flags);                    
  272.         }
  273.         var r:Array = [];
  274.         var m:Array = re.exec(str);
  275.         while(null != m){
  276.             if(1 == m.length)
  277.                 r.push(m[0]);
  278.             else
  279.                 r.push(m.slice(1, m.length));
  280.             m = re.exec(str);
  281.         }
  282.         return r;
  283.     }
  284. //}
  285.     
flash swf thumbnail play
出題者からのコメント
twitterと花火の連携アイディアに脱帽!すごく面白いです。
twitterでつぶやいたコメントが花火になるなんて~♪♪
花火が消え行く様もとても儚くてGOOD。弊社も早速、ログインして打ち上げてみました!
Comments from Sponsor
Cooperated idea of fireworks with twitter is so interesting!
After tweeting in twitter, the comment becomes fireworks! ♪♪
It's good that fireworks is disappeared momentarily. We have enjoyed tweeting.

Bishopsekiryou

  1. // forked from checkmate's Creek challenge
  2. package {
  3.     import flash.display.MovieClip;
  4.     import flash.events.Event;
  5.     import flash.display.Bitmap;
  6.     import flash.display.BitmapData;
  7.     import flash.geom.Matrix;
  8.     import flash.geom.Point;
  9.     import flash.display.BlendMode;
  10.     import flash.display.PixelSnapping;
  11.     import flash.geom.Rectangle;
  12.     import flash.geom.ColorTransform;
  13.     import flash.filters.BlurFilter;
  14.     [SWF(width = "465", height = "465", backgroundColor = "0x000000", frameRate = "30")]
  15.     public class BeneathSpark extends MovieClip {
  16.         private var _canvas:BitmapData;
  17.         private var bmp:Bitmap;
  18.         private var _particles:Array;
  19.         private var _glow:BitmapData;
  20.         private var _rect:Rectangle;
  21.         private var cTra:ColorTransform;
  22.         private var FocalLength:Number = 200;
  23.         private var bullets:Array = [];
  24.         private const bulletAmount:uint = 20;
  25.         private var particles:Array = [];
  26.         private const STAGE_WIDTH = stage.stageWidth;
  27.         private const STAGE_HEIGHT = stage.stageHeight;
  28.         private const STAGE_CENTER_X = stage.stageWidth / 2;
  29.         private const STAGE_CENTER_Y = stage.stageHeight / 2;
  30.         public function BeneathSpark()
  31.         {
  32.             init()
  33.         }
  34.         private function init():void
  35.         {
  36.             _particles = [];
  37.             _canvas = new BitmapData (STAGE_WIDTH, STAGE_HEIGHT, true, 0xFFFFFF);
  38.             bmp = new Bitmap (_canvas);
  39.             addChild (bmp);
  40.             _glow = new BitmapData( STAGE_WIDTH/4, STAGE_HEIGHT/4false, 0x0);
  41.             var bm:Bitmap = addChild(new Bitmap(_glow, PixelSnapping.NEVER, true)) as Bitmap;
  42.             bm.scaleX = bm.scaleY = 4;
  43.             bm.blendMode = BlendMode.ADD;
  44.             _rect = new Rectangle(00, STAGE_WIDTH, STAGE_HEIGHT);
  45.             cTra = new ColorTransform( 0.950.950.951.2 );
  46.             for ( var i = 0; i < bulletAmount; i++ )
  47.             {
  48.                 var p:bullet = new bullet();
  49.                 bullets.push( p );
  50.                 purposePoint( p );
  51.                 p.PositionY -= 280;
  52.             }
  53.             addEventListener(Event.ENTER_FRAME, onEventHandler);
  54.         }
  55.         private function createParticle( sx:Number, sy:Number, sz:Number ):void
  56.         {
  57.             var i:int = 120;
  58.             while (i--) {
  59.                 var p:Particle = new Particle();
  60.                 p.PositionX = sx;
  61.                 p.PositionY = sy;
  62.                 p.PositionZ = sz;
  63.                 var radius:Number = Math.sqrt(Math.random()) * 1.3;
  64.                 var angle:Number = Math.random() * Math.PI * 2;
  65.                 var angle2:Number = Math.random() * Math.PI * 2;
  66.                 p.vx = Math.cos( angle ) * radius;
  67.                 p.vy = Math.sin( angle2 ) * radius;
  68.                 p.vz = Math.sin( angle ) * radius;
  69.                 _particles.push(p);
  70.             }
  71.         }
  72.         private function purposePoint( t )
  73.         {
  74.             t.PurposeX = Math.random() * 120 -60;
  75.             t.PurposeY = Math.random() * 40 -160
  76.             t.PurposeZ = Math.random() * 120 -60;
  77.             var rnd:Number = ( Math.random() * 2 + 2 ) / 400;
  78.             t.vx = ( t.PurposeX - t.PositionX ) * rnd;
  79.             t.vy = ( t.PurposeY - t.PositionY ) * rnd;
  80.             t.vz = ( t.PurposeZ - t.PositionZ ) * rnd;
  81.         }
  82.         private function WtoS( t ):void
  83.         {
  84.             if ( t.PositionY > -FocalLength ) {
  85.                 t.scale = FocalLength / (FocalLength + t.PositionY);
  86.                 t.px = STAGE_CENTER_X + t.PositionX * t.scale;
  87.                 t.py = STAGE_CENTER_Y + t.PositionZ * t.scale;
  88.                 t.visible = true;
  89.             } else {
  90.                 t.visible = false;
  91.             }
  92.         }
  93.         private var cRot:Number = 0;
  94.         private function onEventHandler(eventObject:Event):void
  95.         {
  96.             var variation:Number = 0.04;
  97.             var ctx =  mouseX / 465;
  98.             var cty = mouseY / 465;
  99.             if ( ctx > 0.95 ) {
  100.                 ctx = 0.95;
  101.             } else if ( ctx < 0.05 ) {
  102.                 ctx = 0.05;
  103.             }
  104.             if ( cty > 0.95 ) {
  105.                 cty = 0.95;
  106.             } else if ( cty < 0.05 ) {
  107.                 cty = 0.05;
  108.             }
  109.             if ( ctx > cTra.redMultiplier ) {
  110.                 cTra.redMultiplier += variation;
  111.             } else {
  112.                 cTra.redMultiplier -= variation;
  113.             }
  114.             if ( cty > cTra.greenMultiplier ) {
  115.                 cTra.greenMultiplier += variation;
  116.             } else {
  117.                 cTra.greenMultiplier -= variation;
  118.             }
  119.             cTra.blueMultiplier = ( Math.sin(cRot) + 1 ) / 2 * 0.95;
  120.             cRot += 0.01;
  121.             var i:uint = bullets.length;
  122.             while (i--) {
  123.                 if ( bullets[ i ].PositionY < bullets[ i ].PurposeY ) {
  124.                     createParticle( bullets[ i ].PurposeX, bullets[ i ].PurposeY, bullets[ i ].PurposeZ );
  125.                     bullets[ i ].launchPoint();
  126.                     purposePoint( bullets[ i ] );
  127.                 } else {
  128.                     bullets[ i ].PositionX += bullets[ i ].vx;
  129.                     bullets[ i ].PositionY += bullets[ i ].vy;
  130.                     bullets[ i ].PositionZ += bullets[ i ].vz;
  131.                 }
  132.             }
  133.             _canvas.lock();
  134.             _canvas.applyFilter( _canvas, _rect, new Point(), new BlurFilter( 2.42.4 ) );
  135.             _canvas.colorTransform(_rect, cTra);
  136.             i = _particles.length;
  137.             while (i--) {
  138.                 var p:Particle = _particles[i];
  139.                 p.vy -= 0.06;
  140.                 p.vx *= 0.9;
  141.                 p.vy *= 0.9;
  142.                 p.vz *= 0.9;
  143.                 p.PositionX += p.vx;
  144.                 p.PositionY += p.vy;
  145.                 p.PositionZ += p.vz;
  146.                 WtoS( p );
  147.                 p.x = p.px;
  148.                 p.y = p.py;
  149.                 _canvas.setPixel32(p.x, p.y, p.c);
  150.                 if ( (p.x > stage.stageWidth || p.x < 0) || (p.y < 0 || p.y > stage.stageHeight) || Math.abs(p.vy) < -1.0 )
  151.                 {
  152.                     this._particles.splice(i, 1);
  153.                 }
  154.             }
  155.             _canvas.unlock();
  156.             _glow.draw(_canvas, new Matrix(0.25000.25));
  157.         }
  158.     }
  159. }
  160. import flash.display.Sprite;
  161. class bullet extends Sprite
  162. {
  163.     public var scale:Number;
  164.     public var PositionX:Number;
  165.     public var PositionY:Number;
  166.     public var PositionZ:Number;
  167.     public var PurposeX:Number;
  168.     public var PurposeY:Number;
  169.     public var PurposeZ:Number;
  170.     public var px:Number;
  171.     public var py:Number;
  172.     public var pz:Number;
  173.     public var vx:Number;
  174.     public var vy:Number;
  175.     public var vz:Number;
  176.     public function bullet()
  177.     {
  178.         launchPoint();
  179.     }
  180.     public function launchPoint():void {
  181.         PositionX =  0;
  182.         PositionY = 250
  183.         PositionZ = 200;
  184.     }
  185. }
  186. class Particle
  187. {
  188.     public var x:Number;
  189.     public var y:Number;
  190.     public var visible:Boolean;
  191.     public var scale:Number;
  192.     public var PositionX:Number;
  193.     public var PositionY:Number;
  194.     public var PositionZ:Number;
  195.     public var px:Number;
  196.     public var py:Number;
  197.     public var pz:Number;
  198.     public var vx:Number;
  199.     public var vy:Number;
  200.     public var vz:Number;
  201.     public var c:uint;
  202.     public function Particle()
  203.     {
  204.         this.x = 0;
  205.         this.y = 0;
  206.         this.vx = 0;
  207.         this.vy = 0;
  208.         this.vz = 0;
  209.         this.c = 0xffffffff;
  210.     }
  211. }
flash swf thumbnail play
出題者からのコメント
花火を真下から見る構図に斬新さを感じました。
また、夜空に打ちあがる花火でなく、「宇宙(そら)にある星(流星群)」のようにも見えて、弊社のお題と素敵にリンク☆ありがとうございました!
Comments from Sponsor
This is the new idea that fireworks will be seen from the bottom.
Not only driving fireworks in the sky at night, but also it looks like "meteoric swarm in the universe," that has close ties to this theme. Thank you very much!

Knightyd_niku

  1. // forked from checkmate's Creek challenge
  2. //途中
  3. package {
  4.     import flash.display.*;
  5.     import flash.events.*;
  6.     import flash.geom.*;
  7.     import flash.net.*;
  8.     import flash.utils.*;
  9.     import flash.system.*;
  10.     import com.flashdynamix.utils.*;
  11.     
  12.     [SWF(backgroundColor=0x000000, frameRate=60)]
  13.     public class Sponsor extends Sprite {
  14.         
  15.         private var _gradientMap:BitmapData; 
  16.         private var _timer:Timer;
  17.         private var _camera:Camera3D;
  18.         
  19.         private function setup():void{
  20.             _timer = new Timer( 8000 );
  21.             _timer.addEventListener( TimerEvent.TIMER, timerHadler );
  22.             _timer.start();
  23.             
  24.             _camera = new Camera3D();
  25.             
  26.             shotFirework();
  27.             
  28.             _loader = new Loader();
  29.             _loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadComplete );
  30.             _loader.load( new URLRequest("http://level0.kayac.com/space.jpg"), new LoaderContext(true) );
  31.         } 
  32.         private var _loader:Loader;
  33.         private var _background:DisplayObject;
  34.         private function onLoadComplete(e:Event):void {
  35.             _background = addChildAt( _loader.content, 0 ); 
  36.         }
  37.         
  38.         
  39.         private var _fireworks:Vector.<Firework> = new Vector.<Firework>();
  40.         private function shotFirework():void {
  41.             var fw:Firework =new Firework();
  42.             fw.shot( Math.random()*5 + 1 );
  43.             fw.x = Math.random() * 300 -150;
  44.             fw.y = -Math.random() * 100 -50;
  45.             fw.z = Math.random() * 300  -150;
  46.             _fireworks.push( fw );
  47.         }
  48.         
  49.         
  50.         private var _velocityWorldRot:Vector3D = new Vector3D();
  51.         private var _preMouse:Point = new Point();
  52.         private function updateCalcuration():void{
  53.             _velocityWorldRot.x += ( _preMouse.x - mouseX ) * 0.02;
  54.             _velocityWorldRot.x *= 0.90;
  55.             _velocityWorldRot.y += ( _preMouse.y- mouseY ) * 0.02;
  56.             _velocityWorldRot.y *= 0.90;
  57.             _preMouse.x = mouseX;
  58.             _preMouse.y = mouseY;
  59.             
  60.             _world.appendRotation( _velocityWorldRot.x, Vector3D.Y_AXIS );
  61.             _world.appendRotation( _velocityWorldRot.y, Vector3D.X_AXIS );
  62.             
  63.             for eachvar fw:Firework in _fireworks ) fw.updateCalcuration();
  64.         }
  65.         
  66.         private var _world:Matrix3D = new Matrix3D();
  67.         private function updateDrawing():void{
  68.             //_background.rotationX = 
  69.             
  70.             _canvas.colorTransform( _canvas.rect, CTF );
  71.             _canvas.lock();
  72.             for eachvar fw:Firework in _fireworks ) {
  73.                 fw.draw( _canvas, _world, _camera );
  74.             }
  75.             _canvas.unlock();
  76.         }
  77.         
  78.         private function timerHadler (e:Event):void{
  79.             var newFireworks:Vector.<Firework>= new Vector.<Firework>();
  80.             for eachvar fw:Firework in _fireworks ) {
  81.                 fw.cleanup();
  82.                 if( fw.isLiving )  newFireworks.push(fw);
  83.             }
  84.             _fireworks = newFireworks;
  85.             shotFirework();
  86.         }
  87.         
  88.         private const CTF:ColorTransform = new ColorTransform( 0.940.940.940.9 );
  89.         private var _canvas:BitmapData;
  90.         
  91.         private function init():void{
  92.             Firework.offset.x = stage.stageWidth*0.5>>0;
  93.             Firework.offset.y = stage.stageHeight*0.5>>0;
  94.             
  95.             _canvas  = new BitmapData( stage.stageWidth, stage.stageHeight, true0 );
  96.             addChild( new Bitmap(_canvas) );
  97.             
  98.             setup();
  99.             addEventListener( Event.ENTER_FRAME, enterFrame);
  100.             
  101.             SWFProfiler.init( this );
  102.         }
  103.         private function enterFrame( e:Event ):void {
  104.             updateCalcuration();
  105.             updateDrawing();
  106.         }
  107.         
  108.         
  109.         
  110.         
  111.         public function Sponsor() {
  112.             addEventListener( Event.ADDED_TO_STAGE, addToStage );
  113.         }
  114.         private function addToStage (e:Event):void {
  115.             init();
  116.         }
  117.     }
  118. }
  119. import flash.display.*;
  120. import flash.events.*;
  121. import flash.geom.*;
  122. import flash.net.*;
  123. import flash.utils.*;
  124. import flash.system.*;
  125. class Particle extends Vector3D {
  126.     public var life:int;
  127.     public var vx:Number;
  128.     public var vy:Number;
  129.     public var vz:Number;
  130.         public var rmd:Number = Math.random()*0.005-0.0025;
  131.     public function Particle( x:Number = 0, y:Number = 0, z:Number = 0, vx:Number = 0, vy:Number = 0, vz:Number = 0, life:int = 200 ) {
  132.         super( x, y, z );
  133.         this.vx = vx;
  134.         this.vy = vy;
  135.         this.vz = vz;
  136.         this.life = life;
  137.     }
  138. }
  139. class Camera3D extends Vector3D {
  140.     public var focus:int = 1000;
  141.     public function Camera3D( x:Number = 0, y:Number = 0, z:Number = 0 ) {
  142.         super( x, y, z );
  143.     }
  144. }
  145. class Firework extends Vector3D {
  146.     private static const PARTICLES_LENGTH:int = 600;
  147.     private static const COLORS:Array = [ 0xFFCCFF, 0xFF9999, 0xFFFF99, 0x99CCFF, 0xCCFF99 ];
  148.     
  149.     private static const FRICTION:Vector3D = new Vector3D ( 0.940.940.94 );
  150.     private static const GRAVITY:Vector3D = new Vector3D ( 00.0080 );
  151.     private static const WIND:Vector3D = new Vector3D ( 0.0010,0 );
  152.     
  153.     public static var offset:Point = new Point();
  154.     
  155.     private var _particles:Vector.<Particle> = new Vector.<Particle>();
  156.     private var _gradientMap:BitmapData;
  157.         
  158.     public function Firework() {
  159.         updateGradiate();
  160.     }
  161.     
  162.     public function draw( canvas:BitmapData,  world:Matrix3D, camera:Camera3D ):void {
  163.         for eachvar p:Particle in _particles ) {
  164.             if ( p.life <= 0 ) continue;
  165.             
  166.             var projected:Vector3D = Utils3D.projectVector( world, p .add( this ) );
  167.             
  168.             var persepective:Number = camera.focus / ( camera.focus + projected.z );
  169.             var px:Number = projected.x * persepective + offset.x;
  170.             var py:Number = projected.y * persepective + offset.y;
  171.             var a:uint = ( 255 * 5 / persepective ) << 24;
  172.             canvas.setPixel32( px, py, getColor(p.life) | a );
  173.         }    
  174.     }
  175.     
  176.     private function updateGradiate():void {
  177.         _gradientMap= new BitmapData(200,10true0);
  178.         var sp:Shape= new Shape();
  179.         var color:uint = COLORS[ Math.random()*COLORS.length>>0];
  180.         var mtx:Matrix = new Matrix();
  181.         mtx.createGradientBox(2000000);
  182.         sp.graphics.beginGradientFill( GradientType.LINEAR,
  183.             [ 0x333333, color, color, color*0.9>>0, 0x000000 ],
  184.             [ 11111 ],
  185.             [ 864102204255],
  186.             mtx,
  187.             InterpolationMethod.RGB
  188.         );
  189.         sp.graphics.drawRect( 0020010 );
  190.         sp.graphics.endFill();
  191.         _gradientMap.draw(sp);
  192.         sp = null;
  193.     }
  194.     
  195.     private function getColor(position:int):uint {
  196.         return _gradientMap.getPixel( position, 0 ) | 0x00000000;
  197.     }
  198.     
  199.     public function shot( radius:Number ):void {
  200.         var radian:Number = Math.PI*2;
  201.         
  202.         forvar i :int=0; i<PARTICLES_LENGTH; i++ ) {
  203.             var theta:Number = Math.random() *radian;
  204.             var phi:Number = Math.random() *radian;
  205.             var tx:Number = Math.sin(theta) * Math.sin(phi);
  206.             var ty:Number = Math.sin(theta) * Math.cos(phi);
  207.             var tz:Number = Math.cos(theta);
  208.             
  209.             var sl:Number = Math.random()*radius * 0.5;
  210.             var vl:Number = Math.random()*( 0.2 )*radius + 0.8 * radius;
  211.             
  212.             var particle :Particle= new Particle(
  213.                 tx*sl,
  214.                 ty*sl,
  215.                 tz*sl,
  216.                 tx*vl,
  217.                 ty*vl,
  218.                 tz*vl,
  219.                 100
  220.             );
  221.             _particles.push(particle);
  222.         }
  223.     }
  224.     public function get isLiving():Boolean {
  225.         return  _particles.length > 0;
  226.     }
  227.     public function updateCalcuration():void{
  228.         for eachvar p:Particle in _particles ) {
  229.             p.vx =  p.vx * FRICTION.x + WIND.x + GRAVITY.x + p.rmd;
  230.             p.vy =  p.vy * FRICTION.y + WIND.y + GRAVITY.y + p.rmd;
  231.             p.vz =  p.vz * FRICTION.z + WIND.z + GRAVITY.z + p.rmd;
  232.             p.x = p.x + p.vx;
  233.             p.y = p.y + p.vy;
  234.             p.z = p.z + p.vz;
  235.             p.life--;
  236.         }
  237.         _particles = _particles.sort( _sort );
  238.     }
  239.     private function _sort(a:Vector3D, b:Vector3D):Number { 
  240.         return a.z > b.z ? -1 : a.z < b.z ? 1 : 0;
  241.     }
  242.     
  243.     public function cleanup():void {
  244.         var newParticles:Vector.<Particle> = new Vector.<Particle>();
  245.         for eachvar p:Particle in _particles ) {
  246.             if( p.life > 0 ) newParticles.push(p);
  247.         }
  248.         _particles = newParticles;
  249.     }
  250. }
flash swf thumbnail play
出題者からのコメント
カーソルの動きにあわせた3D花火というアイディアがよかっただけに、まだ「作成途中?」ということが残念。完成品を見たかった作品です。
Comments from Sponsor
The idea which combined the movement cursors to 3D fireworks was great, but what a pity, it's still "in the process of making"
This is the work that we wanted to see the complete one.

ad