I have been experimenting again with Flint Particle System, that you can find at flintparticles.org.

I made some smoke, modified from the FireAndSmoke version, already at the site

See the code

And made some rain too.

See the code

Enjoy!

Hi!

Today’s lesson will be about creating a starfield with the Flint Particle System. It’s quiet easy, thanks to the simplicity of the system itself. Let’s jump in! Follow me!

  1. First of all, download the latest version of the Flint Particle System, you can download it here or by SVN. Decompress the archive and copy the files (under the org folder) in your lib directory. Don’t you know how to do this?
  2. We begin making an empty AS3 empty file in the flash IDE. We will prefer to set the Stage background in black, and our frame rate at 40 fps. I will choose to develop the starfield in a class, so i will click on an empty point of the stage, call the Property panel and set Starfield as the document class. I save the document as Starfield.fla.
  3. We create a new actionscript file, named Starfield.as. We will add here all the code to make the class work. We will make the class extend MovieClip because this is a Document Class. Every document class extends MovieClip.

    package {
    public class StarField extends MovieClip {
    public function StarField() {
    }
    }
    }

  4. Add the needed imports.
  5. // all we need to import from flash libraries
    import flash.display.MovieClip;
    import flash.geom.Point;
    import flash.events.Event;
    import flash.filters.BlurFilter;

    // all we need to import from Flint library
    import org.flintparticles.displayObjects.Dot;
    import org.flintparticles.actions.*;
    import org.flintparticles.counters.*;
    import org.flintparticles.emitters.*;
    import org.flintparticles.initializers.*;
    import org.flintparticles.zones.*;

  6. We start by creating the constructor. I usually don’t put code in here, but i wait for the object to be added to the stage, before creating all of it.
  7. public function StarField() {
    this.addEventListener(Event.ADDED_TO_STAGE, added);
    }

  8. So we have to create a added function, that will manage all of the rest.
  9. private function added(e:Event) {
    // your code here…
    }

  10. Now we got to add the control code in the added function, so please delete the “your code here” line and add the newly created code. We start by creating the emitter.
  11. var emitter:BitmapEmitter = new BitmapEmitter();

  12. We will use a Steady counter, that will keep on creating particles continuosly.
  13. emitter.setCounter( new Steady(20) );

  14. I will add a blur effect to have some sort of trail.
  15. emitter.addFilter( new BlurFilter( 2, 2, 1 ) );

  16. We add the initializers. I will use dots for stars, make them change their birth color from 0xFFFFFFFF and 0xFF000FFF, position the stars on a line before they start moving, and give them a left handed direction.
  17. emitter.addInitializer( new SharedImage( new Dot( 1 ) ) );
    emitter.addInitializer( new ColorInit( 0xFFFFFFFF, 0xFF000FFF ) );
    emitter.addInitializer( new Position( new LineZone(new Point(250, 0), new Point(250, 250))) );
    emitter.addInitializer( new Velocity( new PointZone( new Point (-100, 0) ) ) );

  18. Now that all is set, i add actions, that will drive my particles. I tell the particles to move, and i limit their speed to 200, because i do not want them to move too quickly. Then i add a DeathZone, a zone in which the particles contained are set dead or safe (which is the case, and the second parameter determines if the zone if safe). If the particle run outside of the stage, are deleted.
  19. emitter.addAction( new Move() );
    emitter.addAction( new SpeedLimit(200) );
    emitter.addAction( new DeathZone( new RectangleZone(0, 0, stage.stageWidth, stage.stageHeight), true) );

  20. So i will add the emitter to the stage, and make it start.
  21. addChild( emitter );
    emitter.start( );
    emitter.runAhead(2);

  22. The class is done! Enjoy your particle starfield! This should be the result.

[download=4]

See you soon with other Flint related stuff!

Tutorials

Hey all
this are the tutorials i wrote up to now. Please click on the link to read them. Some are just in italian. Some others are in english. I hope you can find them useful. And please, let comments to share every doubt or request!

See you!

  1. Flint Particle System AS3 : How to (in italian)
  2. Flint Particle System AS3 : Creating a simple Starfield
  3. AS2 Gamemaker - 01 - Introduction
  4. AS2 Gamemaker - 02 - Controlling : Mouse Events
  5. AS2 Gamemaker - 03 - Controlling : Keyboard Events
  6. AS2 Gamemaker - 04 - Game Cycle : The basics
  7. AS2 Gamemaker - 05 - Game Cycle : Game programming

Hey all!

I’ve been studying Flint as3 particle system.
I still have learned 80% of its full potential, and i already love it. With a little customization, you can make your own effect classes and then you can use them whenever you want. The methods that has been created are very friendly and self-explicative.

These are two examples made in about half a day, the first things that i always dreamt of.

Follow instructions ;)


I think i’ll write a tutorial for this library soon.

Good night!