FORKED

forked from: FITC: Cool Japan side A / Particle sample of SMOKE without blur effect forked from: forked from: FITC: Cool Japan side A / Particle sample of SMOKE without blur effect [diff(1)]

  1. // forked from fladdict's forked from: FITC: Cool Japan side A / Particle sample of SMOKE without blur effect
  2. // forked from fladdict's FITC: Cool Japan side A / Particle sample of SMOKE
  3. /**
  4. * Sample code for FITC
  5. * Smoke particle effect
  6. */
  7. package {
  8.     import flash.display.Sprite;    
  9.     import flash.display.Bitmap;
  10.     import flash.display.BitmapData;
  11.     import flash.display.BlendMode;
  12.     import flash.events.Event;
  13.     import flash.filters.BlurFilter;
  14.     import flash.geom.ColorTransform;
  15.     import flash.geom.Matrix;
  16.     import flash.geom.Point;
  17.     import flash.utils.ByteArray;
  18.     
  19.     public class FlashTest extends Sprite {
  20.        //View
  21.         protected var canvas:BitmapData;
  22.         protected var canvasBitmap:Bitmap;
  23.         
  24.         //BitmapData that contains the actual froce that is applied to particles.
  25.         protected var forceMap:BitmapData;
  26.         
  27.         //BitmapData that contains the force of the storm.
  28.         protected var stormMap0:BitmapData;
  29.         protected var stormMap1:BitmapData;
  30.         
  31.         //BitmapData that contains the mouse repulsion force of the stage.
  32.         protected var repulsionMap:BitmapData;
  33.         protected var repulsionHistoryMap:BitmapData;
  34.         protected var repulsionFadeMap:BitmapData;
  35.         
  36.         //the number of particles. 5000-200000
  37.         protected var particleNum:int = 10000;
  38.         protected var particles:Vector.<Particle>
  39.         
  40.         //
  41.         protected var stormScaleRatioX:Number;
  42.         protected var stormScaleRatioY:Number;
  43.         protected var stormCycle:Number = 0;
  44.         
  45.         //color transform that guradually changes canvas.
  46.         protected var fadeCanvasColt:ColorTransform;
  47.         protected var canvasBlurFilter:BlurFilter;
  48.         
  49.         //temporaly variables
  50.         protected var tempColt:ColorTransform = new ColorTransform();
  51.         protected var tempPt:Point = new Point();
  52.         protected var tempMat:Matrix = new Matrix();
  53.         
  54.         public function FlashTest() {
  55.             init();
  56.             reset();
  57.         }
  58.         
  59.         protected function init():void
  60.         {
  61.             //build View
  62.             canvasBitmap = new Bitmap(null"auto"false);
  63.             // because canvas is 25% size of screen, we make view 400% bigger.
  64.             canvasBitmap.scaleX = 4;
  65.             canvasBitmap.scaleY = 4;
  66.             addChild(canvasBitmap);
  67.             
  68.             //initialize the map that contains force of the storm;
  69.             stormMap0 = new BitmapData(256,256,false,0x000000);
  70.             stormMap0.perlinNoise(128,128,3,Math.random()*100,false,true,3,false);
  71.             stormMap1 = new BitmapData(256,256,false,0x000000);
  72.             stormMap1.perlinNoise(128,128,3,Math.random()*100,false,true,3,false);
  73.             
  74.             //
  75.             forceMap = new BitmapData(256,256,false,0x000000);
  76.             
  77.             //initialize repulsionMap
  78.             repulsionHistoryMap = new BitmapData(256,256,false,0x000000);
  79.             repulsionFadeMap = new BitmapData(256,256,true,0x20808000);
  80.             repulsionMap = new BitmapData(256,256,false,0);
  81.             
  82.             /**
  83.             * First we preculculate the repulsion force field that mouse cursor generates as a bitmapdata. 
  84.             * Red channel of bitmap data contains horizontal force.
  85.             * Green channel of bitmap data contains vertical force. 
  86.             */
  87.             var dx:int, dy:int;
  88.             var dist:Number, fx:Number, fy:Number;
  89.             var col:int;
  90.             for(var yy:int=0; yy<256; yy++)
  91.             {
  92.                 for(var xx:int=0; xx<256; xx++){
  93.                     dx = xx-128;
  94.                     dy = yy-128;
  95.                     dist = Math.sqrt(dx*dx+dy*dy);
  96.                     if(dist<1){
  97.                         fx = 0;
  98.                         fy = 0;
  99.                     }else{
  100.                         fx = dx / dist / dist / dist * 50000;
  101.                         fy = dy / dist / dist / dist * 50000;
  102.                     }
  103.                     fx = (fx<-128)? -128 : (fx>127)? 127 : fx;
  104.                     fy = (fy<-128)? -128 : (fy>127)? 127 : fy;
  105.                     fx += 128;
  106.                     fy += 128;
  107.                     col = (fx<<16) + (fy<<8)
  108.                     repulsionMap.setPixel(xx,yy,col);
  109.                 }
  110.             }
  111.             //You can see 
  112.             canvasBitmap.bitmapData = repulsionMap;
  113.             
  114.             //initialize particle
  115.             particles = new Vector.<Particle>(particleNum);
  116.             
  117.             var particle:Particle;
  118.             var rr:int;
  119.             for(var i:int=0; i<particleNum; i++)
  120.             {
  121.                 particle = new Particle();
  122.                 particle.x = Math.random() * stage.stageWidth >> 2;
  123.                 particle.y = Math.random() * stage.stageHeight >> 2;
  124.                 
  125.                 //Customize the range of the particle color according to the amount of the particle and stage size.
  126.                 particle.r = particle.g = particle.b = Math.min(Math.random()*8+4,255);  
  127.                 
  128.                 //Customize the rage of the scaleFactor according to the amount of the particle and stage size.
  129.                 particle.scaleFactor = (Math.random()*0.1 + 0.95) * 0.003;
  130.                 particles[i] = particle;
  131.             }
  132.             
  133.             fadeCanvasColt = new ColorTransform(1,1,1,1,-2,-1,-1,0);
  134.             canvasBlurFilter = new BlurFilter(2,2,3);
  135.             
  136.             //set event listeners
  137.             stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  138.             stage.addEventListener(Event.RESIZE, resizeHandler);
  139.         }
  140.         
  141.         /**
  142.         *
  143.         * Called when you need reset the view. E.G. resizing screen.
  144.         */
  145.         protected function reset():void
  146.         {
  147.             if(canvas)
  148.                 canvas.dispose();
  149.                 
  150.             //build view, to optimize we use 25% size BitmapData of actual screensize.
  151.             canvas = new BitmapData((stage.stageWidth>>2)+1, (stage.stageHeight>>2)+1false, 0x000000);
  152.             canvasBitmap.bitmapData = canvas;
  153.             
  154.             //precalculate ratio that converts screen coordinate to stomMapBitmap coodinate;
  155.             stormScaleRatioX = 1 / (stage.stageWidth>>2)*255;
  156.             stormScaleRatioY = 1 / (stage.stageHeight>>2)*255;
  157.             
  158.            //canvasBitmap.bitmapData = stormMap1;  //if you want to see stormMap;
  159.            //canvasBitmap.bitmapData = repulsionHistoryMap;
  160.            //canvasBitmap.bitmapData = forceMap; //if you want to see forceMap;
  161.            
  162.            //canvasBitmap.scaleX = 1;
  163.            //canvasBitmap.scaleY = 1;
  164.         }
  165.         
  166.         
  167.         //We rebuild screen when swf is reseized.
  168.         //It is not required if you only run it on wonderfl.
  169.         protected function resizeHandler(e:Event):void
  170.         {
  171.             reset();
  172.         }
  173.         
  174.         //Update storm and particle every frame.
  175.         protected function enterFrameHandler(e:Event):void
  176.         { 
  177.            updateStormMap();
  178.            updateRepulsionMap();
  179.            updateForceMap();
  180.            updateParticles();
  181.         }
  182.         
  183.         /**
  184.         * We calculate current forcefielde's state by blending two stormMap.
  185.         * Therefore force field gradually changes every frame.
  186.         */
  187.         protected function updateStormMap():void
  188.         {
  189.             stormCycle++;
  190.             if(stormCycle == 180){
  191.                 stormMap0.perlinNoise(256,256,3,Math.random()*100,false,true,3,false);
  192.             }else if(stormCycle==360){
  193.                 stormMap1.perlinNoise(256,256,3,Math.random()*100,false,true,3,false);
  194.                 stormCycle = 0;
  195.             }
  196.         }
  197.         
  198.         /**
  199.         * We update repulsionMap according to the current mouse position.
  200.         */
  201.         protected function updateRepulsionMap():void
  202.         {
  203.             tempMat.a = 1;
  204.             tempMat.b = 0;
  205.             tempMat.c = 0;
  206.             tempMat.d = 1;
  207.             tempMat.tx = 0;
  208.             tempMat.ty = 0;
  209.             
  210.             repulsionHistoryMap.draw(repulsionFadeMap, tempMat);
  211.             
  212.             tempMat.translate(-128,-128);
  213.             tempMat.translate(mouseX, mouseY);
  214.             tempMat.scale(1/stormScaleRatioX, 1/stormScaleRatioY);
  215.             repulsionHistoryMap.draw(repulsionMap, tempMat, null, BlendMode.HARDLIGHT);
  216.         }
  217.         
  218.         protected function updateForceMap():void
  219.         {
  220.             //generate current force fieldes state with blending two stormMaps.
  221.             forceMap.copyPixels(stormMap1, stormMap0.rect, tempPt);
  222.             tempColt.alphaMultiplier = Math.cos(stormCycle*Math.PI/180)*0.5+0.5;
  223.             forceMap.draw(stormMap0, null, tempColt);
  224.             
  225.             //add mouse repulsion force
  226.             forceMap.draw(repulsionHistoryMap,null,null,BlendMode.HARDLIGHT);
  227.             forceMap.draw(repulsionHistoryMap,null,null,BlendMode.HARDLIGHT);
  228.         }
  229.         
  230.         protected function updateParticles():void
  231.         {
  232.             var forceBytes:ByteArray = forceMap.getPixels(forceMap.rect);
  233.             
  234.             var stageW:int = canvas.width;
  235.             var stageH:int = canvas.height;
  236.             var loopW:int = stageW-1;
  237.             var loopH:int = stageH-1;
  238.             var byteIndex:int;
  239.             
  240.             canvas.lock();
  241.             canvas.colorTransform(canvas.rect, fadeCanvasColt);
  242.             
  243.             //Update Paritcle position and draw.
  244.             var col:int, r:int, g:int, b:int;
  245.             for(var i:int=0; i<particleNum; i++)
  246.             {
  247.                 var prt:Particle = particles[i];
  248.                 byteIndex = (int(prt.y*stormScaleRatioY)*256 + int(prt.x*stormScaleRatioX))<<2;
  249.                 prt.vx = prt.vx * 0.96 + (forceBytes[byteIndex+1]-128)*prt.scaleFactor;
  250.                 prt.vy = prt.vy * 0.96 + (forceBytes[byteIndex+2]-128)*prt.scaleFactor;
  251.                 prt.x += prt.vx;
  252.                 prt.y += prt.vy;
  253.                 if(prt.x<0){
  254.                     prt.x = loopW;
  255.                 }else if(prt.x > loopW){
  256.                     prt.x = 1;
  257.                 }
  258.                 if(prt.y<0){
  259.                     prt.y = loopH;
  260.                 }else if(prt.y > loopH){
  261.                     prt.y = 1;
  262.                 }
  263.                 
  264.                 //Self implimentation of addtive color blend mode.
  265.                 //Because there is too many particle, blending particle with low brightness color is much effective.
  266.                 col = canvas.getPixel(int(prt.x), int(prt.y));
  267.                 r = (col>>16&0xff) + prt.r;
  268.                 g = (col>>8&0xff) + prt.g;
  269.                 b = (col&0xff) + prt.b;
  270.                 r = (r<0xff)? r : 0xff;
  271.                 g = (g<0xff)? g : 0xff;
  272.                 b = (b<0xff)? b : 0xff;
  273.                 canvas.setPixel(int(prt.x), int(prt.y), (r<<16)|(g<<8)|b);
  274.             }
  275.             canvas.unlock();
  276.         }
  277.     }
  278.     
  279. }
  280. class Particle
  281. {
  282.     //particle position
  283.     public var x:Number = 0;
  284.     public var y:Number = 0;
  285.     public var vx:Number = 0;
  286.     public var vy:Number = 0;
  287.     
  288.     //particle color
  289.     public var r:int;
  290.     public var g:int;
  291.     public var b:int;
  292.     
  293.     //scale factor that affects the force applied to the particle.
  294.     public var scaleFactor:Number;
  295. }
noswf

forked from: FITC: Cool Japan side A / Particle sample of SMOKE without blur effect forked from: forked from: FITC: Cool Japan side A / Particle sample of SMOKE without blur effect [diff(1)]

  1. // forked from fladdict's forked from: FITC: Cool Japan side A / Particle sample of SMOKE without blur effect
  2. // forked from fladdict's FITC: Cool Japan side A / Particle sample of SMOKE
  3. /**
  4. * Sample code for FITC
  5. * Smoke particle effect
  6. */
  7. package {
  8.     import flash.display.Sprite;    
  9.     import flash.display.Bitmap;
  10.     import flash.display.BitmapData;
  11.     import flash.display.BlendMode;
  12.     import flash.events.Event;
  13.     import flash.filters.BlurFilter;
  14.     import flash.geom.ColorTransform;
  15.     import flash.geom.Matrix;
  16.     import flash.geom.Point;
  17.     import flash.utils.ByteArray;
  18.     
  19.     public class FlashTest extends Sprite {
  20.        //View
  21.         protected var canvas:BitmapData;
  22.         protected var canvasBitmap:Bitmap;
  23.         
  24.         //BitmapData that contains the actual froce that is applied to particles.
  25.         protected var forceMap:BitmapData;
  26.         
  27.         //BitmapData that contains the force of the storm.
  28.         protected var stormMap0:BitmapData;
  29.         protected var stormMap1:BitmapData;
  30.         
  31.         //BitmapData that contains the mouse repulsion force of the stage.
  32.         protected var repulsionMap:BitmapData;
  33.         protected var repulsionHistoryMap:BitmapData;
  34.         protected var repulsionFadeMap:BitmapData;
  35.         
  36.         //the number of particles. 5000-200000
  37.         protected var particleNum:int = 10000;
  38.         protected var particles:Vector.<Particle>
  39.         
  40.         //
  41.         protected var stormScaleRatioX:Number;
  42.         protected var stormScaleRatioY:Number;
  43.         protected var stormCycle:Number = 0;
  44.         
  45.         //color transform that guradually changes canvas.
  46.         protected var fadeCanvasColt:ColorTransform;
  47.         protected var canvasBlurFilter:BlurFilter;
  48.         
  49.         //temporaly variables
  50.         protected var tempColt:ColorTransform = new ColorTransform();
  51.         protected var tempPt:Point = new Point();
  52.         protected var tempMat:Matrix = new Matrix();
  53.         
  54.         public function FlashTest() {
  55.             init();
  56.             reset();
  57.         }
  58.         
  59.         protected function init():void
  60.         {
  61.             //build View
  62.             canvasBitmap = new Bitmap(null"auto"false);
  63.             // because canvas is 25% size of screen, we make view 400% bigger.
  64.             canvasBitmap.scaleX = 4;
  65.             canvasBitmap.scaleY = 4;
  66.             addChild(canvasBitmap);
  67.             
  68.             //initialize the map that contains force of the storm;
  69.             stormMap0 = new BitmapData(256,256,false,0x000000);
  70.             stormMap0.perlinNoise(128,128,3,Math.random()*100,false,true,3,false);
  71.             stormMap1 = new BitmapData(256,256,false,0x000000);
  72.             stormMap1.perlinNoise(128,128,3,Math.random()*100,false,true,3,false);
  73.             
  74.             //
  75.             forceMap = new BitmapData(256,256,false,0x000000);
  76.             
  77.             //initialize repulsionMap
  78.             repulsionHistoryMap = new BitmapData(256,256,false,0x000000);
  79.             repulsionFadeMap = new BitmapData(256,256,true,0x20808000);
  80.             repulsionMap = new BitmapData(256,256,false,0);
  81.             
  82.             /**
  83.             * First we preculculate the repulsion force field that mouse cursor generates as a bitmapdata. 
  84.             * Red channel of bitmap data contains horizontal force.
  85.             * Green channel of bitmap data contains vertical force. 
  86.             */
  87.             var dx:int, dy:int;
  88.             var dist:Number, fx:Number, fy:Number;
  89.             var col:int;
  90.             for(var yy:int=0; yy<256; yy++)
  91.             {
  92.                 for(var xx:int=0; xx<256; xx++){
  93.                     dx = xx-128;
  94.                     dy = yy-128;
  95.                     dist = Math.sqrt(dx*dx+dy*dy);
  96.                     if(dist<1){
  97.                         fx = 0;
  98.                         fy = 0;
  99.                     }else{
  100.                         fx = dx / dist / dist / dist * 50000;
  101.                         fy = dy / dist / dist / dist * 50000;
  102.                     }
  103.                     fx = (fx<-128)? -128 : (fx>127)? 127 : fx;
  104.                     fy = (fy<-128)? -128 : (fy>127)? 127 : fy;
  105.                     fx += 128;
  106.                     fy += 128;
  107.                     col = (fx<<16) + (fy<<8)
  108.                     repulsionMap.setPixel(xx,yy,col);
  109.                 }
  110.             }
  111.             //You can see 
  112.             canvasBitmap.bitmapData = repulsionMap;
  113.             
  114.             //initialize particle
  115.             particles = new Vector.<Particle>(particleNum);
  116.             
  117.             var particle:Particle;
  118.             var rr:int;
  119.             for(var i:int=0; i<particleNum; i++)
  120.             {
  121.                 particle = new Particle();
  122.                 particle.x = Math.random() * stage.stageWidth >> 2;
  123.                 particle.y = Math.random() * stage.stageHeight >> 2;
  124.                 
  125.                 //Customize the range of the particle color according to the amount of the particle and stage size.
  126.                 particle.r = particle.g = particle.b = Math.min(Math.random()*8+4,255);  
  127.                 
  128.                 //Customize the rage of the scaleFactor according to the amount of the particle and stage size.
  129.                 particle.scaleFactor = (Math.random()*0.1 + 0.95) * 0.003;
  130.                 particles[i] = particle;
  131.             }
  132.             
  133.             fadeCanvasColt = new ColorTransform(1,1,1,1,-2,-1,-1,0);
  134.             canvasBlurFilter = new BlurFilter(2,2,3);
  135.             
  136.             //set event listeners
  137.             stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  138.             stage.addEventListener(Event.RESIZE, resizeHandler);
  139.         }
  140.         
  141.         /**
  142.         *
  143.         * Called when you need reset the view. E.G. resizing screen.
  144.         */
  145.         protected function reset():void
  146.         {
  147.             if(canvas)
  148.                 canvas.dispose();
  149.                 
  150.             //build view, to optimize we use 25% size BitmapData of actual screensize.
  151.             canvas = new BitmapData((stage.stageWidth>>2)+1, (stage.stageHeight>>2)+1false, 0x000000);
  152.             canvasBitmap.bitmapData = canvas;
  153.             
  154.             //precalculate ratio that converts screen coordinate to stomMapBitmap coodinate;
  155.             stormScaleRatioX = 1 / (stage.stageWidth>>2)*255;
  156.             stormScaleRatioY = 1 / (stage.stageHeight>>2)*255;
  157.             
  158.            //canvasBitmap.bitmapData = stormMap1;  //if you want to see stormMap;
  159.            //canvasBitmap.bitmapData = repulsionHistoryMap;
  160.            //canvasBitmap.bitmapData = forceMap; //if you want to see forceMap;
  161.            
  162.            //canvasBitmap.scaleX = 1;
  163.            //canvasBitmap.scaleY = 1;
  164.         }
  165.         
  166.         
  167.         //We rebuild screen when swf is reseized.
  168.         //It is not required if you only run it on wonderfl.
  169.         protected function resizeHandler(e:Event):void
  170.         {
  171.             reset();
  172.         }
  173.         
  174.         //Update storm and particle every frame.
  175.         protected function enterFrameHandler(e:Event):void
  176.         { 
  177.            updateStormMap();
  178.            updateRepulsionMap();
  179.            updateForceMap();
  180.            updateParticles();
  181.         }
  182.         
  183.         /**
  184.         * We calculate current forcefielde's state by blending two stormMap.
  185.         * Therefore force field gradually changes every frame.
  186.         */
  187.         protected function updateStormMap():void
  188.         {
  189.             stormCycle++;
  190.             if(stormCycle == 180){
  191.                 stormMap0.perlinNoise(256,256,3,Math.random()*100,false,true,3,false);
  192.             }else if(stormCycle==360){
  193.                 stormMap1.perlinNoise(256,256,3,Math.random()*100,false,true,3,false);
  194.                 stormCycle = 0;
  195.             }
  196.         }
  197.         
  198.         /**
  199.         * We update repulsionMap according to the current mouse position.
  200.         */
  201.         protected function updateRepulsionMap():void
  202.         {
  203.             tempMat.a = 1;
  204.             tempMat.b = 0;
  205.             tempMat.c = 0;
  206.             tempMat.d = 1;
  207.             tempMat.tx = 0;
  208.             tempMat.ty = 0;
  209.             
  210.             repulsionHistoryMap.draw(repulsionFadeMap, tempMat);
  211.             
  212.             tempMat.translate(-128,-128);
  213.             tempMat.translate(mouseX, mouseY);
  214.             tempMat.scale(1/stormScaleRatioX, 1/stormScaleRatioY);
  215.             repulsionHistoryMap.draw(repulsionMap, tempMat, null, BlendMode.HARDLIGHT);
  216.         }
  217.         
  218.         protected function updateForceMap():void
  219.         {
  220.             //generate current force fieldes state with blending two stormMaps.
  221.             forceMap.copyPixels(stormMap1, stormMap0.rect, tempPt);
  222.             tempColt.alphaMultiplier = Math.cos(stormCycle*Math.PI/180)*0.5+0.5;
  223.             forceMap.draw(stormMap0, null, tempColt);
  224.             
  225.             //add mouse repulsion force
  226.             forceMap.draw(repulsionHistoryMap,null,null,BlendMode.HARDLIGHT);
  227.             forceMap.draw(repulsionHistoryMap,null,null,BlendMode.HARDLIGHT);
  228.         }
  229.         
  230.         protected function updateParticles():void
  231.         {
  232.             var forceBytes:ByteArray = forceMap.getPixels(forceMap.rect);
  233.             
  234.             var stageW:int = canvas.width;
  235.             var stageH:int = canvas.height;
  236.             var loopW:int = stageW-1;
  237.             var loopH:int = stageH-1;
  238.             var byteIndex:int;
  239.             
  240.             canvas.lock();
  241.             canvas.colorTransform(canvas.rect, fadeCanvasColt);
  242.             
  243.             //Update Paritcle position and draw.
  244.             var col:int, r:int, g:int, b:int;
  245.             for(var i:int=0; i<particleNum; i++)
  246.             {
  247.                 var prt:Particle = particles[i];
  248.                 byteIndex = (int(prt.y*stormScaleRatioY)*256 + int(prt.x*stormScaleRatioX))<<2;
  249.                 prt.vx = prt.vx * 0.96 + (forceBytes[byteIndex+1]-128)*prt.scaleFactor;
  250.                 prt.vy = prt.vy * 0.96 + (forceBytes[byteIndex+2]-128)*prt.scaleFactor;
  251.                 prt.x += prt.vx;
  252.                 prt.y += prt.vy;
  253.                 if(prt.x<0){
  254.                     prt.x = loopW;
  255.                 }else if(prt.x > loopW){
  256.                     prt.x = 1;
  257.                 }
  258.                 if(prt.y<0){
  259.                     prt.y = loopH;
  260.                 }else if(prt.y > loopH){
  261.                     prt.y = 1;
  262.                 }
  263.                 
  264.                 //Self implimentation of addtive color blend mode.
  265.                 //Because there is too many particle, blending particle with low brightness color is much effective.
  266.                 col = canvas.getPixel(int(prt.x), int(prt.y));
  267.                 r = (col>>16&0xff) + prt.r;
  268.                 g = (col>>8&0xff) + prt.g;
  269.                 b = (col&0xff) + prt.b;
  270.                 r = (r<0xff)? r : 0xff;
  271.                 g = (g<0xff)? g : 0xff;
  272.                 b = (b<0xff)? b : 0xff;
  273.                 canvas.setPixel(int(prt.x), int(prt.y), (r<<16)|(g<<8)|b);
  274.             }
  275.             canvas.unlock();
  276.         }
  277.     }
  278.     
  279. }
  280. class Particle
  281. {
  282.     //particle position
  283.     public var x:Number = 0;
  284.     public var y:Number = 0;
  285.     public var vx:Number = 0;
  286.     public var vy:Number = 0;
  287.     
  288.     //particle color
  289.     public var r:int;
  290.     public var g:int;
  291.     public var b:int;
  292.     
  293.     //scale factor that affects the force applied to the particle.
  294.     public var scaleFactor:Number;
  295. }
noswf
Get Adobe Flash Player