Flint Particle System Forum - Stopping or affecting an individual particle... Sun, 11 Dec 2011 10:29:44 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Stopping or affecting an individual particle... http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=943#Comment_943 http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=943#Comment_943 Tue, 20 Oct 2009 23:37:17 +0100 ed
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 http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=951#Comment_951 Mon, 02 Nov 2009 08:40:30 +0000 Richard
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 http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=1639#Comment_1639 Tue, 10 May 2011 10:12:41 +0100 mazwat
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 http://flintparticles.org/forum/comments.php?DiscussionID=265&Focus=1640#Comment_1640 Thu, 12 May 2011 08:48:48 +0100 Richard 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. ]]>