Flint Particle System Forum - Mouse Events Not Triggering 2011-06-23T17:07:10+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=43#Comment_43 2008-04-07T19:13:21+01:00 2008-05-20T10:11:18+01:00 pyiap http://flintparticles.org/forum/account.php?u=19 I'm tying to integrate the particle system into a game I've been working on and I've run into an issue with mouse events. I've created a new class that extends a MovieClip which manages emitters. A ... Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=44#Comment_44 2008-04-07T20:24:42+01:00 2011-06-23T17:07:10+01:00 ericr http://flintparticles.org/forum/account.php?u=17 What layer is it that's "between" the working and not working layers? Does that layer's MouseEvent handler capture the events? capture the events?]]> Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=45#Comment_45 2008-04-07T21:28:07+01:00 2008-04-07T21:30:12+01:00 pyiap http://flintparticles.org/forum/account.php?u=19 Here's an example of what the stage looks like -> particle place holder layer movieclip (basically an empty movieclip object) ----> particle manager movieclip object ---------> ...
-> particle place holder layer movieclip (basically an empty movieclip object)
----> particle manager movieclip object
---------> particles are physically added here
-> mouse handler layer place holder movieclip
----> movieclip with mouse event handlers

If i swap the particle place holder layer with the mouse handler layer mouse events are captured. So in essence I can only capture mouseEvents if the particles are layered below any layers that need to trigger them.

Here's a project example
http://students.washington.edu/pyiap/ParticleLayer.zip
http://students.washington.edu/pyiap/WorkingProject.swf
http://students.washington.edu/pyiap/NotWorking.swf

In the example, the test image in the center of the screen should turn blue on the MouseOver event. The only difference between the working and not working swf is the layering order.]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=47#Comment_47 2008-04-08T09:09:35+01:00 2011-06-23T17:07:10+01:00 Richard http://flintparticles.org/forum/account.php?u=1 The BitmapRenderer creates a Bitmap object in which to draw the particles. When the Renderer is above your button the BitmapRenderer will receive the mouse events rather than your button. The ...
package
{
import flash.display.MovieClip;
import flash.events.Event;

public class myButton extends MovieClip
{
public var over:Boolean = false;

public function myButton()
{
mcOver.visible = false;
addEventListener(Event.ENTER_FRAME, myButtonTest);
}

public function myButtonTest( event:Event ):void
{
var newOver:Boolean = mcOn.hitTestPoint( stage.mouseX, stage.mouseY, true );
if( newOver != over )
{
over = newOver;
if( over )
{
myButtonOver();
}
else
{
myButtonOut();
}
}
}

public function myButtonOver():void
{
mcOver.visible = true;
mcOn.visible = false;
}

public function myButtonOut():void
{
mcOver.visible = false;
mcOn.visible = true;
}
}
}
]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=50#Comment_50 2008-04-08T17:45:44+01:00 2011-06-23T17:07:10+01:00 ericr http://flintparticles.org/forum/account.php?u=17 The other thing to do is make sure that all of your MovieClips have the appropriate enabled settings. Also, look at this: Additionally, consider whether you want the children of your sprite to ... enabled settings.

Also, look at this:

Additionally, consider whether you want the children of your sprite to be mouse enabled. Most buttons do not enable mouse interactivity for their child objects because it confuses the event flow. To disable mouse interactivity for all child objects, you must set the mouseChildren property (inherited from the DisplayObjectContainer class) to false.

The above is from the Sprite->buttonMode explanation. Check out the DisplayObjectContainer->mouseChildren information. I find that Adobe's "Default" values don't always play out as such. Try setting this explicitly yourself and see if it helps.

The scenario mentioned by Robert would only occur if the BitmapRenderer was set to Capture the mouse events. It may be set to do so by default (something may get confused in the creation of new objects within the BitmapRenderer definition). Read up on Flash's Event Flow. Also, make sure that you have the MouseEvents registered with the appropriate MouseHandler object and not the BitmapRenderer.

Sweet.]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=51#Comment_51 2008-04-08T20:28:29+01:00 2008-04-08T20:29:07+01:00 pyiap http://flintparticles.org/forum/account.php?u=19 Thanks for the replies. I've tried setting the enabled, buttonMode, and mouseChildren properties on every different level I could do (place holder movieclip, manager movieclip, even inside the ... I've tried setting the enabled, buttonMode, and mouseChildren properties on every different level I could do (place holder movieclip, manager movieclip, even inside the BitmapRenderer class) and the mouse events still doesn't seem to register. I've also tried explicitly setting those values to true for the movieclips that need to them to be. Though adding the ENTER_FRAME event and checking the state of the mouse would solve the issue, it seems very inefficient to add that to all the interactive objects within the game.

I'm not very familiar with the inner workings of flash, but I'm don't understand why the bitmap object would capture mouse events since it can't dispatch mouse events, even when you disable the container class from receiving mouse events.
Bitmap]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=52#Comment_52 2008-04-08T20:57:39+01:00 2008-04-08T21:17:36+01:00 ericr http://flintparticles.org/forum/account.php?u=17 I'm not very familiar with the inner workings of flash, but I'm don't understand why the bitmap object would capture mouse events since it can't dispatch mouse events, even when you disable the ... I'm not very familiar with the inner workings of flash, but I'm don't understand why the bitmap object would capture mouse events since it can't dispatch mouse events, even when you disable the container class from receiving mouse events.
I see your point. The BitmapRenderer is, however, a Sprite (via inheritance). That's what I meant to check out :)

As for the rest of it, how exactly are you adding all of these to the scene? There may be something wrong with the way you're defining stuff such that your mouseHandler layer look like Child2Node in the diagrams in the Event Flow documentation.

I.e. by this:
-> particle place holder layer movieclip (basically an empty movieclip object)
----> particle manager movieclip object
---------> particles are physically added here
-> mouse handler layer place holder movieclip
----> movieclip with mouse event handlers

do you mean this:
// Particle stuff.
particlePlaceHolder:MovieClip;
Stage.addChild(particlePlaceHolder);

particleManager:MovieClip;
particlePlaceHolder.addChild(particleManager);

particles:SomeRenderer;
particleManager.addChild(particles);

// Mouse stuff.
mouseLayer:MovieClip;
Stage.addChild(mouseLayer);

mouseEventHandlers:MovieClip;
mouseLayer.addChild(mouseEventHandlers);

mouseEventHandlers.addEventListener(MouseEvent:UP, mouseUpfunction);
// etc.

Does your code look like that? What's added to what? If it does look like that than I have to say that you've got a lot of [expensive] wasted objects. For instance, the entire mouseLayer architecture could be redundant because particlePlaceHolder is a MovieClip and can thus receive Mouse Events.

Also note that, provided you're using the default BitmapRenderer, the Sprite you define by using the BitmapRenderer code is immediately resized to the size of the Stage. If you don't have the mouseLayer directly between the Stage and the BitmapRenderer in the Event Flow structure and your BitmapRenderer is above the MouseHandler then you're not going to receive any messages anywhere. You'll be looking at the "Child2 Node" scenario from the Event Flow docs.

How are you calling all of the addChild() calls? Can you post them all?

Before you respond to this, see the next post.]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=53#Comment_53 2008-04-08T21:16:32+01:00 2008-04-08T21:17:08+01:00 ericr http://flintparticles.org/forum/account.php?u=17 @Richard: The way I would do it would be: 1) In a simple project, use the Stage for handling mouse events.In a complex project, explicitly turn off Mouse Event handling in the WhateverRenderer ... @Richard:
The way I would do it would be:
  1. 1) In a simple project, use the Stage for handling mouse events.
  2. In a complex project, explicitly turn off Mouse Event handling in the WhateverRenderer object and then add the particle emitter in the right event flow space (depends on project).


@pyiap:
Come to think of it, did you ever try explicitly turning those values off for the BitmapRenderer? I bet that's the problem. By removing that object from the Mouse Handling code it allows the mouse to 'go through' it. Try something like:
particlePlaceHolder.mouseEnabled = false;
particlePlaceHolder.mouseChildren = false;

Where particlePlaceHolder is the object you add to the Stage and into which you add the ParticleManager and whatever.

The above code explicitly disables MouseEvents for the objects - the clicks should go right through.]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=54#Comment_54 2008-04-08T21:56:38+01:00 2011-06-23T17:07:10+01:00 pyiap http://flintparticles.org/forum/account.php?u=19 Wow thanks. particlePlaceHolder.mouseEnabled = false; particlePlaceHolder.mouseChildren = false; did the trick. I was calling particlePlaceHolder.enabled = ...
particlePlaceHolder.mouseEnabled = false;
particlePlaceHolder.mouseChildren = false;

did the trick.

I was calling

particlePlaceHolder.enabled = false;
particlePlaceHolder.mouseChildren = false;


Also I'm really digging the particle system. Keep up the great work you're doing.]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=55#Comment_55 2008-04-08T22:11:16+01:00 2011-06-23T17:07:10+01:00 ericr http://flintparticles.org/forum/account.php?u=17 Nice, glad you got everything worked out! Definitely props to Richard for his work on Flint. Such a fantastic resource!
Definitely props to Richard for his work on Flint. Such a fantastic resource!]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=56#Comment_56 2008-04-09T08:28:57+01:00 2011-06-23T17:07:10+01:00 Richard http://flintparticles.org/forum/account.php?u=1 renderer.mouseEnabled = false; is definitely better than my long winded solution. I thought there should be a property like this and hoped someone would find it for me. Now I'm wondering if this ... renderer.mouseEnabled = false;

is definitely better than my long winded solution. I thought there should be a property like this and hoped someone would find it for me. Now I'm wondering if this should be the default setting for renderers. What's your opinion on this?]]>
Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=60#Comment_60 2008-04-09T15:31:18+01:00 2011-06-23T17:07:10+01:00 ericr http://flintparticles.org/forum/account.php?u=17 @Richard: I definitely agree with that sentiment. If someone wants to interact directly with the particles (and not with, say, something they're mounted to) then they should specify that. Perhaps ... @Richard:
I definitely agree with that sentiment. If someone wants to interact directly with the particles (and not with, say, something they're mounted to) then they should specify that. Perhaps you could set it as such and then toss up a note in the ASDocs?]]>