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:

[as]
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.geom.Point;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import org.flintparticles.actions.*;
import org.flintparticles.activities.EmitterImage;
import org.flintparticles.activities.RotateEmitter;
import org.flintparticles.counters.*;
import org.flintparticles.debug.FrameTimer;
import org.flintparticles.emitters.*;
import org.flintparticles.initializers.*;
import org.flintparticles.zones.*;

public class tinderbox extends Sprite
{
private var emitter:PixelEmitter;
private var gravwell:GravityWell;
private var planet:Bitmap;

public function tinderbox():void
{
planet = new Bitmap(new planetPNG(90, 90));
planet.x = 354;
planet.y = 106;

init();
var t:FrameTimer = new FrameTimer();
addChild(t);

stage.addEventListener(MouseEvent.CLICK, randomGW, false, 0, true);

addChild(planet);
}

private function init():void
{
emitter = new PixelEmitter();

emitter.addFilter( new BlurFilter( 4, 4, 1 ) );
emitter.setCounter(new Pulse(1, 200));
emitter.addAction(new ColorChange(0xffffff00, 0xffdd0000));
emitter.addInitializer(new Position(new DiscZone(new Point(398, 150), 41)));
emitter.addInitializer(new Lifetime(4, 8));
emitter.addAction(new Age());
emitter.addActivity( new RotateEmitter(10));
emitter.addAction( new RandomDrift(40,40));
emitter.addAction(new Move());
emitter.addAction(new LinearDrag(0.5));
gravwell = new GravityWell(450, 47, 439);

emitter.addAction( gravwell );

addChild(emitter);

emitter.start();
}

private function randomGW(event:MouseEvent):void
{
var x:int = mouseX;
var y:int = mouseY;

trace(“new gw at ” + x + ” ” + y);

emitter.removeAction( gravwell );
gravwell = new GravityWell(470, x, y);
emitter.addAction( gravwell );
}

}

}
[/as]

Posted on April 10th 2008 at 10:46 pm by .
View more posts in Experiments. Follow responses via the RSS 2.0 feed.


3 Responses

Leave a comment
  • Smith
    May 19th 2008 at 1:27 am

    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

  • May 19th 2008 at 5:40 pm

    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.

  • Smith
    May 21st 2008 at 5:39 am

    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

Make yourself heard