Flint Particle System Forum - Mouse Events Not Triggering Thu, 23 Jun 2011 13:40:21 +0100 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=43#Comment_43 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=43#Comment_43 Mon, 07 Apr 2008 19:13:21 +0100 pyiap Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=44#Comment_44 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=44#Comment_44 Mon, 07 Apr 2008 20:24:42 +0100 ericr capture the events? ]]> Mouse Events Not Triggering http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=45#Comment_45 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=45#Comment_45 Mon, 07 Apr 2008 21:28:07 +0100 pyiap
-> 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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=47#Comment_47 Tue, 08 Apr 2008 09:09:35 +0100 Richard
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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=50#Comment_50 Tue, 08 Apr 2008 17:45:44 +0100 ericr 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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=51#Comment_51 Tue, 08 Apr 2008 20:28:29 +0100 pyiap 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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=52#Comment_52 Tue, 08 Apr 2008 20:57:39 +0100 ericr 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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=53#Comment_53 Tue, 08 Apr 2008 21:16:32 +0100 ericr @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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=54#Comment_54 Tue, 08 Apr 2008 21:56:38 +0100 pyiap
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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=55#Comment_55 Tue, 08 Apr 2008 22:11:16 +0100 ericr
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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=56#Comment_56 Wed, 09 Apr 2008 08:28:57 +0100 Richard 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 http://flintparticles.org/forum/comments.php?DiscussionID=14&Focus=60#Comment_60 Wed, 09 Apr 2008 15:31:18 +0100 ericr @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? ]]>