Learn how to integrate the Flint particle system with Away3D.
Away3D does not have a particle system of its own, which is a shame because particles are a great way of displaying complex effects without requiring a lot of processing power. Thankfully the Flint particle system does integrate with Away3D. In this article we will look at how this is done.
EmitterContainer.as
The EmitterContainer class wraps up a Flint particle emitter. Like any object, the Flint particle emitter needs to be managed, and the EmitterContainer class allows us to create and add the Flint emitter to the scene, and then remove it, either with a call to shutdown like any other BaseObject, or when the emitter has finished and the EMITTER_EMPTY event has been triggered. In this way you can add an emitter that continues indefinitely and call shutdown yourself, or add an emitter that will remove itself once it has finished.
The EmitterContainer class takes care of all the initialisation and cleanup of the emiiter class. It will add the emitter to the Flint renderer [code], watch for the EMITTER_EMPTY event [code] and start the emitter [code].
The shutdown function does the reverse by removing the removeEmitter function from the EMITTER_EMPTY event [code] and removing the emitter from the Flint renderer [code].
Fire.as & Fountain.as
These two classes are the Flint emitters. The Flint documentation covers the nuances of creating an emitter, so I won’t go into too much detail here, except to say that all emitters that are displayed by the Away3D engine need to have an A3DDisplayObjectClass initializer added. The A3DDisplayObjectClass class creates the 3D object that will be displayed by the Away3D engine.
ApplicationManager.as
The ApplicationManager shows how the emitters and the EmitterContainer class work together. First a new EmitterContainer is created, and then its startup function is called with a new instance of the Flint emitter class. [code]
EngineManager.as
The EngineManager is modified to include the Flint renderer. [code]
The Flint particle system is a very capable particle system, and with a few simple modifications it can be integrated into the Away3D engine quite easily. A small point of interest is that the latest Away3D engine (3.3.3 at the time of writing) as changed some of the names of its classes, like Matrix3D to MatrixAway3D. The latest version of Flint (2.1 at the time of writing) has not been updated to incorporate these changes. If you get an error message about undefined Matrix3D classes, grab the Flint source (you won’t be able to use the compiled SWC files) and manually update the references yourself. I have also included a copy of the Flint library with these fixes already implemented under the Related Files section.
Go back to Away3D Tutorials