| Package | org.flintparticles.emitters |
| Class | public class Emitter |
| Inheritance | Emitter flash.events.EventDispatcher |
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 make it move or rotate.
An emitter uses a Counter to know when and how many particles to emit.
An emitter uses a Renderer to display the particles on screen.
All timings in the emitter are based on actual time passed, not on frames.
Most functionality is best added to an emitter using Actions, Initializers, Activities, Counters and Renderers. This offers greater flexibility to combine behaviours witout needing to subclass the Emitter itself.
The emitter also has position properties - x, y, rotation - that can be used to directly affect its location in the particle system.
| Property | Defined by | ||
|---|---|---|---|
| counter : Counter
The Counter for the Emitter.
| Emitter | ||
| maximumFrameTime : Number
The maximum duration, in seconds, 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 [read-only]
The array of all particles created by this emitter.
| Emitter | ||
| renderer : Renderer
The Renderer for the Emitter.
| Emitter | ||
| rotation : Number
Indicates the rotation of the Emitter, in degrees, within the particle system's coordinate space.
| Emitter | ||
| rotRadians : Number
Indicates the rotation of the Emitter, in radians, within the particle system's
coordinate space.
| Emitter | ||
| spaceSort : Boolean = false
Identifies whether the particles should be arranged
into spacially sorted arrays - this speeds up proximity
testing for those actions that need it.
| Emitter | ||
| spaceSortedX : Array
The array of particle indices sorted based on the particles' horizontal positions.
| Emitter | ||
| x : Number
Indicates the x coordinate of the Emitter within the particle system's coordinate space.
| Emitter | ||
| y : Number
Indicates the y coordinate of the Emitter within the particle system's coordinate space.
| Emitter | ||
| Method | Defined by | ||
|---|---|---|---|
|
Emitter()
The constructor creates an emitter.
| Emitter | ||
|
Adds an Action to the Emitter.
| Emitter | ||
|
addActivity(activity:Activity, priority:Number):void
Adds an Activity to the Emitter.
| Emitter | ||
|
addDisplayObjects(... objects):void
Adds existing display objects as particles to the emitter.
| Emitter | ||
|
addInitializer(initializer:Initializer, priority:Number):void
Adds an Initializer object to the Emitter.
| Emitter | ||
|
dispose():void
Cleans up the emitter prior to removal.
| 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 | ||
|
rendererGlobalToLocal(p:Point):Point
If the emitter's renderer is a display object, this method will
calculate a localToGlobal on the point with respect to the renderer.
| Emitter | ||
|
rendererLocalToGlobal(p:Point):Point
If the emitter's renderer is a display object, this method will
calculate a localToGlobal on the point with respect to the renderer.
| 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 | ||
| Method | Defined by | ||
|---|---|---|---|
| Emitter | |||
|
frameUpdate(time:Number):void
Used internally and in derived classes to update the emitter.
| Emitter | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when an emitter attempts to update the particles' state but it contains no particles. | Emitter | |||
| Dispatched when a particle is created and has just been added to the system. | Emitter | |||
| Dispatched when a particle dies and is about to be removed from the system. | Emitter | |||
| 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
| maximumFrameTime | property |
maximumFrameTime:Number [read-write]The maximum duration, in seconds, 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 default value is an instance of the ParticleCreator class that is shared by all emitters. You don't usually need to alter this unless you are not using the default particle type. Any custom particle factory should implement the ParticleFactory class.
Implementation public function get particleFactory():ParticleFactory
public function set particleFactory(value:ParticleFactory):void
See also
| particles | property |
particles:Array [read-only]The array of all particles created by this emitter.
Implementation public function get particles():Array
| renderer | property |
renderer:Renderer [read-write]The Renderer for the Emitter. The renderer draws the particles.
Implementation public function get renderer():Renderer
public function set renderer(value:Renderer):void
| rotation | property |
rotation:Number [read-write]Indicates the rotation of the Emitter, in degrees, within the particle system's coordinate space.
Implementation public function get rotation():Number
public function set rotation(value:Number):void
| rotRadians | property |
rotRadians:Number [read-write]Indicates the rotation of the Emitter, in radians, within the particle system's coordinate space.
Implementation public function get rotRadians():Number
public function set rotRadians(value:Number):void
| spaceSort | property |
public var spaceSort:Boolean = falseIdentifies whether the particles should be arranged into spacially sorted arrays - this speeds up proximity testing for those actions that need it.
| spaceSortedX | property |
public var spaceSortedX:ArrayThe array of particle indices sorted based on the particles' horizontal positions. To persuade the emitter to create this array you should set the spaceSort property to true. Usually, actions that need this set to true will do so in their addedToEmitter method.
| x | property |
x:Number [read-write]Indicates the x coordinate of the Emitter within the particle system's coordinate space.
Implementation public function get x():Number
public function set x(value:Number):void
| y | property |
y:Number [read-write]Indicates the y coordinate of the Emitter within the particle system's coordinate space.
Implementation public function get y():Number
public function set y(value:Number):void
| Emitter | () | constructor |
public function Emitter()The constructor creates an emitter.
| addAction | () | method |
public function addAction(action:Action, priority:Number):voidAdds an Action to the Emitter. Actions set the behaviour of particles created by the emitter.
Parametersaction:Action — The Action to add
|
|
priority:Number — Indicates the sequencing of the actions. Higher numbers cause
an action to be run before other actions. All actions have a default priority
which is used if no value is passed in this parameter. The default priority is usually
the one you want so this parameter is only used when you need to override the default.
|
| addActivity | () | method |
public function addActivity(activity:Activity, priority:Number):voidAdds an Activity to the Emitter. Activities set the behaviour of the Emitter.
Parametersactivity:Activity — The activity to add
|
|
priority:Number — Indicates the sequencing of the activities. Higher numbers cause
an activity to be run before other activities. All activities have a default priority
which is used if no value is passed in this parameter. The default priority is usually
the one you want so this parameter is only used when you need to override the default.
|
| addDisplayObjects | () | method |
public function addDisplayObjects(... objects):voidAdds existing display objects as particles to the emitter. This allows you, for example, to take an existing image and subject it to the actions of the emitter.
This method moves all the display objects into the emitter's renderer, removing them from their current position within the display list. It will only work if a renderer has been defined for the emitter and the renderer has been added to the display list.
Parameters... objects — Each parameter is another display object for adding to the emitter.
If you pass an array as the parameter, each item in the array should be another
display object for adding to the emitter.
|
| addInitializer | () | method |
public function addInitializer(initializer:Initializer, priority:Number):voidAdds an Initializer object to the Emitter. Initializers set the initial properties of particles created by the emitter.
Parametersinitializer:Initializer — The Initializer to add
|
|
priority:Number — Indicates the sequencing of the initializers. Higher numbers
cause an initializer to be run before other initialzers. All initializers
have a default priority which is used if no value is passed in this
parameter. The default priority is usually the one you want so this
parameter is only used when you need to override the default.
|
| createParticle | () | method |
| dispose | () | method |
public function dispose():voidCleans up the emitter prior to removal. If you don't call this method, the garbage collector will clean up all the particles in teh usual way. If you use this method, the particles will be returned to the particle factory for reuse.
| frameUpdate | () | method |
protected function frameUpdate(time:Number):voidUsed internally and in derived classes to update the emitter.
Parameterstime:Number — The duration, in seconds, of the current frame.
|
| 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
| rendererGlobalToLocal | () | method |
public function rendererGlobalToLocal(p:Point):PointIf the emitter's renderer is a display object, this method will calculate a localToGlobal on the point with respect to the renderer. The new point is returned. If the renderer is not a display object then the original point is returned.
Parametersp:Point |
Point |
| rendererLocalToGlobal | () | method |
public function rendererLocalToGlobal(p:Point):PointIf the emitter's renderer is a display object, this method will calculate a localToGlobal on the point with respect to the renderer. The new point is returned. If the renderer is not a display object then the original point is returned.
Parametersp:Point |
Point |
| 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.
|
| start | () | method |
public function start():voidStarts the emitter. Until start is called, the emitter will not emit any particles.
| emitterEmpty | event |
org.flintparticles.events.FlintEvent
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 disposed. So the event will not be dispatched at these times.
See the firework example for an example that uses this event.
See also
| particleCreated | event |
org.flintparticles.events.FlintEvent
Dispatched when a particle is created and has just been added to the system.
| particleDead | event |
org.flintparticles.events.FlintEvent
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.