Flint Particle System Forum - Is there a way to target the individual particles2010-06-13T07:27:50+01:00http://flintparticles.org/forum/
Lussumo Vanilla & Feed Publisher
Is there a way to target the individual particleshttp://flintparticles.org/forum/comments.php?DiscussionID=116&Focus=475#Comment_4752008-11-05T05:58:30+00:002008-11-06T08:41:10+00:00Vhttp://flintparticles.org/forum/account.php?u=92
Hi there Richard,
I don't even attempt to match up to the level of praise that is already been displayed on this forum - I think it is an awesome job. (My first guess - this poor man must have ...
I don't even attempt to match up to the level of praise that is already been displayed on this forum - I think it is an awesome job. (My first guess - this poor man must have been put to bed with 2 broken legs and since he couldn't sleep with the agonising pain he decided to put his days and sleepless nights to good use instead.)
We are trying here to build a bit of a tag cloud using Flint particles. Nothing overly advanced, just a few items (instances of a movie clip from a library) floating around the stage. Where we kind of run into the wall is targeting the individual particles. The effect that we're after is that when rolling over any of the particles the animation would stop and we could reveal whatever is in our movie clip instance. This is the first step. Then we are also planning to pass specific information to each of the particles (title, URL link, etc.) that is dynamically drawn from a database. Well kind of like a regular tag cloud with some nice animation really.
We are able to trace out the individual objects that are created by the emitter, but we just can't seem to find the way of adding event listeners to them. What advice would you have about targeting the particles? I don't know if it helps you, I will add the bit of code here on the bottom. Would love to hear if you have any thoughts.
private var emitter:Emitter2D = new Emitter2D(); private var renderer:DisplayObjectRenderer = new DisplayObjectRenderer(); private var imgClassTag:ImageClass = new ImageClass( Tag ); private var zone:RectangleZone = new RectangleZone(10, 10, 470, 390 ); private var position:Position = new Position( zone ); private var zone2:DiscZone = new DiscZone( new Point( 0, 0 ), 50, 5 ); private var velocity:Velocity = new Velocity( zone2 ); private var move:Move = new Move(); private var boundingBox:BoundingBox = new BoundingBox( 10, 10, 470, 390, 1 );
emitter.counter = new Blast( 20); emitter.addInitializer( imgClassTag ); emitter.addInitializer( position ); emitter.addInitializer( velocity ); emitter.addAction( move ); emitter.addAction( boundingBox); emitter.start();
for(var i:uint; i]]>
Is there a way to target the individual particleshttp://flintparticles.org/forum/comments.php?DiscussionID=116&Focus=476#Comment_4762008-11-05T06:00:38+00:002008-11-06T08:41:47+00:00Vhttp://flintparticles.org/forum/account.php?u=92
Sorry, I don't think the code fitted in - too much blabbering from my side. Hope you don't mind if I try pasting again.
public class Main extends MovieClip{
private var emitter:Emitter2D = ...
public class Main extends MovieClip{
private var emitter:Emitter2D = new Emitter2D(); private var renderer:DisplayObjectRenderer = new DisplayObjectRenderer(); private var imgClassTag:ImageClass = new ImageClass( Tag ); private var zone:RectangleZone = new RectangleZone(10, 10, 470, 390 ); private var position:Position = new Position( zone ); private var zone2:DiscZone = new DiscZone( new Point( 0, 0 ), 50, 5 ); private var velocity:Velocity = new Velocity( zone2 ); private var move:Move = new Move(); private var boundingBox:BoundingBox = new BoundingBox( 10, 10, 470, 390, 1 );
emitter.counter = new Blast( 20); emitter.addInitializer( imgClassTag ); emitter.addInitializer( position ); emitter.addInitializer( velocity ); emitter.addAction( move ); emitter.addAction( boundingBox); emitter.start();
for(var i:uint; i<renderer.numChildren; i++){ //I can trace out the individual objects that are created by emitter trace(renderer.getChildAt(i).name) //But I can't add an event listener to them. How can I target the individual particles? renderer.getChildAt(i).addEventListener(MouseEvent.MOUSE_OVER, pauseParticles);
}
}
private function pauseParticles(evt:MouseEvent):void{ emitter.removeAction(move); }
}]]>
Is there a way to target the individual particleshttp://flintparticles.org/forum/comments.php?DiscussionID=116&Focus=479#Comment_4792008-11-06T08:53:10+00:002008-11-06T08:54:41+00:00Richardhttp://flintparticles.org/forum/account.php?u=1
Fortunately, I haven't broken both my legs. It's rather a case of having to commute to a client's every day for the first few months of this year, with only an tiny eeepc running FDT to keep me ...
eeepc running FDT to keep me company on the journey. I needed something to do during all the travelling, so I wrote Flint.
Your code didn't display because you were posting the message as html and it fell over on the less-than symbol. I fixed it in your second post by wrapping the code inside <code> elements.
As for your main problem. Because people don't usually want to respond to mouse events on the particles, the renderer has both mouseEnabled and mouseChildren set to false. If you set these to true for your renderer, you should be able to listen to mouse events on the particles.