| Package | org.flintparticles.common.emitters |
| Class | public class Emitter |
| Inheritance | Emitter flash.events.EventDispatcher |
| Subclasses | Emitter2D, Emitter3D |
An Emitter manages the creation and ongoing state of particles. It uses a number of utility classes to customise its behaviour.
An emitter uses Initializers to customise the initial state of particles that it creates; their position, velocity, color etc. These are added to the emitter using the addInitializer method.
An emitter uses Actions to customise the behaviour of particles that it creates; to apply gravity, drag, fade etc. These are added to the emitter using the addAction method.
An emitter uses Activities to customise its own behaviour in an ongoing manner, to move it or rotate it for example.
An emitter uses a Counter to know when and how many particles to emit.
All timings in the emitter are based on actual time passed, independent of the frame rate of the flash movie.
Most functionality is best added to an emitter using Actions, Initializers, Activities and Counters. This offers greater flexibility to combine behaviours without needing to subclass the Emitter classes.
| Property | Defined by | ||
|---|---|---|---|
| actions : Array
The array of all actions being used by this emitter.
| Emitter | ||
| activities : Array
The array of all actions being used by this emitter.
| Emitter | ||
| counter : Counter
The Counter for the Emitter.
| Emitter | ||
| fixedFrameTime : Number
Indicates a fixed time (in seconds) to use for every frame.
| Emitter | ||
| initializers : Array
The array of all initializers being used by this emitter.
| Emitter | ||
| maximumFrameTime : Number
The maximum duration for a single update frame, in seconds.
| Emitter | ||
| particleFactory : ParticleFactory
This is the particle factory used by the emitter to create and dispose
of particles.
| Emitter | ||
| particles : Array
The array of all particles created by this emitter.
| Emitter | ||
| running : Boolean [read-only]
Indicates if the emitter is currently running.
| Emitter | ||
| useInternalTick : Boolean
Indicates whether the emitter should manage its own internal update
tick.
| Emitter | ||
| Property | Defined by | ||
|---|---|---|---|
| _dispatchCounterComplete : Boolean = false
Indicates if the emitter should dispatch a counterComplete event at the
end of the next update cycle.
| Emitter | ||
| Method | Defined by | ||
|---|---|---|---|
|
Emitter()
The constructor creates an emitter.
| Emitter | ||
|
Adds an Action to the Emitter.
| Emitter | ||
|
addActivity(activity:Activity):void
Adds an Activity to the Emitter.
| Emitter | ||
|
addExistingParticles(particles:Array, applyInitializers:Boolean = false):void
Adds existing particles to the emitter.
| Emitter | ||
|
addInitializer(initializer:Initializer):void
Adds an Initializer object to the Emitter.
| Emitter | ||
|
dispatchCounterComplete():void
Used by counters to tell the emitter to dispatch a counter complete event.
| Emitter | ||
|
Detects if the emitter is using a particular action or not.
| Emitter | ||
|
hasActionOfType(actionClass:Class):Boolean
Detects if the emitter is using an action of a particular class.
| Emitter | ||
|
hasActivity(activity:Activity):Boolean
Detects if the emitter is using a particular activity or not.
| Emitter | ||
|
hasActivityOfType(activityClass:Class):Boolean
Detects if the emitter is using an activity of a particular class.
| Emitter | ||
|
hasInitializer(initializer:Initializer):Boolean
Detects if the emitter is using a particular initializer or not.
| Emitter | ||
|
hasInitializerOfType(initializerClass:Class):Boolean
Detects if the emitter is using an initializer of a particular class.
| Emitter | ||
|
killAllParticles():void
| Emitter | ||
|
pause():void
Pauses the emitter.
| Emitter | ||
|
removeAction(action:Action):void
Removes an Action from the Emitter.
| Emitter | ||
|
removeActivity(activity:Activity):void
Removes an Activity from the Emitter.
| Emitter | ||
|
removeInitializer(initializer:Initializer):void
Removes an Initializer from the Emitter.
| Emitter | ||
|
resume():void
Resumes the emitter after a pause.
| Emitter | ||
|
runAhead(time:Number, frameRate:Number = 10):void
Makes the emitter skip forwards a period of time with a single update.
| Emitter | ||
|
start():void
Starts the emitter.
| Emitter | ||
|
stop():void
Stops the emitter, killing all current particles and returning them to the
particle factory for reuse.
| Emitter | ||
|
update(time:Number):void
Used to update the emitter.
| Emitter | ||
| Method | Defined by | ||
|---|---|---|---|
| Emitter | |||
|
initParticle(particle:Particle):void
Emitters do their own particle initialization here - usually involves
positioning and rotating the particle to match the position and rotation
of the emitter.
| Emitter | ||
|
sortParticles():void
Used to sort the particles as required.
| Emitter | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when the counter for the particle system has finished its cycle and so the system will not emit any more particles unless the counter is changed or restarted. | Emitter | |||
| Dispatched when an emitter attempts to update the particles' state but it contains no particles. | Emitter | |||
| Dispatched when the particle system has updated and the state of the particles has changed. | Emitter | |||
| Dispatched when a pre-existing particle is added to the emitter. | Emitter | |||
| Dispatched when a particle is created and has just been added to the emitter. | Emitter | |||
| Dispatched when a particle dies and is about to be removed from the system. | Emitter | |||
| actions | property |
actions:Array [read-write]The array of all actions being used by this emitter.
Implementation public function get actions():Array
public function set actions(value:Array):void
| activities | property |
activities:Array [read-write]The array of all actions being used by this emitter.
Implementation public function get activities():Array
public function set activities(value:Array):void
| counter | property |
counter:Counter [read-write]The Counter for the Emitter. The counter defines when and with what frequency the emitter emits particles.
Implementation public function get counter():Counter
public function set counter(value:Counter):void
| _dispatchCounterComplete | property |
protected var _dispatchCounterComplete:Boolean = falseIndicates if the emitter should dispatch a counterComplete event at the end of the next update cycle.
| fixedFrameTime | property |
fixedFrameTime:Number [read-write]Indicates a fixed time (in seconds) to use for every frame. Setting this property causes the emitter to bypass its frame timing functionality and use the given time for every frame. This enables the particle system to be frame based rather than time based.
To return to time based animation, set this value to zero (the default).
This feature only works if useInternalTick is true (the default).
Implementation public function get fixedFrameTime():Number
public function set fixedFrameTime(value:Number):void
See also
| initializers | property |
initializers:Array [read-write]The array of all initializers being used by this emitter.
Implementation public function get initializers():Array
public function set initializers(value:Array):void
| maximumFrameTime | property |
maximumFrameTime:Number [read-write]The maximum duration for a single update frame, in seconds.
Under some circumstances related to the Flash player (e.g. on MacOSX, when the user right-clicks on the flash movie) the flash movie will freeze for a period. When the freeze ends, the current frame of the particle system will be calculated as the time since the previous frame, which encompases the duration of the freeze. This could cause the system to generate a single frame update that compensates for a long period of time and hence moves the particles an unexpected long distance in one go. The result is usually visually unacceptable and certainly unexpected.
This property sets a maximum duration for a frame such that any frames longer than this duration are ignored. The default value is 0.5 seconds. Developers don't usually need to change this from the default value.
Implementation public function get maximumFrameTime():Number
public function set maximumFrameTime(value:Number):void
| particleFactory | property |
particleFactory:ParticleFactory [read-write]This is the particle factory used by the emitter to create and dispose of particles. The 2D and 3D libraries each have a default particle factory that is used by the Emitter2D and Emitter3D classes. Any custom particle factory should implement the ParticleFactory interface.
Implementation public function get particleFactory():ParticleFactory
public function set particleFactory(value:ParticleFactory):void
See also
| particles | property |
particles:Array [read-write]The array of all particles created by this emitter.
Implementation public function get particles():Array
public function set particles(value:Array):void
| running | property |
running:Boolean [read-only]Indicates if the emitter is currently running.
Implementation public function get running():Boolean
| useInternalTick | property |
useInternalTick:Boolean [read-write]Indicates whether the emitter should manage its own internal update tick. The internal update tick is tied to the frame rate and updates the particle system every frame.
If users choose not to use the internal tick, they have to call the emitter's update method with the appropriate time parameter every time they want the emitter to update the particle system.
Implementation public function get useInternalTick():Boolean
public function set useInternalTick(value:Boolean):void
| Emitter | () | constructor |
public function Emitter()The constructor creates an emitter.
| addAction | () | method |
public function addAction(action:Action):voidAdds an Action to the Emitter. Actions set the behaviour of particles created by the emitter.
Parametersaction:Action — The Action to add
|
See also
| addActivity | () | method |
public function addActivity(activity:Activity):voidAdds an Activity to the Emitter. Activities set the behaviour of the Emitter.
Parametersactivity:Activity — The activity to add
|
See also
| addExistingParticles | () | method |
public function addExistingParticles(particles:Array, applyInitializers:Boolean = false):voidAdds existing particles to the emitter. This enables users to create particles externally to the emitter and then pass the particles to the emitter for management.
Parametersparticles:Array — An array of particles
|
|
applyInitializers:Boolean (default = false) — Indicates whether to apply the emitter's
initializer behaviours to the particle (true) or not (false).
|
| addInitializer | () | method |
public function addInitializer(initializer:Initializer):voidAdds an Initializer object to the Emitter. Initializers set the initial state of particles created by the emitter.
Parametersinitializer:Initializer — The Initializer to add
|
See also
| createParticle | () | method |
| dispatchCounterComplete | () | method |
public function dispatchCounterComplete():voidUsed by counters to tell the emitter to dispatch a counter complete event.
| hasAction | () | method |
public function hasAction(action:Action):BooleanDetects if the emitter is using a particular action or not.
Parametersaction:Action — The action to look for.
|
Boolean — true if the action is being used by the emitter, false
otherwise.
|
| hasActionOfType | () | method |
public function hasActionOfType(actionClass:Class):BooleanDetects if the emitter is using an action of a particular class.
ParametersactionClass:Class — The type of action to look for.
|
Boolean — true if the emitter is using an instance of the class as an
action, false otherwise.
|
| hasActivity | () | method |
public function hasActivity(activity:Activity):BooleanDetects if the emitter is using a particular activity or not.
Parametersactivity:Activity — The activity to look for.
|
Boolean — true if the activity is being used by the emitter, false
otherwise.
|
| hasActivityOfType | () | method |
public function hasActivityOfType(activityClass:Class):BooleanDetects if the emitter is using an activity of a particular class.
ParametersactivityClass:Class — The type of activity to look for.
|
Boolean — true if the emitter is using an instance of the class as an
activity, false otherwise.
|
| hasInitializer | () | method |
public function hasInitializer(initializer:Initializer):BooleanDetects if the emitter is using a particular initializer or not.
Parametersinitializer:Initializer — The initializer to look for.
|
Boolean — true if the initializer is being used by the emitter, false
otherwise.
|
| hasInitializerOfType | () | method |
public function hasInitializerOfType(initializerClass:Class):BooleanDetects if the emitter is using an initializer of a particular class.
ParametersinitializerClass:Class — The type of initializer to look for.
|
Boolean — true if the emitter is using an instance of the class as an
initializer, false otherwise.
|
| initParticle | () | method |
protected function initParticle(particle:Particle):voidEmitters do their own particle initialization here - usually involves positioning and rotating the particle to match the position and rotation of the emitter. This method is called before any initializers that are assigned to the emitter, so initializers can override any properties set here.
The implementation of this method in this base class does nothing.
Parametersparticle:Particle |
| killAllParticles | () | method |
public function killAllParticles():void
| pause | () | method |
public function pause():voidPauses the emitter.
| removeAction | () | method |
public function removeAction(action:Action):voidRemoves an Action from the Emitter.
Parametersaction:Action — The Action to remove
|
See also
| removeActivity | () | method |
public function removeActivity(activity:Activity):voidRemoves an Activity from the Emitter.
Parametersactivity:Activity — The Activity to remove
|
See also
| removeInitializer | () | method |
public function removeInitializer(initializer:Initializer):voidRemoves an Initializer from the Emitter.
Parametersinitializer:Initializer — The Initializer to remove
|
See also
| resume | () | method |
public function resume():voidResumes the emitter after a pause.
| runAhead | () | method |
public function runAhead(time:Number, frameRate:Number = 10):voidMakes the emitter skip forwards a period of time with a single update. Used when you want the emitter to look like it's been running for a while.
Parameterstime:Number — The time, in seconds, to skip ahead.
|
|
frameRate:Number (default = 10) — The frame rate for calculating the new positions. The
emitter will calculate each frame over the time period to get the new state
for the emitter and its particles. A higher frameRate will be more
accurate but will take longer to calculate.
|
| sortParticles | () | method |
protected function sortParticles():voidUsed to sort the particles as required. In this base class this method does nothing.
| start | () | method |
public function start():voidStarts the emitter. Until start is called, the emitter will not emit or update any particles.
| stop | () | method |
public function stop():voidStops the emitter, killing all current particles and returning them to the particle factory for reuse.
| update | () | method |
public function update(time:Number):voidUsed to update the emitter. If using the internal tick, this method will be called every frame without any action by the user. If not using the internal tick, the user should call this method on a regular basis to update the particle system.
The method asks the counter how many particles to create then creates those particles. Then it calls sortParticles, applies the activities to the emitter, applies the Actions to all the particles, removes all dead particles, and finally dispatches an emitterUpdated event which tells any renderers to redraw the particles. Parameters
time:Number — The duration, in seconds, to be applied in the update step.
|
See also
| counterComplete | event |
org.flintparticles.common.events.EmitterEvent
Dispatched when the counter for the particle system has finished its cycle and so the system will not emit any more particles unless the counter is changed or restarted.
| emitterEmpty | event |
org.flintparticles.common.events.EmitterEvent
Dispatched when an emitter attempts to update the particles' state but it contains no particles. This event will be dispatched every time the update occurs and there are no particles in the emitter. The update does not occur when the emitter has not yet been started, when the emitter is paused, and after the emitter has been stopped, so the event will not be dispatched at these times.
See the firework example for an example that uses this event.
See also
| emitterUpdated | event |
org.flintparticles.common.events.EmitterEvent
Dispatched when the particle system has updated and the state of the particles has changed.
| particleAdded | event |
org.flintparticles.common.events.ParticleEvent
Dispatched when a pre-existing particle is added to the emitter.
| particleCreated | event |
org.flintparticles.common.events.ParticleEvent
Dispatched when a particle is created and has just been added to the emitter.
| particleDead | event |
org.flintparticles.common.events.ParticleEvent
Dispatched when a particle dies and is about to be removed from the system. As soon as the event has been handled the particle will be removed but at the time of the event it still exists so its properties (e.g. its location) can be read from it.