Playing with Flint

Damn I love messing with Flint - it is one seriously cool particle system :) This is a little test I threw together tonight in about half an hour (includes creating the planet image!). Leave it for a few seconds to see the planet trail burn up, and then just click anywhere you want to re-position the gravity well!

Code wise it's extremely simple:

Actionscript:
  1. package
  2. {
  3.     import flash.display.Bitmap;
  4.     import flash.display.Sprite;
  5.     import flash.geom.Point;
  6.     import flash.events.MouseEvent;
  7.     import flash.filters.BlurFilter;
  8.     import org.flintparticles.actions.*;
  9.     import org.flintparticles.activities.EmitterImage;
  10.     import org.flintparticles.activities.RotateEmitter;
  11.     import org.flintparticles.counters.*;
  12.     import org.flintparticles.debug.FrameTimer;
  13.     import org.flintparticles.emitters.*;
  14.     import org.flintparticles.initializers.*;
  15.     import org.flintparticles.zones.*;
  16.  
  17.     public class tinderbox extends Sprite
  18.     {
  19.         private var emitter:PixelEmitter;
  20.         private var gravwell:GravityWell;
  21.         private var planet:Bitmap;
  22.        
  23.         public function tinderbox():void
  24.         {
  25.             planet = new Bitmap(new planetPNG(90, 90));
  26.             planet.x = 354;
  27.             planet.y = 106;
  28.            
  29.             init();
  30.             var t:FrameTimer = new FrameTimer();
  31.             addChild(t);
  32.            
  33.             stage.addEventListener(MouseEvent.CLICK, randomGW, false, 0, true);
  34.            
  35.             addChild(planet);
  36.         }
  37.        
  38.         private function init():void
  39.         {
  40.             emitter = new PixelEmitter();
  41.            
  42.             emitter.addFilter( new BlurFilter( 4, 4, 1 ) );
  43.             emitter.setCounter(new Pulse(1, 200));
  44.             emitter.addAction(new ColorChange(0xffffff00, 0xffdd0000));
  45.             emitter.addInitializer(new Position(new DiscZone(new Point(398, 150), 41)));
  46.             emitter.addInitializer(new Lifetime(4, 8));
  47.             emitter.addAction(new Age());
  48.             emitter.addActivity( new RotateEmitter(10));
  49.             emitter.addAction( new RandomDrift(40,40));
  50.             emitter.addAction(new Move());
  51.             emitter.addAction(new LinearDrag(0.5));
  52.             gravwell = new GravityWell(450, 47, 439);
  53.            
  54.             emitter.addAction( gravwell );
  55.            
  56.             addChild(emitter);
  57.            
  58.             emitter.start();
  59.         }
  60.        
  61.         private function randomGW(event:MouseEvent):void
  62.         {
  63.             var x:int = mouseX;
  64.             var y:int = mouseY;
  65.            
  66.             trace("new gw at " + x + " " + y);
  67.            
  68.             emitter.removeAction( gravwell );
  69.             gravwell = new GravityWell(470, x, y);
  70.             emitter.addAction( gravwell );
  71.         }
  72.        
  73.     }
  74.    
  75. }

3 Responses to “Playing with Flint”

  1. Smith Says:

    Very nice work.
    I wonder which version you’re using, since I couldn’t find PixelEmitter class. Also, can you give some help about class planetPNG.

    Cheers

  2. rich Says:

    Yeah sorry this demo was made with the old version of Flint before the Renderer moved to its own class. It’s an easy change to get it running in 1.0.2 though.

    planetPNG is just a PNG file imported into the Library, given a class name of planetPNG (of type BitmapData, not MovieClip). If you like I can convert to Flint 1.0.2 and upload the source.

  3. Smith Says:

    Thanks for your reply.
    I’m a newbie of AS3.0 3D. That will be much helpful if you can make source available (1.0.2 version).

    Cheers

Leave a Reply