Flint Particle System Forum - Features 2011-12-11T10:31:49+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1509#Comment_1509 2011-01-14T14:53:26+00:00 2011-12-11T10:31:49+00:00 FlashDev2007 http://flintparticles.org/forum/account.php?u=460 Apologies for not trawling the forum for answers, I thought this would be an easy one for people familiar with Flint to answer. I would really like to use Flint for an animation that I need to ...
1. Can I create particles from any display object I create, eg. some bubbles that open up with text in when I click them?
2. Is it possible to make certain particles get attracted to one I click on?
3. Can you change the movement behaviour at runtime?

Many thanks,

Neil]]>
Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1510#Comment_1510 2011-01-16T18:17:22+00:00 2011-12-11T10:31:49+00:00 FlashDev2007 http://flintparticles.org/forum/account.php?u=460 Ok, so I had some time today and I went through the forum posts and I have answers to my first two questions, i'll get to number 3 when I get the chance. I seem to be getting two click events ...
Any ideas?


package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;

import org.flintparticles.common.counters.Blast;
import org.flintparticles.common.displayObjects.Star;
import org.flintparticles.common.initializers.CollisionRadiusInit;
import org.flintparticles.common.initializers.ImageClass;
import org.flintparticles.common.initializers.MassInit;
import org.flintparticles.twoD.actions.BoundingBox;
import org.flintparticles.twoD.actions.Collide;
import org.flintparticles.twoD.actions.Move;
import org.flintparticles.twoD.actions.Rotate;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.Position;
import org.flintparticles.twoD.initializers.RotateVelocity;
import org.flintparticles.twoD.initializers.Velocity;
import org.flintparticles.twoD.renderers.DisplayObjectRenderer;
import org.flintparticles.twoD.zones.DiscZone;
import org.flintparticles.twoD.zones.RectangleZone;

[SWF (backgroundColor="#000000")]
public class FlintTest extends Sprite
{
protected static const PARTICLE_COUNT:int = 25;
protected var emitter:Emitter2D;

public function FlintTest()
{
emitter = new Emitter2D();
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
renderer.mouseChildren = true;
renderer.mouseEnabled = true;
renderer.addEventListener(MouseEvent.CLICK, clickHandler);
renderer.addEmitter(emitter);
addChild(renderer);

emitter.counter = new Blast(PARTICLE_COUNT);
emitter.addInitializer(new Position(new RectangleZone(0,0,stage.stageWidth, stage.stageHeight)));
emitter.addInitializer(new ImageClass(MyParticle));

var zone:DiscZone = new DiscZone(new Point(0, -50), 100, 10);
emitter.addInitializer(new Velocity(zone));
emitter.addInitializer(new CollisionRadiusInit(20));
emitter.addInitializer(new MassInit(Math.random()*0.1));
emitter.addInitializer( new RotateVelocity(-Math.PI / 2, Math.PI / 2));

emitter.addAction(new Move());
emitter.addAction(new BoundingBox(0,0,stage.stageWidth, stage.stageHeight));
emitter.addAction(new Collide());
emitter.addAction(new Rotate());
emitter.start();

for(var i:int = 0; i < renderer.numChildren; i++)
{
var particle:Sprite = Sprite(renderer.getChildAt(i));
particle.useHandCursor = true;
particle.buttonMode = true;
particle.addEventListener(MouseEvent.CLICK, clickHandler);
}
}

protected function clickHandler(event:MouseEvent):void
{
trace("clicked: " + event.target.name)
}
}
}
]]>
Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1515#Comment_1515 2011-01-18T03:25:01+00:00 2011-12-11T10:31:49+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Your listening for clicks on both the particles and the renderer. That's why you receive two click events. You need only listen on one of these. You can modify behaviour at runtime by either 1. ...
You can modify behaviour at runtime by either

1. adding and removing actions from/to the emitter to change the behaviour.
2. using an action that alters its behaviour dynamically (writing your own actions is not hard - look in the source code of a few of the included actions for clues).

Richard]]>
Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1517#Comment_1517 2011-01-18T14:32:04+00:00 2011-01-18T14:32:16+00:00 FlashDev2007 http://flintparticles.org/forum/account.php?u=460 Thanks for the reply Richard, I created a custom action to check if there is a listener attached or not, and adds one if needed. The current example I'm working on now uses a SineCounter so I would ...
Neil]]>
Features http://flintparticles.org/forum/comments.php?DiscussionID=446&Focus=1518#Comment_1518 2011-01-18T14:43:01+00:00 2011-12-11T10:31:49+00:00 FlashDev2007 http://flintparticles.org/forum/account.php?u=460 Apologies for not reading the docs more thoroughly, I found ParticleEvent.PARTICLE_DEAD. Cheers
Cheers]]>