Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
How do I?: Need help using using displayOjbectZone as velocity with a movieclip
Bottom of Page1 to 3 of 3
-
- CommentAuthorfate0000
- CommentTimeApr 14th 2010
My ultimate goal is to have particles originate from a location and fill in the area specified by an instance of a movieclip that currently resides on my stage. I started off with the snow example and am attempting to convert my velocity zone to into the movieclip on my stage, but perhaps that isn't the right way of going about reaching my goal. This is what I've tried so far:
import flash.geom.Point;
import flash.display.DisplayObject;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.RadialDot;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;
//Emitter emits particles
var emitter:Emitter2D = new Emitter2D();
//Emitter needs a renderer to draw the particles
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
//Renderer is a display object so we create it and add it to the stage
addChild( renderer );
//Add emitter to renderer
renderer.addEmitter( emitter );
//Tells how the emitter emits particles. In this case its a steady stream of 100 particles.
emitter.counter = new Steady( 100 );
//This is the image that is going to be the base for our particle.
var imgClass:ImageClass = new ImageClass( RadialDot, 2 );
//Add our image to the emitter
emitter.addInitializer( imgClass );
emitter.addInitializer( new Lifetime( 6 ) );
//Create a line zone above the scene. This is where the particles will emit from.
var zone:LineZone = new LineZone( new Point( -5, -5 ), new Point( 505, -5 ) );
//Create a position and add the zone to the position
var position:Position = new Position( zone );
//Add the position to the emitter.
emitter.addInitializer( position );
//Velocity is specified as a zone, or a place that the particle arrives at in one second.
var zone2:DisplayObjectZone = new DisplayObjectZone(this.ouidooLogo);
var velocity:Velocity = new Velocity( zone2 );
emitter.addInitializer( velocity );
//Takes care of the particles movement after initialization.
var move:Move = new Move();
emitter.addAction( move );
//Start the emitter!
emitter.start();
It seems to be generating particles, but they are not able to get the location of my movie clip it seems as I'm receiving the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at org.flintparticles.twoD.zones::DisplayObjectZone/getLocation()
at org.flintparticles.twoD.initializers::Velocity/initialize()
at org.flintparticles.common.emitters::Emitter/createParticle()
at org.flintparticles.common.emitters::Emitter/update()
at org.flintparticles.common.emitters::Emitter/updateEventListener()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.flintparticles.common.utils::FrameUpdater/frameUpdate()
Any help on how I can get my particles to "land" on my movieclip would be greatly appreciated.
Thank you for looking! -
- CommentAuthorfate0000
- CommentTimeApr 14th 2010
I cleared up a few things for myself and got my desired effect with the following code. One of my biggest problems was that I didn't specify the render in the displayobjectzone declaration. :
import flash.geom.Point;
import flash.display.DisplayObject;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.RadialDot;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.energyEasing.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;
//Emitter emits particles
var emitter:Emitter2D = new Emitter2D();
//Emitter needs a renderer to draw the particles
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
//Renderer is a display object so we create it and add it to the stage
addChild( renderer );
//Add emitter to renderer
renderer.addEmitter( emitter );
//Tells how the emitter emits particles. In this case its a steady stream of 100 particles.
emitter.counter = new Steady( 100 );
//This is the image that is going to be the base for our particle.
var imgClass:ImageClass = new ImageClass( RadialDot, 2 );
//Add our image to the emitter
emitter.addInitializer( imgClass );
emitter.addInitializer( new Lifetime( 6 ) );
//Create a line zone above the scene. This is where the particles will emit from.
var zone:LineZone = new LineZone( new Point( -5, -5 ), new Point( 505, -5 ) );
//Create a position and add the zone to the position
var position:Position = new Position( zone );
//Add the position to the emitter.
emitter.addInitializer( position );
//specify easing
var easing:Function = Cubic.easeInOut;
//Takes care of the particles movement after initialization.
emitter.addAction(new Age(easing));
emitter.addAction(new TweenToZone(new DisplayObjectZone(this.ouidooLogo, renderer)));
//Start the emitter!
emitter.start(); -
- CommentAuthorRichard
- CommentTimeApr 17th 2010
To get the particles to fill in the area of your display object, you may be better off using a TweenToZone action.
1 to 3 of 3
