Flint Particle System Forum - about MouseEvent 2011-12-13T03:30:29+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1339#Comment_1339 2010-09-13T15:38:11+01:00 2010-09-13T15:38:39+01:00 RobC http://flintparticles.org/forum/account.php?u=407 Hi, exscuse for my English, I have this problem: I want to add a MouseEvent in this simple code just to trigger the particles movement: [SWF(width="500", height="500", ... I have this problem: I want to add a MouseEvent in this simple code just to trigger the particles movement:


[SWF(width="500", height="500", frameRate="60", backgroundColor="#000000")]

var emitter:Emitter2D = new Emitter2D();
var render:BitmapRenderer = new BitmapRenderer(new Rectangle(0, 0, 500, 500), true);

emitter.counter = new Blast(50);

emitter.addInitializer(new SharedImage(new RadialDot(4)));
emitter.addInitializer(new ColorInit(0xFF00FF00, 0x0000FFFF));
emitter.addInitializer(new Position(new RectangleZone(0, 0, 500, 500)));

emitter.addEventListener(MouseEvent.CLICK, movement);

function movement(e:MouseEvent) {
emitter.addInitializer(new Velocity(new RectangleZone(20, 0, 0, 20)));
emitter.addAction(new Move());
}

render.addEmitter(emitter);
addChild(render);

emitter.start();

I know that this addEventListener does nothing but I would know what is the right way.
Thank!]]>
about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1350#Comment_1350 2010-09-14T21:14:06+01:00 2011-12-13T03:30:29+00:00 Ubuntu http://flintparticles.org/forum/account.php?u=387 I guess this does not work because the emitter is not a clickable sprite or movieclip. If you want this to work when you click anywhere on the stage then try ...
stage.addEventListener(MouseEvent.CLICK, movement);]]>
about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1354#Comment_1354 2010-09-16T08:49:15+01:00 2011-12-13T03:30:29+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Exactly. Use any clickable object to trigger the event, including the stage. The emitter is not clickable. The particles can be made clickable - render.mouseEnabled = ...
The particles can be made clickable -

render.mouseEnabled = true;
render.mouseChildren = true;
render.addEventListener(MouseEvent.CLICK, movement);
]]>
about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1356#Comment_1356 2010-09-16T09:41:19+01:00 2010-09-16T09:54:34+01:00 RobC http://flintparticles.org/forum/account.php?u=407 Thank guys! But I tried with this code and nothing happens: render.mouseEnabled = true; render.mouseChildren = true; render.addEventListener(MouseEvent.CLICK, movement); function ...
render.mouseEnabled = true;
render.mouseChildren = true;

render.addEventListener(MouseEvent.CLICK, movement);

function movement(e:MouseEvent) {
emitter.addInitializer(new Velocity(new RectangleZone(20, 0, 0, 20)));
emitter.addAction(new Move());
}


I don't understand why....]]>
about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1357#Comment_1357 2010-09-16T10:10:43+01:00 2011-12-13T03:30:29+00:00 RobC http://flintparticles.org/forum/account.php?u=407 Ok, I understand that I have to put the emitter.start() inside the function but, in this way, before the click there arent any particles on the stage. What I want, if possible, is to start the ... emitter.start() inside the function but, in this way, before the click there arent any particles on the stage.
What I want, if possible, is to start the movement of the particles when they are just on the stage....]]>
about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1359#Comment_1359 2010-09-16T11:56:07+01:00 2011-12-13T03:30:29+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Don't put the emitter.start() inside the function, but do put the emitter.addAction(new Move()) inside it. The particles won't move until you add this action to the emitter. about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1362#Comment_1362 2010-09-16T16:19:54+01:00 2011-12-13T03:30:29+00:00 RobC http://flintparticles.org/forum/account.php?u=407 I tried to leave out the function emitter.start() and just put the emitter.addAction(new Move()) inside it (like the example in my post before) but the particles doesn't move after the click. about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1363#Comment_1363 2010-09-17T07:13:47+01:00 2011-12-13T03:30:29+00:00 Richard http://flintparticles.org/forum/account.php?u=1 In your previous example, you should move the velocity initializer out of the function. Basically, you set the emitter up with all its initializers, including velocity. Then you start it, causing the ... about MouseEvent http://flintparticles.org/forum/comments.php?DiscussionID=396&Focus=1364#Comment_1364 2010-09-17T12:17:42+01:00 2011-12-13T03:30:29+00:00 RobC http://flintparticles.org/forum/account.php?u=407 Really thank you Richard! Now is all ok, very good explanation! Now is all ok, very good explanation!]]>