Class com.lookmum.view.ParticlePlayground

com.lookmum.view.ParticlePlayground

Description

Particle playground class

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.startFountain()

Field Index

acceleration, accelerationVariation, alpha, alphaVariation, broadcastParticleDeath, burst, burstLength, direction, directionVariation, distance, distanceVariation, frameGap, frameGapVariation, gravity, height, killStoppedParticles, PARTICLE_DEATH, particleColour, particleFilters, particleLimit, PARTICLES_END, particleSource, rate, rateVariation, scale, scaleVariation, speed, speedVariation, width, x, xVariation, y, yVariation

Method Index

new ParticlePlayground()

addEventListener(), getParticleDirection(), getParticleScale(), getParticleSpeed(), getParticleX(), getParticleY(), removeEventListener(), startFountain(), stopFountain()

Constructor Detail

ParticlePlayground

function ParticlePlayground(target:MovieClip)

Constructor function.

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.startFountain()

Parameters

targetThe target movieclip in which to create the particle fountain.

Field Detail

PARTICLE_DEATH

static public PARTICLE_DEATH:String
Event. Broadcast whenever a particle dies.
Event object contains a reference number to get properties for the dead particle.
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.broadcastParticleDeath = true
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,onParticleDeath)
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead at x='+getParticleX(event.ref)+' '+ y='+getParticleY(event.ref))
}

PARTICLES_END

static public PARTICLES_END:String
Event. Broadcast when all particles on stage have died.
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.addEventListener(ParticlePlayground.PARTICLES_END,onParticlesEnd)
this.pPlayground.burst = true
this.pPlayground.burstLength = 10
this.pPlayground.startFountain()
function onParticlesEnd(event:Object):Void{
	trace('all particles gone')
}

width

public width:Number
The width in pixels of the particle playground. Particles will be destroyed on reaching this boundary
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.width = 800
this.pPlayground.startFountain()

height

public height:Number
The width in pixels of the particle playground. Particles will be destroyed on reaching this boundary
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.height = 600
this.pPlayground.startFountain()

x

public x:Number
The x coordinate in pixels of the particle playground fountain. Particles will originate from this point
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.x = 300
this.pPlayground.startFountain()

y

public y:Number
The y coordinate in pixels of the particle playground fountain. Particles will originate from this point
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.y = 300
this.pPlayground.startFountain()

xVariation

public xVariation:Number
The amount of random variation from the specified x coordinate
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.x = 300
this.pPlayground.xVariation = 100
this.pPlayground.startFountain()

yVariation

public yVariation:Number
The amount of random variation from the specified y coordinate
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.y = 300
this.pPlayground.yVariation = 100
this.pPlayground.startFountain()

distance

public distance:Number
The distance in pixels from the particle source particles will travel before being destroyed. setting to 0 means no limit
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.distance = 50
this.pPlayground.startFountain()

distanceVariation

public distanceVariation:Number
The amount of random variation from the specified distance
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.distance = 50
this.pPlayground.distanceVariation = 20
this.pPlayground.startFountain()

rate

public rate:Number
The amount of particles created each frame. Setting this number too high can have a significant impact on performance.
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.rate = 3
this.pPlayground.startFountain()

rateVariation

public rateVariation:Number
The amount of random variation from the specified rate
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.rate = 3
this.pPlayground.rateVariation = 4
this.pPlayground.startFountain()

frameGap

public frameGap:Number
The amount of frames between particle creation.
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.frameGap = 4
this.pPlayground.startFountain()

frameGapVariation

public frameGapVariation:Number
The amount of random variation from the specified frameGap
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.frameGap = 4
this.pPlayground.frameGapVariation = 4
this.pPlayground.startFountain()

particleLimit

public particleLimit:Number
The maximum amount of particles allowed on stage at any time. setting to 0 means no limit
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.frameGap = 4
this.pPlayground.frameGapVariation = 4
this.pPlayground.startFountain()

burst

public burst:Boolean
Sets the fountain to burst mode. fountain creates particles for the amount of frames specified by burstLength
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.burst = true
this.pPlayground.burstLength = 10
this.pPlayground.startFountain()

burstLength

public burstLength:Number
The amount of frames to create particles for. used with burst=true
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.burst = true
this.pPlayground.burstLength = 10
this.pPlayground.startFountain()

particleSource

public particleSource:String
A linkage identifier to use a library symbol as the particle graphic.
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.particleSource = 'myLibrarySymbol'
this.pPlayground.startFountain()

scale

public scale:Number
The amount in percent to scale particles by
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.scale = 500
this.pPlayground.startFountain()

scaleVariation

public scaleVariation:Number
The amount of random variation from the specified scale
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.scale = 500
this.pPlayground.scaleVariation = 500
this.pPlayground.startFountain()

direction

public direction:Number
The direct in degrees to move particles by
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.direction = 45
this.pPlayground.startFountain()

directionVariation

public directionVariation:Number

particleFilters

public particleFilters:Array [Write Only]
An array of filters to apply to created particles (flash 8+ only)
Usage
import com.lookmum.view.ParticlePlayground
import flash.filters.BlurFilter;
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
var blurX:Number = 3;
var blurY:Number = 3;
var quality:Number = 3;
var filter:BlurFilter = new BlurFilter(blurX, blurY, quality);
var filterArray:Array = new Array();
this.filterArray.push(this.filter);
this.pPlayground.particleFilters = filterArray;
this.pPlayground.startFountain()

gravity

public gravity:Number
The amount of gravity effect to apply to particles
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.gravity = 1
this.pPlayground.startFountain()

speed

public speed:Number
The speed of created particles
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.speed = 4
this.pPlayground.startFountain()

speedVariation

public speedVariation:Number
The amount of random variation from the specified speed
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.speed = 4
this.pPlayground.speedVariation = 4
this.pPlayground.startFountain()

acceleration

public acceleration:Number
The acceleration of created particles. set this to negative numbers for swarming effects
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.acceleration = 0.2
this.pPlayground.startFountain()

accelerationVariation

public accelerationVariation:Number
The amount of random variation from the specified acceleration
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.acceleration = 0.4
this.pPlayground.accelerationVariation = 0.2
this.pPlayground.startFountain()

particleColour

public particleColour:Number
The colour of created particles if not using a library particle source.
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.particleColour = 0xFF0000
this.pPlayground.startFountain()

alpha

public alpha:Number
The transparency of created particles.
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.alpha = 50
this.pPlayground.startFountain()

alphaVariation

public alphaVariation:Number
The amount of random variation from the specified alpha
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.alpha = 50
this.pPlayground.alphaVariation = 50
this.pPlayground.startFountain()

broadcastParticleDeath

public broadcastParticleDeath:Boolean
If true, particlePlayground will broadcast particle deaths
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.broadcastParticleDeath = true
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,onParticleDeath)
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead at x='+getParticleX(event.ref)+' '+ y='+getParticleY(event.ref))
}

killStoppedParticles

public killStoppedParticles:Boolean
The when set to true, particles that reach 0 speed are destroyed. use with negative acceleration values
Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.acceleration = -0.1
this.pPlayground.killStoppedParticles = true
this.pPlayground.startFountain()

Method Detail

addEventListener

public function addEventListener(eventType:String, listener:Function)

Add a listener function to be notified of a specified event

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,onParticleDeath)
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead at x='+getParticleX(event.ref)+' '+ y='+getParticleY(event.ref))
}
Although not required, it is advised that you use this in conjunction with the macromedia delegate utility to keep your function scope in order.
import mx.utils.Delegate
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,Delegate.create(this,this.onParticleDeath))
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead at x='+getParticleX(event.ref)+' '+ y='+getParticleY(event.ref))
}

Parameters

eventTypeThe type of event to listen to
listenerThe function to call on event

removeEventListener

public function removeEventListener(eventType:String, listener:Function)

Remove a listener from being notified of a specified event

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.removeEventListener(ParticlePlayground.PARTICLE_DEATH,this.onParticleDeath)

Parameters

eventTypeThe type of event no longer listen to
listenerThe object to no longer call on event

startFountain

public function startFountain(frame:Number):Void

start the particle fountain. if frame is specified then simulate start after amount of frames (this can have serious performance problems if set too high)

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.startFountain()

Parameters

framethe number of frames to simulate having passed

stopFountain

public function stopFountain(fast:Boolean):Void

stop the generation of particles. and erase all current particle if fast is true

Usage
this.pPlayground.stopFountain()

Parameters

fastdeletes all existing particles immediately

getParticleX

public function getParticleX(ref:Number):Number

gets the x coordinate of a specified particle. use with the PARTICLE_DEATH event to get particle references

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.broadcastParticleDeath = true
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,onParticleDeath)
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead at x='+getParticleX(event.ref))
}

Parameters

refa unique reference number of the particle

Return

the x coordinate of the particle

getParticleY

public function getParticleY(ref:Number):Number

gets the y coordinate of a specified particle. use with the PARTICLE_DEATH event to get particle references

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.broadcastParticleDeath = true
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,onParticleDeath)
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead at y='+getParticleY(event.ref))
}

Parameters

refa unique reference number of the particle

Return

the y coordinate of the particle

getParticleScale

public function getParticleScale(ref:Number):Number

gets the scale in percent of a specified particle. use with the PARTICLE_DEATH event to get particle references

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.broadcastParticleDeath = true
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,onParticleDeath)
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead with scale='+getParticleScale(event.ref))
}

Parameters

refa unique reference number of the particle

Return

the scale of the particle

getParticleSpeed

public function getParticleSpeed(ref:Number):Number

gets the speed in pixels per frame of a specified particle. use with the PARTICLE_DEATH event to get particle references

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.broadcastParticleDeath = true
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,onParticleDeath)
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead with speed='+getParticleSpeed(event.ref))
}

Parameters

refa unique reference number of the particle

Return

the speed of the particle

getParticleDirection

public function getParticleDirection(ref:Number):Number

gets the direction in degrees of a specified particle. use with the PARTICLE_DEATH event to get particle references

Usage
import com.lookmum.view.ParticlePlayground
var pPlayground:ParticlePlayground = new ParticlePlayground(thisMc)
this.pPlayground.broadcastParticleDeath = true
this.pPlayground.addEventListener(ParticlePlayground.PARTICLE_DEATH,onParticleDeath)
this.pPlayground.startFountain()
function onParticleDeath(event:Object):Void{
	trace('particle dead with direction='+getParticleDirection(event.ref))
}

Parameters

refa unique reference number of the particle

Return

the direction of the particle