この度は、美しい花火、アイディア満載の花火、衝撃的な花火など、いろいろな花火のご投稿ありがとうございました!またそれぞれの作品に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!
-

- coppieee
書籍『Flash + After Effects』と魚沼産コシヒカリ (書籍提供:ボーンデジタル)
"Flash + After Effects"(a book written by Chris Jackson, 2009, presented by Born Digital, Inc.) and Koshihikari, Japanese top brand rice.
-

- sekiryou
「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)
-

- yd_niku
golla: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)
coppieee
- /**
- * たーまやー。
- * 正規表現に苦戦しながらも、twitterでヘルプを求めて出来上がった作品。
- * Twitterで打ち上げたいコメントを、
- * #hanabi [( ゚д゚ )]
- * のように #hanabi [コメント]って書けば打ち上げリストに追加されるよ!
- * []は必須だからちゃんと付けてね!
- *
- * Tweet hanabi!のボタンを押せばテンプレが表示される。
- *
- * 花火リスト
- * http://search.twitter.com/search?q=%23hanabi
- *
- * katan_t irgal_ Horiuchi_H katan_t repeatedly aibou nakawake seisuke uwitenpen beinteractive
- * に感謝!
- * @author coppieee
- */
- package {
- import com.bit101.components.PushButton;
- import flash.display.*;
- import flash.events.*;
- import flash.geom.*;
- import flash.net.*;
- import flash.text.engine.TextBlock;
- import flash.text.engine.TextElement;
- import flash.text.engine.TextLine;
- import flash.text.TextField;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFormat;
- import flash.utils.*;
- import flash.system.*;
- import com.flashdynamix.utils.*;
- [SWF(backgroundColor=0x000000, frameRate=60)]
- public class Sponsor extends Sprite {
- private var _particles:Vector.<Object>;
- private var _gradientMap:BitmapData;
- private var _timer:Timer;
- private static const PARTICLES_LENGTH:int = 1000;
- //private static const _texts:Array = ["( ゚д゚ )","\(^o^)/","(「・ω・)「",""];
- private var _texts:Array;
- private var _newestTexts:Array;
- private function setup():void {
- //Wonderfl.capture_delay(2);
- _gradientMap= new BitmapData(200,10, true, 0);
- //addChild( new Bitmap( _gradientMap) ); // for debug
- updateGradientFill();
- //shotFirework();
- shotAA();
- _timer = new Timer( 5000, 0 );
- _timer.addEventListener( TimerEvent.TIMER, timerHadler );
- _timer.start();
- _loader = new Loader();
- _loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadComplete );
- _loader.load( new URLRequest("http://level0.kayac.com/space.jpg"), new LoaderContext(true) );
- //var textLoader:URLLoader = new URLLoader(new URLRequest("http://search.twitter.com/search.atom?q=%23hanabi&rpp=100"));
- //textLoader.addEventListener(Event.COMPLETE, function(e:Event):void {
- //default xml namespace = new Namespace("http://www.w3.org/2005/Atom");
- //var htmlText:XML = XML(textLoader.data);
- //var title:XMLList = htmlText.entry.title;
- //var xs:Array = [];
- //for each(var c:XML in title)
- //{
- //xs.push.apply(null,scan(c.toString(),/\[(.+)\]/));
- //}
- //if (xs.length >= 1)
- //{
- //_texts = xs;
- //}
- //});
- var loadTexts:Function = function (rpp:int, arraySetter:Function):void {
- var textLoader:URLLoader = new URLLoader(new URLRequest("http://search.twitter.com/search.atom?q=%23hanabi&rpp=" + rpp));
- textLoader.addEventListener(Event.COMPLETE, function(e:Event):void {
- default xml namespace = new Namespace("http://www.w3.org/2005/Atom");
- var htmlText:XML = XML(textLoader.data);
- var title:XMLList = htmlText.entry.title;
- var xs:Array = [];
- for each(var c:XML in title)
- {
- xs.push.apply(null,scan(c.toString(),/\[(.+)\]/));
- }
- if (xs.length >= 1)
- {
- //_texts = xs;
- arraySetter(xs);
- }
- });
- }
- loadTexts(100, function(arr:Array):void { _texts = arr } );
- loadTexts(20, function(arr:Array):void { _newestTexts = arr } );
- var tweetButton:PushButton = new PushButton(this);
- tweetButton.label = "Tweet Hanabi!";
- tweetButton.alpha = 0.8;
- tweetButton.x = (465 - tweetButton.width) / 2;
- tweetButton.y = (465 - tweetButton.height);
- tweetButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
- navigateToURL(new URLRequest("http://twitter.com/home/?status="
- + escapeMultiByte("#hanabi [] http://bit.ly/AAHanabi")
- ));
- });
- }
- private var _loader:Loader;
- private function onLoadComplete(e:Event):void {
- addChildAt( _loader.content, 0 );
- }
- private function shotAA():void
- {
- var text:String = "(・ω・)";
- if (_texts != null && _newestTexts != null)
- {
- if (Math.random() > 0.5)
- {
- text = _texts[Math.floor(_texts.length * Math.random())];
- }else
- {
- text = _newestTexts[Math.floor(_newestTexts.length * Math.random())];
- }
- }
- _particles = new Vector.<Object>();
- var tf:TextField = new TextField();
- tf.autoSize = TextFieldAutoSize.LEFT;
- var format:TextFormat = new TextFormat();
- format.size = 20;
- tf.defaultTextFormat = format;
- tf.text = text;
- var b:BitmapData = new BitmapData(tf.width, tf.height, false);
- b.draw(tf);
- const offsetX:int = 0;
- const offsetY:int = - 45;
- const scale:Number = 20/b.width;
- for (var i:int = 0; i < b.width; i++ )
- {
- for (var j:int = 0; j < b.height; j++ )
- {
- if (b.getPixel(i, j) == 0xFFFFFF) { continue ; }
- var direction:Number = Math.random()*Math.PI*2;
- var tx:Number = Math.sin(direction);
- var ty:Number = Math.cos(direction);
- //var sl:Number = Math.random()* radius +2;
- var vl:Number = Math.random()/10;
- var p:Object = {
- x:_center.x,
- y:_center.y,
- vx:(i -b.width / 2) *scale + tx*vl,
- vy:(j -b.height / 2) *scale +ty*vl,
- life:Math.random()*30+170
- };
- _particles.push(p);
- }
- }
- b.dispose();
- }
- private static const FRICTION:Number = 0.96;
- private static const GRAVITY:Number = 0.006;
- private static const WIND:Point = new Point(0.001,0 );
- private function updateCalcuration():void{
- for each( var p:Object in _particles ) {
- p.vx = p.vx * FRICTION + WIND.x + Math.random()*0.01-.005;
- p.vy = p.vy * FRICTION + WIND.y + GRAVITY + Math.random()*0.01-.005;
- p.x = p.x + p.vx;
- p.y = p.y + p.vy;
- p.life--;
- }
- }
- private function updateDrawing():void{
- _canvas.colorTransform( _canvas.rect, CTF );
- _canvas.lock();
- for each( var p:Object in _particles ) {
- if( p.life <= 0 ) continue;
- _canvas.setPixel32( p.x, p.y, getColor(p.life) );
- }
- _canvas.unlock();
- }
- private function timerHadler (e:Event):void{
- updateGradientFill();
- _particles = null;
- //shotFirework();
- shotAA();
- }
- private function getColor(position:int):uint {
- return _gradientMap.getPixel( position, 0 ) | 0xFF000000;
- }
- private const CTF:ColorTransform = new ColorTransform( 0.94, 0.94, 0.94, 0.9 );
- private const COLORS:Array = [ 0xFFCCFF, 0xFF9999, 0xFFFF99, 0x99CCFF, 0xCCFF99 ];
- private function updateGradientFill():void {
- var sp:Shape= new Shape();
- var color:uint = COLORS[ Math.random()*COLORS.length>>0];
- var mtx:Matrix = new Matrix();
- mtx.createGradientBox(200, 0, 0, 0, 0);
- sp.graphics.beginGradientFill( GradientType.LINEAR,
- [ 0x333333, color, color, color*0.9>>0, 0x000000 ],
- [ 1, 1, 1, 1, 1 ],
- [ 8, 64, 102, 204, 255],
- mtx,
- InterpolationMethod.RGB
- );
- sp.graphics.drawRect( 0, 0, 200, 10 );
- sp.graphics.endFill();
- _gradientMap.draw(sp);
- sp = null;
- }
- private var _canvas:BitmapData;
- private var _center:Point;
- private function init():void{
- _center= new Point();
- _center.x = stage.stageWidth*0.5>>0;
- _center.y = stage.stageHeight*0.5>>0;
- _canvas = new BitmapData( stage.stageWidth, stage.stageHeight, true, 0 );
- addChild( new Bitmap(_canvas) );
- setup();
- addEventListener( Event.ENTER_FRAME, enterFrame);
- SWFProfiler.init( this );
- }
- private function enterFrame( e:Event ):void {
- updateCalcuration();
- updateDrawing();
- }
- public function Sponsor() {
- addEventListener( Event.ADDED_TO_STAGE, addToStage );
- }
- private function addToStage (e:Event):void {
- init();
- }
- }
- }
- /**
- * @see http://takumakei.blogspot.com/2009/05/actionscriptrubystringscan.html
- */
- //package com.blogspot.takumakei.utils
- //{
- //public
- function scan(str:String, re:RegExp):Array
- {
- if(!re.global){
- var flags:String = 'g';
- if(re.dotall)
- flags += 's';
- if(re.multiline)
- flags += 'm';
- if(re.ignoreCase)
- flags += 'i';
- if(re.extended)
- flags += 'x';
- re = new RegExp(re.source, flags);
- }
- var r:Array = [];
- var m:Array = re.exec(str);
- while(null != m){
- if(1 == m.length)
- r.push(m[0]);
- else
- r.push(m.slice(1, m.length));
- m = re.exec(str);
- }
- return r;
- }
- //}
- 出題者からのコメント
- 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.
sekiryou
- // forked from checkmate's Creek challenge
- package {
- import flash.display.MovieClip;
- import flash.events.Event;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.geom.Matrix;
- import flash.geom.Point;
- import flash.display.BlendMode;
- import flash.display.PixelSnapping;
- import flash.geom.Rectangle;
- import flash.geom.ColorTransform;
- import flash.filters.BlurFilter;
- [SWF(width = "465", height = "465", backgroundColor = "0x000000", frameRate = "30")]
- public class BeneathSpark extends MovieClip {
- private var _canvas:BitmapData;
- private var bmp:Bitmap;
- private var _particles:Array;
- private var _glow:BitmapData;
- private var _rect:Rectangle;
- private var cTra:ColorTransform;
- private var FocalLength:Number = 200;
- private var bullets:Array = [];
- private const bulletAmount:uint = 20;
- private var particles:Array = [];
- private const STAGE_WIDTH = stage.stageWidth;
- private const STAGE_HEIGHT = stage.stageHeight;
- private const STAGE_CENTER_X = stage.stageWidth / 2;
- private const STAGE_CENTER_Y = stage.stageHeight / 2;
- public function BeneathSpark()
- {
- init()
- }
- private function init():void
- {
- _particles = [];
- _canvas = new BitmapData (STAGE_WIDTH, STAGE_HEIGHT, true, 0xFFFFFF);
- bmp = new Bitmap (_canvas);
- addChild (bmp);
- _glow = new BitmapData( STAGE_WIDTH/4, STAGE_HEIGHT/4, false, 0x0);
- var bm:Bitmap = addChild(new Bitmap(_glow, PixelSnapping.NEVER, true)) as Bitmap;
- bm.scaleX = bm.scaleY = 4;
- bm.blendMode = BlendMode.ADD;
- _rect = new Rectangle(0, 0, STAGE_WIDTH, STAGE_HEIGHT);
- cTra = new ColorTransform( 0.95, 0.95, 0.95, 1.2 );
- for ( var i = 0; i < bulletAmount; i++ )
- {
- var p:bullet = new bullet();
- bullets.push( p );
- purposePoint( p );
- p.PositionY -= 280;
- }
- addEventListener(Event.ENTER_FRAME, onEventHandler);
- }
- private function createParticle( sx:Number, sy:Number, sz:Number ):void
- {
- var i:int = 120;
- while (i--) {
- var p:Particle = new Particle();
- p.PositionX = sx;
- p.PositionY = sy;
- p.PositionZ = sz;
- var radius:Number = Math.sqrt(Math.random()) * 1.3;
- var angle:Number = Math.random() * Math.PI * 2;
- var angle2:Number = Math.random() * Math.PI * 2;
- p.vx = Math.cos( angle ) * radius;
- p.vy = Math.sin( angle2 ) * radius;
- p.vz = Math.sin( angle ) * radius;
- _particles.push(p);
- }
- }
- private function purposePoint( t )
- {
- t.PurposeX = Math.random() * 120 -60;
- t.PurposeY = Math.random() * 40 -160
- t.PurposeZ = Math.random() * 120 -60;
- var rnd:Number = ( Math.random() * 2 + 2 ) / 400;
- t.vx = ( t.PurposeX - t.PositionX ) * rnd;
- t.vy = ( t.PurposeY - t.PositionY ) * rnd;
- t.vz = ( t.PurposeZ - t.PositionZ ) * rnd;
- }
- private function WtoS( t ):void
- {
- if ( t.PositionY > -FocalLength ) {
- t.scale = FocalLength / (FocalLength + t.PositionY);
- t.px = STAGE_CENTER_X + t.PositionX * t.scale;
- t.py = STAGE_CENTER_Y + t.PositionZ * t.scale;
- t.visible = true;
- } else {
- t.visible = false;
- }
- }
- private var cRot:Number = 0;
- private function onEventHandler(eventObject:Event):void
- {
- var variation:Number = 0.04;
- var ctx = mouseX / 465;
- var cty = mouseY / 465;
- if ( ctx > 0.95 ) {
- ctx = 0.95;
- } else if ( ctx < 0.05 ) {
- ctx = 0.05;
- }
- if ( cty > 0.95 ) {
- cty = 0.95;
- } else if ( cty < 0.05 ) {
- cty = 0.05;
- }
- if ( ctx > cTra.redMultiplier ) {
- cTra.redMultiplier += variation;
- } else {
- cTra.redMultiplier -= variation;
- }
- if ( cty > cTra.greenMultiplier ) {
- cTra.greenMultiplier += variation;
- } else {
- cTra.greenMultiplier -= variation;
- }
- cTra.blueMultiplier = ( Math.sin(cRot) + 1 ) / 2 * 0.95;
- cRot += 0.01;
- var i:uint = bullets.length;
- while (i--) {
- if ( bullets[ i ].PositionY < bullets[ i ].PurposeY ) {
- createParticle( bullets[ i ].PurposeX, bullets[ i ].PurposeY, bullets[ i ].PurposeZ );
- bullets[ i ].launchPoint();
- purposePoint( bullets[ i ] );
- } else {
- bullets[ i ].PositionX += bullets[ i ].vx;
- bullets[ i ].PositionY += bullets[ i ].vy;
- bullets[ i ].PositionZ += bullets[ i ].vz;
- }
- }
- _canvas.lock();
- _canvas.applyFilter( _canvas, _rect, new Point(), new BlurFilter( 2.4, 2.4 ) );
- _canvas.colorTransform(_rect, cTra);
- i = _particles.length;
- while (i--) {
- var p:Particle = _particles[i];
- p.vy -= 0.06;
- p.vx *= 0.9;
- p.vy *= 0.9;
- p.vz *= 0.9;
- p.PositionX += p.vx;
- p.PositionY += p.vy;
- p.PositionZ += p.vz;
- WtoS( p );
- p.x = p.px;
- p.y = p.py;
- _canvas.setPixel32(p.x, p.y, p.c);
- if ( (p.x > stage.stageWidth || p.x < 0) || (p.y < 0 || p.y > stage.stageHeight) || Math.abs(p.vy) < -1.0 )
- {
- this._particles.splice(i, 1);
- }
- }
- _canvas.unlock();
- _glow.draw(_canvas, new Matrix(0.25, 0, 0, 0.25));
- }
- }
- }
- import flash.display.Sprite;
- class bullet extends Sprite
- {
- public var scale:Number;
- public var PositionX:Number;
- public var PositionY:Number;
- public var PositionZ:Number;
- public var PurposeX:Number;
- public var PurposeY:Number;
- public var PurposeZ:Number;
- public var px:Number;
- public var py:Number;
- public var pz:Number;
- public var vx:Number;
- public var vy:Number;
- public var vz:Number;
- public function bullet()
- {
- launchPoint();
- }
- public function launchPoint():void {
- PositionX = 0;
- PositionY = 250
- PositionZ = 200;
- }
- }
- class Particle
- {
- public var x:Number;
- public var y:Number;
- public var visible:Boolean;
- public var scale:Number;
- public var PositionX:Number;
- public var PositionY:Number;
- public var PositionZ:Number;
- public var px:Number;
- public var py:Number;
- public var pz:Number;
- public var vx:Number;
- public var vy:Number;
- public var vz:Number;
- public var c:uint;
- public function Particle()
- {
- this.x = 0;
- this.y = 0;
- this.vx = 0;
- this.vy = 0;
- this.vz = 0;
- this.c = 0xffffffff;
- }
- }
- 出題者からのコメント
- 花火を真下から見る構図に斬新さを感じました。
また、夜空に打ちあがる花火でなく、「宇宙(そら)にある星(流星群)」のようにも見えて、弊社のお題と素敵にリンク☆ありがとうございました!
- 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!
yd_niku
- // forked from checkmate's Creek challenge
- //途中
- package {
- import flash.display.*;
- import flash.events.*;
- import flash.geom.*;
- import flash.net.*;
- import flash.utils.*;
- import flash.system.*;
- import com.flashdynamix.utils.*;
- [SWF(backgroundColor=0x000000, frameRate=60)]
- public class Sponsor extends Sprite {
- private var _gradientMap:BitmapData;
- private var _timer:Timer;
- private var _camera:Camera3D;
- private function setup():void{
- _timer = new Timer( 800, 0 );
- _timer.addEventListener( TimerEvent.TIMER, timerHadler );
- _timer.start();
- _camera = new Camera3D();
- shotFirework();
- _loader = new Loader();
- _loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadComplete );
- _loader.load( new URLRequest("http://level0.kayac.com/space.jpg"), new LoaderContext(true) );
- }
- private var _loader:Loader;
- private var _background:DisplayObject;
- private function onLoadComplete(e:Event):void {
- _background = addChildAt( _loader.content, 0 );
- }
- private var _fireworks:Vector.<Firework> = new Vector.<Firework>();
- private function shotFirework():void {
- var fw:Firework =new Firework();
- fw.shot( Math.random()*5 + 1 );
- fw.x = Math.random() * 300 -150;
- fw.y = -Math.random() * 100 -50;
- fw.z = Math.random() * 300 -150;
- _fireworks.push( fw );
- }
- private var _velocityWorldRot:Vector3D = new Vector3D();
- private var _preMouse:Point = new Point();
- private function updateCalcuration():void{
- _velocityWorldRot.x += ( _preMouse.x - mouseX ) * 0.02;
- _velocityWorldRot.x *= 0.90;
- _velocityWorldRot.y += ( _preMouse.y- mouseY ) * 0.02;
- _velocityWorldRot.y *= 0.90;
- _preMouse.x = mouseX;
- _preMouse.y = mouseY;
- _world.appendRotation( _velocityWorldRot.x, Vector3D.Y_AXIS );
- _world.appendRotation( _velocityWorldRot.y, Vector3D.X_AXIS );
- for each( var fw:Firework in _fireworks ) fw.updateCalcuration();
- }
- private var _world:Matrix3D = new Matrix3D();
- private function updateDrawing():void{
- //_background.rotationX =
- _canvas.colorTransform( _canvas.rect, CTF );
- _canvas.lock();
- for each( var fw:Firework in _fireworks ) {
- fw.draw( _canvas, _world, _camera );
- }
- _canvas.unlock();
- }
- private function timerHadler (e:Event):void{
- var newFireworks:Vector.<Firework>= new Vector.<Firework>();
- for each( var fw:Firework in _fireworks ) {
- fw.cleanup();
- if( fw.isLiving ) newFireworks.push(fw);
- }
- _fireworks = newFireworks;
- shotFirework();
- }
- private const CTF:ColorTransform = new ColorTransform( 0.94, 0.94, 0.94, 0.9 );
- private var _canvas:BitmapData;
- private function init():void{
- Firework.offset.x = stage.stageWidth*0.5>>0;
- Firework.offset.y = stage.stageHeight*0.5>>0;
- _canvas = new BitmapData( stage.stageWidth, stage.stageHeight, true, 0 );
- addChild( new Bitmap(_canvas) );
- setup();
- addEventListener( Event.ENTER_FRAME, enterFrame);
- SWFProfiler.init( this );
- }
- private function enterFrame( e:Event ):void {
- updateCalcuration();
- updateDrawing();
- }
- public function Sponsor() {
- addEventListener( Event.ADDED_TO_STAGE, addToStage );
- }
- private function addToStage (e:Event):void {
- init();
- }
- }
- }
- import flash.display.*;
- import flash.events.*;
- import flash.geom.*;
- import flash.net.*;
- import flash.utils.*;
- import flash.system.*;
- class Particle extends Vector3D {
- public var life:int;
- public var vx:Number;
- public var vy:Number;
- public var vz:Number;
- public var rmd:Number = Math.random()*0.005-0.0025;
- public function Particle( x:Number = 0, y:Number = 0, z:Number = 0, vx:Number = 0, vy:Number = 0, vz:Number = 0, life:int = 200 ) {
- super( x, y, z );
- this.vx = vx;
- this.vy = vy;
- this.vz = vz;
- this.life = life;
- }
- }
- class Camera3D extends Vector3D {
- public var focus:int = 1000;
- public function Camera3D( x:Number = 0, y:Number = 0, z:Number = 0 ) {
- super( x, y, z );
- }
- }
- class Firework extends Vector3D {
- private static const PARTICLES_LENGTH:int = 600;
- private static const COLORS:Array = [ 0xFFCCFF, 0xFF9999, 0xFFFF99, 0x99CCFF, 0xCCFF99 ];
- private static const FRICTION:Vector3D = new Vector3D ( 0.94, 0.94, 0.94 );
- private static const GRAVITY:Vector3D = new Vector3D ( 0, 0.008, 0 );
- private static const WIND:Vector3D = new Vector3D ( 0.001, 0,0 );
- public static var offset:Point = new Point();
- private var _particles:Vector.<Particle> = new Vector.<Particle>();
- private var _gradientMap:BitmapData;
- public function Firework() {
- updateGradiate();
- }
- public function draw( canvas:BitmapData, world:Matrix3D, camera:Camera3D ):void {
- for each( var p:Particle in _particles ) {
- if ( p.life <= 0 ) continue;
- var projected:Vector3D = Utils3D.projectVector( world, p .add( this ) );
- var persepective:Number = camera.focus / ( camera.focus + projected.z );
- var px:Number = projected.x * persepective + offset.x;
- var py:Number = projected.y * persepective + offset.y;
- var a:uint = ( 255 * 5 / persepective ) << 24;
- canvas.setPixel32( px, py, getColor(p.life) | a );
- }
- }
- private function updateGradiate():void {
- _gradientMap= new BitmapData(200,10, true, 0);
- var sp:Shape= new Shape();
- var color:uint = COLORS[ Math.random()*COLORS.length>>0];
- var mtx:Matrix = new Matrix();
- mtx.createGradientBox(200, 0, 0, 0, 0);
- sp.graphics.beginGradientFill( GradientType.LINEAR,
- [ 0x333333, color, color, color*0.9>>0, 0x000000 ],
- [ 1, 1, 1, 1, 1 ],
- [ 8, 64, 102, 204, 255],
- mtx,
- InterpolationMethod.RGB
- );
- sp.graphics.drawRect( 0, 0, 200, 10 );
- sp.graphics.endFill();
- _gradientMap.draw(sp);
- sp = null;
- }
- private function getColor(position:int):uint {
- return _gradientMap.getPixel( position, 0 ) | 0x00000000;
- }
- public function shot( radius:Number ):void {
- var radian:Number = Math.PI*2;
- for( var i :int=0; i<PARTICLES_LENGTH; i++ ) {
- var theta:Number = Math.random() *radian;
- var phi:Number = Math.random() *radian;
- var tx:Number = Math.sin(theta) * Math.sin(phi);
- var ty:Number = Math.sin(theta) * Math.cos(phi);
- var tz:Number = Math.cos(theta);
- var sl:Number = Math.random()*radius * 0.5;
- var vl:Number = Math.random()*( 0.2 )*radius + 0.8 * radius;
- var particle :Particle= new Particle(
- tx*sl,
- ty*sl,
- tz*sl,
- tx*vl,
- ty*vl,
- tz*vl,
- 100
- );
- _particles.push(particle);
- }
- }
- public function get isLiving():Boolean {
- return _particles.length > 0;
- }
- public function updateCalcuration():void{
- for each( var p:Particle in _particles ) {
- p.vx = p.vx * FRICTION.x + WIND.x + GRAVITY.x + p.rmd;
- p.vy = p.vy * FRICTION.y + WIND.y + GRAVITY.y + p.rmd;
- p.vz = p.vz * FRICTION.z + WIND.z + GRAVITY.z + p.rmd;
- p.x = p.x + p.vx;
- p.y = p.y + p.vy;
- p.z = p.z + p.vz;
- p.life--;
- }
- _particles = _particles.sort( _sort );
- }
- private function _sort(a:Vector3D, b:Vector3D):Number {
- return a.z > b.z ? -1 : a.z < b.z ? 1 : 0;
- }
- public function cleanup():void {
- var newParticles:Vector.<Particle> = new Vector.<Particle>();
- for each( var p:Particle in _particles ) {
- if( p.life > 0 ) newParticles.push(p);
- }
- _particles = newParticles;
- }
- }
- 出題者からのコメント
- カーソルの動きにあわせた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.


