Creates functions to be used for independantly moving particle movie clips.
Functions (or "behaviors" created with the ParticleBehavior class are self-
contained and are typically assigned to a particle movie clip's onEnterFrame
event handler. Particle movie clips you would create on your own
[ Behavior Generation ]
description:
The following methods generate behavior functions for your particles
usage: Static
returns: behavior functions
create
description:
Returns an instance of the behavior function specified. Each time create
is called, a new instance of the behavior specified is created with the
properties specified in the optionsObject. For those options not specified
in the optionsObject, defaults are provided
usage:
myParticle.onEnterFrame = ParticleBehavior.create("behaviorname" [, optionsObject]);
parameters:
- behaviorname (String) The name of the behavior to be created
- optionsObject (String) Optional; default: behavior defaults. An object of options related to the behavior
returns: behavior function
multiple
description:
Returns an instance of a function that combines each behavior passed
usage:
myParticle.onEnterFrame = ParticleBehavior.multiple(behavior [, behavior...]);
parameters:
- behavior (Function) any number of comma separated particle behavior functions created with ParticleBehavior.create
returns: a single behavior function representing the actions of each passed
[ Motion Behaviors ]
description:
The following behaviors generate motion for particles
usage: Created through create or multiple
returns: behavior functions
fall
description:
Falling motion behavior. Moves a movie clip down (or up) along the y axis
every frame with a speed yvelocity. Each frame yvelocity increases by gravity
usage:
ParticleBehavior.create("fall", {gravity:2, yvelocity:5});
parameters:
- gravity (Number) Optional; default: 1. Gravity property representing the amount added to the velocity each time the behavior is called
- yvelocity (Number) Optional; default: 0. Vertical velocity or the amount added to the behavior owner's _y property each time the behavior is called
returns: behavior function
slide
description:
Sliding motion behavior. Moves a movie clip in any direction with a speed based
on xvelocity and yvelocity. Each frame the velocities increase by x and y
increases (yvelocity is also increased by gravity) through an additive
process and are further affected by friction through a multiplication.
usage:
ParticleBehavior.create("slide", {xvelocity:1, xincrease:1, xfriction:.9});
parameters:
- xvelocity (Number) Optional; default: 0. Horizontal velocity or the amount added to the behavior owner's _x property each time the behavior is called
- yvelocity (Number) Optional; default: 0. Vertical velocity or the amount added to the behavior owner's _y property each time the behavior is called
- xincrease (Number) Optional; default: 0. The amount added to the xvelocity each time the behavior is called
- yincrease (Number) Optional; default: 0. The amount added to the yvelocity each time the behavior is called
- xfriction (Number) Optional; default: 1. The amount multiplied to the xvelocity each time the behavior is called
- yfriction (Number) Optional; default: 1. The amount multiplied to the yvelocity each time the behavior is called
- gravity (Number) Optional; default: 0. Gravity property representing the amount added to the yvelocity each time the behavior is called
returns: behavior function.
bounce
description:
Bouncing motion behavior (2D). Moves a movie clip in any direction with a speed
based on xvelocity and yvelocity. Each frame the velocities increase by x and y
increases (yvelocity is also increased by gravity) through an additive
process and are further affected by friction through a multiplication. When the
movie clip reaches the bounds, velocity is reversed creating a bounce.
usage:
ParticleBehavior.create("bounce", {xvelocity:20, yvelocity:2, xfriction:.8, bounds:myClip.getBounds()});
parameters:
- xvelocity (Number) Optional; default: 0. Horizontal velocity or the amount added to the behavior owner's _x property each time the behavior is called
- yvelocity (Number) Optional; default: 0. Vertical velocity or the amount added to the behavior owner's _y property each time the behavior is called
- xincrease (Number) Optional; default: 0. The amount added to the xvelocity each time the behavior is called
- yincrease (Number) Optional; default: 0. The amount added to the yvelocity each time the behavior is called
- xfriction (Number) Optional; default: 1. The amount multiplied to the xvelocity each time the behavior is called
- yfriction (Number) Optional; default: 1. The amount multiplied to the yvelocity each time the behavior is called
- gravity (Number) Optional; default: 0. Gravity property representing the amount added to the yvelocity each time the behavior is called
- bounds (Object) Optional; default: bounds of Stage. A bounds object (as given by getBounds) representing the area in which the movie clip will bounce
returns: behavior function.
bounce3D
description:
Bouncing motion behavior (3D). Moves a movie clip in any direction with a speed
based on xvelocity, yvelocity and zvelocity within 3D space. Each frame the velocities
increase by x, y, and z increases (yvelocity is also increased by gravity) through an additive
process and are further affected by friction through a multiplication. When the
movie clip reaches the bounds, velocity is reversed creating a bounce.
usage:
ParticleBehavior.create("bounce3D", {xvelocity:1, yvelocity:10, swap:true});
parameters:
- xvelocity (Number) Optional; default: 0. Horizontal velocity or the amount added to the behavior owner's x position in 3D space each time the behavior is called
- yvelocity (Number) Optional; default: 0. Vertical velocity or the amount added to the behavior owner's y position in 3D space each time the behavior is called
- zvelocity (Number) Optional; default: 0. Forward velocity or the amount added to the behavior owner's z position in 3D space each time the behavior is called
- xincrease (Number) Optional; default: 0. The amount added to the xvelocity each time the behavior is called
- yincrease (Number) Optional; default: 0. The amount added to the yvelocity each time the behavior is called
- zincrease (Number) Optional; default: 0. The amount added to the zvelocity each time the behavior is called
- xfriction (Number) Optional; default: 1. The amount multiplied to the xvelocity each time the behavior is called
- yfriction (Number) Optional; default: 1. The amount multiplied to the yvelocity each time the behavior is called
- zfriction (Number) Optional; default: 1. The amount multiplied to the zvelocity each time the behavior is called
- gravity (Number) Optional; default: 0. Gravity property representing the amount added to the yvelocity each time the behavior is called
- bounds (Object) Optional; default: infinity except 0 for minimum y. A bounds object (as given by getBounds) with additional zMin and zMax properties representing the area in which the movie clip will bounce in 3D space
- focallength (Number) Optional; default: 300. The focal length to be applied to the 3D view of particles
- swap (Boolean) Optional; default: false. Determines whether or not swapDepths is used to control the arrangement of movie clips using this behavior in the 3D space
returns: behavior function.
size
description:
Sizing behavior. Scales a movie clip.
usage:
ParticleBehavior.create("size", {xincrease:2, yincrease:2, use:"value"});
parameters:
- xincrease (Number) Optional; default: 0. Amount of increase for sizing the movie clip along its local x axis
- yincrease (Number) Optional; default: 0. Amount of increase for sizing the movie clip along its local y axis
- use (String) Optional; values: "percent", "value"; default: "percent". Determines whether the movie clip is scaled through percent ("percent") or through added numeric values ("value"). If not "percent", "value" is implied
returns: behavior function
transparency
description:
Transparency behavior. Fades a movie clip.
usage:
ParticleBehavior.create("transparency", {increase:-5});
parameters:
- increase (Number) Optional; default: 1. Gravity property representing the amount added to the velocity each time the behavior is called
- use (String) Optional; values: "percent", "value"; default: "percent". Determines whether the movie clip is scaled through percent ("percent") or through added numeric values ("value"). If not "percent", "value" is implied
returns: behavior function
repel
description:
Repelling motion behavior. Creates a behavior that causes a movie clip to repel
from a central location when a "repeller" (either the mouse or a movie clip) approches
usage:
ParticleBehavior.create("repel", {x:100, y:100, repeller:my_mc});
parameters:
- x (Number) Optional; default: current _x location. The origin x from which the movie clip is based and is repelled from
- y (Number) Optional; default: current _y location. The origin y from which the movie clip is based and is repelled from
- repeller (MovieClip, Mouse) Optional; default: Mouse. Object from which the clip is repelled. If not a MovieClip, then Mouse can be specified to be repelled from the mouse
- range (Number) Optional; default: 100. The range a which the repeller starts to repel the movie clip from it's origin
- acceleration (Number) Optional; default: .03. Acceleration factor for repelling movement
- friction (Number) Optional; default: .9. Friction factor for repelling movement
returns: behavior function
avoid
description:
Avoiding motion behavior. Creates a behavior that causes a movie clip to avoid
a movie clip or the mouse.
usage:
ParticleBehavior.create("avoid", {velocity:2, range:50, avoid:my_mc});
parameters:
- avoid (MovieClip, Mouse) Optional; default: Mouse. Object the clip is to avoid. If not a MovieClip, then Mouse can be specified to be avoided
- range (Number) Optional; default: 100. The range a which the movie clip starts to avoid the avoid object
- velocity (Number) Optional; default: 1. Speed at which the movie clip avoids the avoid object. When acceleration is involved, this is a max speed.
- acceleration (Number) Optional; default: 0. Acceleration factor for avoiding movement
- friction (Number) Optional; default: 0. Friction factor for avoiding movement
returns: behavior function
constrain
description:
Constraining behavior. Constrains a movieclip within a boundary.
usage:
ParticleBehavior.create("constrain", {bounds:my_mc.getBounds(), use:"bounds"});
parameters:
- bounds (Object) Optional; default: bounds of Stage. A bounds object (as given by getBounds) representing the area in which the movie clip will be constrained
- check (String) Optional; values: "bounds", "center"; default: "bounds". Determines what part of the movie clip is to be checked when constraining, the movie clip's bounds ("bounds") or its center point ("center"). If not "bounds", "center" is implied
returns: behavior function
[ Removal Behaviors ]
description:
The following behaviors are used to remove particles
usage: Created through create or multiple
returns: behavior functions
boundsRemove
description:
Removal behavior. Removes a movie clip if it is no longer within the specified bounds.
usage:
ParticleBehavior.create("boundsRemove", {bounds:my_mc.getBounds(), use:"bounds"});
parameters:
- bounds (Object) Optional; default: bounds of Stage. A bounds object (as given by getBounds) representing the area in which the movie clip will be constrained
- check (String) Optional; values: "bounds", "center"; default: "bounds". Determines what part of the movie clip is to be checked when constraining, the movie clip's bounds ("bounds") or its center point ("center"). If not "bounds", "center" is implied
returns: behavior function
timedRemove
description:
Removal behavior. Removes a movie clip after a specified time (ms).
usage:
ParticleBehavior.create("timedRemove", {time:3000});
parameters:
- time (Number) Optional; default: 1000. Time in milliseconds to wait before removing the clip. Removal will only occur when the behavior is called
returns: behavior function
framesRemove
description:
Removal behavior. Removes a movie clip after a specified frames.
usage:
ParticleBehavior.create("framesRemove", {frames:60});
parameters:
- frames (Number) Optional; default: 100. Number of frames to wait before removing the clip. Removal will only occur when the behavior is called
returns: behavior function
changeInPositionRemove
description:
Removal behavior. Removes a movie clip after a specified frames.
usage:
ParticleBehavior.create("changeInPositionRemove", {distance:100, check:"less"});
parameters:
- distance (Number) Optional; default: 10. Distance to check between the current location and the last recorded location
- check (String) Optional; values: "greater", "less"; default: "greater". Determines whether distance is checked to be greater than or less than the specified distance for removal. If not "greater", "less" is implied
returns: behavior function
distanceRemove
description:
Removal behavior. Removes a movie clip after its a certain distance from a point.
usage:
ParticleBehavior.create("distanceRemove", {x:50, y75, distance:50});
parameters:
- x (Number) Optional; default: current _x location. The origin x from which distance is to be checked
- y (Number) Optional; default: current _y location. The origin y from which distance is to be checked
- distance (Number) Optional; default: 100. Distance to check between the current location and the last recorded location
returns: behavior function
distanceTraveledRemove
description:
Removal behavior. Removes a movie clip after it has traveled a certain distance.
usage:
ParticleBehavior.create("distanceTraveledRemove", {distance:600});
parameters:
- distance (Number) Optional; default: 100. Distance traveled before removal
returns: behavior function
sizeRemove
description:
Removal behavior. Removes a movie clip after it reaches a certain size. Size is based on local coordinate space
usage:
ParticleBehavior.create("sizeRemove", {distance:600});
parameters:
- minwidth (Number) Optional; default: 1. The minimum width the movie clip can reach before removal
- minheight (Number) Optional; default: 1. The minimum height the movie clip can reach before removal
- maxwidth (Number) Optional; default: 100. The maximum width the movie clip can reach before removal
- maxheight (Number) Optional; default: 100. The maximum height the movie clip can reach before removal
- check (String) Optional; values: "both", "single"; default: "both". Determines whether or not both height and width are checked for removal. If not "both", "single" is implied
returns: behavior function