Flint Particle System Forum - Stopping or affecting an individual particle... 2011-12-11T10:51:01+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Stopping or affecting an individual particle... http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=943#Comment_943 2009-10-20T23:37:17+01:00 2009-10-20T23:41:23+01:00 ed http://flintparticles.org/forum/account.php?u=257 Pardon me if this has already been addressed. I've searched and read through many threads and haven't found a solution to this problem: Is there a way to stop or add LinearDrag to a particle when ...
Is there a way to stop or add LinearDrag to a particle when a user rolls over it? Anything I add to the emitter affects all the particles at once. If possible, how do I access each particle within the emitter?]]>
Stopping or affecting an individual particle... http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=951#Comment_951 2009-11-02T08:40:30+00:00 2009-11-02T08:41:52+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Hi Ed Note first that the renderers have their mouseChildren property set to false by default. To enable mouse events on the particles, you'll need to set the mouseChildren property of the ...
Note first that the renderers have their mouseChildren property set to false by default. To enable mouse events on the particles, you'll need to set the mouseChildren property of the renderer to true.

You access the particles through initializers or actions. If you added an initializer that set the MouseOver and MouseOut event handlers for all particles, that would give you the access you need. Something like this

package
{
public class ParticleRollover extends InitializerBase
{
private var _overHandler:Function;
private var _outHandler:Function;

public function ParticleRollover( overHandler:Function, outHandler:Function )
{
_overHandler = overHandler;
_outHandler = outHandler;
}

override public function addedToEmitter( emitter:Emitter ):void
{
emitter.addEventListener( ParticleEvent.PARTICLE_DEAD, removeListeners, false, 0, true );
}

override public function removedFromEmitter( emitter:Emitter ):void
{
emitter.removeEventListener( ParticleEvent.PARTICLE_DEAD, removeListeners );
}

private function removeListeners( event:ParticleEvent ):void
{
IEventDispatcher( event.particle.image ).removeEventListener( MouseEvent.MOUSE_OVER, _overHandler );
IEventDispatcher( event.particle.image ).removeEventListener( MouseEvent.MOUSE_OVER, _outHandler );
}

override public function initialize( emitter:Emitter, particle:Particle ):void
{
IEventDispatcher( particle.image ).addEventListener( MouseEvent.MOUSE_OVER, _overHandler, false, 0, true );
IEventDispatcher( particle.image ).addEventListener( MouseEvent.MOUSE_OUT, _outHandler, false, 0, true );
}
}
}
]]>
Stopping or affecting an individual particle... http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=1639#Comment_1639 2011-05-10T10:12:41+01:00 2011-12-11T10:51:01+00:00 mazwat http://flintparticles.org/forum/account.php?u=496 Hi Richard, I think Flint is a fabulous system and I am really just beginning to unlock it's potential. However I am struggling with some of the coding side of things. I too am looking to ...
I think Flint is a fabulous system and I am really just beginning to unlock it's potential. However I am struggling with some of the coding side of things.
I too am looking to implement the movement of individual particles, and I came across this post.
I have added this package that you have written above to my initializer base, But I am not sure about how to implement this as code in the main flash file.
Could you possibly give me some pointers. thanks]]>
Stopping or affecting an individual particle... http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=1640#Comment_1640 2011-05-12T08:48:48+01:00 2011-12-11T10:51:01+00:00 Richard http://flintparticles.org/forum/account.php?u=1 The class mentioned above has since been added to Flint's core initializers. The documentation is here. To use it, do something like this ... var mouseHandlers:MouseEventHandlers = new ... documentation is here. To use it, do something like this

...
var mouseHandlers:MouseEventHandlers = new MouseEventHandlers();
emitter.addInitializer( mouseHandlers );

renderer.mouseEnabled = true;
renderer.mouseChildren = true;

mouseHandlers.overHandler = onMouseOver;
mouseHandlers.outHandler = onMouseOut;

function onMouseOver( event:MouseEvent ) : void
{
...
}

function onMouseOut( event:MouseEvent ) : void
{
...
}


Also, you must use a DisplayObjectRenderer because that is the only renderer where particles are discrete objects with their own events.]]>