flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled

theRemix
I have a Sprite that contains a text field which displays points  
earned that is added above all other elements in a game that i'm  
creating.

this sprite is obstructing the MouseEvent listeners on game objects  
'below' it.

i set flash.display.DisplayObjectContainer.mouseChildren and  
flash.display.InteractiveObject.mouseEnabled to = false; on the points  
display sprite. this doesn't help 'mute' the display object, or allow  
the mouse to trigger the MouseEvents on the display objects 'below' it.

what is the proper way, or is there a trick to doing this?

tia

-+> theRemix


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled

gershon
sounds like you need to set the mouseEnabled=false for the TextField.
can also try "ignoring" with if(e.target==tf) return; in the event callback.
hope that helps.


On Fri, Aug 21, 2009 at 1:00 AM, theRemix <[hidden email]> wrote:
I have a Sprite that contains a text field which displays points earned that is added above all other elements in a game that i'm creating.

this sprite is obstructing the MouseEvent listeners on game objects 'below' it.

i set flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled to = false; on the points display sprite. this doesn't help 'mute' the display object, or allow the mouse to trigger the MouseEvents on the display objects 'below' it.

what is the proper way, or is there a trick to doing this?

tia

-+> theRemix


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled

theRemix

-+> theRemix

On Aug 20, 2009, at 12:15 PM, gershon wrote:

sounds like you need to set the mouseEnabled=false for the TextField.

DisplayObjectContainer.mouseChildren *should* handle this for me. it doesn't seem like it is.

can also try "ignoring" with if(e.target==tf) return; in the event callback.

thanks for the tip. i don't totally understand though. can you show me an example

var game_sprite:Sprite = new Sprite(); // pretend there's stuff in here
var point_sprite:Sprite = new Sprite();
var point_txt:TextField = new TextField(); // pretend there's text in here and all that

var point_sprite.addChild(point_txt);

game_sprite.addEventListener(MouseEvent.MOUSE_OVER, mouse_over_game_sprite);

private function mouse_over_game_sprite(_):Void
{
     // Does not trigger because point_sprite is above game_sprite
    trace("u wont see me");
}


how do i ignore? and in which event callback?

thanks,


hope that helps.


On Fri, Aug 21, 2009 at 1:00 AM, theRemix <[hidden email]> wrote:
I have a Sprite that contains a text field which displays points earned that is added above all other elements in a game that i'm creating.

this sprite is obstructing the MouseEvent listeners on game objects 'below' it.

i set flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled to = false; on the points display sprite. this doesn't help 'mute' the display object, or allow the mouse to trigger the MouseEvents on the display objects 'below' it.

what is the proper way, or is there a trick to doing this?

tia

-+> theRemix


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled

gershon
game_sprite.mouseChildren=false;
point_txt.mouseEnabled=point_txt.selectable=false;

either should do the trick i think...

about the callback:

private function mouse_over_game_sprite(e:MouseEvent):Void
{
if(Std.is(e.target, TextField) || e.target==point_txt || this.contains(e.target) || e.target!=this || e.target!=e.currentTarget)
    return;

trace("me u should see.");
}

e.target is the object currently hovered over, e.currentTarget is the object who's assigned the listener.



On Fri, Aug 21, 2009 at 1:26 AM, theRemix <[hidden email]> wrote:

-+> theRemix

On Aug 20, 2009, at 12:15 PM, gershon wrote:

sounds like you need to set the mouseEnabled=false for the TextField.

DisplayObjectContainer.mouseChildren *should* handle this for me. it doesn't seem like it is.

can also try "ignoring" with if(e.target==tf) return; in the event callback.

thanks for the tip. i don't totally understand though. can you show me an example

var game_sprite:Sprite = new Sprite(); // pretend there's stuff in here
var point_sprite:Sprite = new Sprite();
var point_txt:TextField = new TextField(); // pretend there's text in here and all that

var point_sprite.addChild(point_txt);

game_sprite.addEventListener(MouseEvent.MOUSE_OVER, mouse_over_game_sprite);

private function mouse_over_game_sprite(_):Void
{
     // Does not trigger because point_sprite is above game_sprite
    trace("u wont see me");
}


how do i ignore? and in which event callback?

thanks,


hope that helps.


On Fri, Aug 21, 2009 at 1:00 AM, theRemix <[hidden email]> wrote:
I have a Sprite that contains a text field which displays points earned that is added above all other elements in a game that i'm creating.

this sprite is obstructing the MouseEvent listeners on game objects 'below' it.

i set flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled to = false; on the points display sprite. this doesn't help 'mute' the display object, or allow the mouse to trigger the MouseEvents on the display objects 'below' it.

what is the proper way, or is there a trick to doing this?

tia

-+> theRemix


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled

theRemix
thanks, i'll give it a try.



-+> theRemix

On Aug 20, 2009, at 2:10 PM, gershon wrote:

game_sprite.mouseChildren=false;
point_txt.mouseEnabled=point_txt.selectable=false;

either should do the trick i think...

about the callback:

private function mouse_over_game_sprite(e:MouseEvent):Void
{
if(Std.is(e.target, TextField) || e.target==point_txt || this.contains(e.target) || e.target!=this || e.target!=e.currentTarget)
    return;

trace("me u should see.");
}

e.target is the object currently hovered over, e.currentTarget is the object who's assigned the listener.



On Fri, Aug 21, 2009 at 1:26 AM, theRemix <[hidden email]> wrote:

-+> theRemix

On Aug 20, 2009, at 12:15 PM, gershon wrote:

sounds like you need to set the mouseEnabled=false for the TextField.

DisplayObjectContainer.mouseChildren *should* handle this for me. it doesn't seem like it is.

can also try "ignoring" with if(e.target==tf) return; in the event callback.

thanks for the tip. i don't totally understand though. can you show me an example

var game_sprite:Sprite = new Sprite(); // pretend there's stuff in here
var point_sprite:Sprite = new Sprite();
var point_txt:TextField = new TextField(); // pretend there's text in here and all that

var point_sprite.addChild(point_txt);

game_sprite.addEventListener(MouseEvent.MOUSE_OVER, mouse_over_game_sprite);

private function mouse_over_game_sprite(_):Void
{
     // Does not trigger because point_sprite is above game_sprite
    trace("u wont see me");
}


how do i ignore? and in which event callback?

thanks,


hope that helps.


On Fri, Aug 21, 2009 at 1:00 AM, theRemix <[hidden email]> wrote:
I have a Sprite that contains a text field which displays points earned that is added above all other elements in a game that i'm creating.

this sprite is obstructing the MouseEvent listeners on game objects 'below' it.

i set flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled to = false; on the points display sprite. this doesn't help 'mute' the display object, or allow the mouse to trigger the MouseEvents on the display objects 'below' it.

what is the proper way, or is there a trick to doing this?

tia

-+> theRemix


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled

theRemix
In reply to this post by gershon
thanks for your help,

i tried them out, and

game_sprite.mouseChildren=false;
point_txt.mouseEnabled=point_txt.selectable=false;

is what i tried at first, and does not work, it behaves as if i hadn't written that.

and 

private function mouse_over_game_sprite(e:MouseEvent):Void
{
if(Std.is(e.target, TextField) || e.target==point_txt || this.contains(e.target) || e.target!=this || e.target!=e.currentTarget)
    return;

trace("me u should see.");
}

"mutes" the game_sprite mouse events. "me u should see" does not trace :/

doing these methods, 
i'm wondering why it's difficult to do this, because in cases where someone replaces a mouse cursor with a custom cursor, isn't there s "fake cursor" sprite that just follows mouseX and mouseY and really blocking the mouse event from ever reaching what ever is below the fake mouse cursor?

i never did a fake/custom mouse cursor since back in actionscript 1, and i know i COULD do a hitTest against 'fake_cursor' and whatever interface buttons, but then i'd have to manually change the button states to 'over_state' and add a bunch more unnecessary listeners for a SimpleButton.

any ideas? 

-+> theRemix

On Aug 20, 2009, at 2:10 PM, gershon wrote:

game_sprite.mouseChildren=false;
point_txt.mouseEnabled=point_txt.selectable=false;

either should do the trick i think...

about the callback:

private function mouse_over_game_sprite(e:MouseEvent):Void
{
if(Std.is(e.target, TextField) || e.target==point_txt || this.contains(e.target) || e.target!=this || e.target!=e.currentTarget)
    return;

trace("me u should see.");
}

e.target is the object currently hovered over, e.currentTarget is the object who's assigned the listener.



On Fri, Aug 21, 2009 at 1:26 AM, theRemix <[hidden email]> wrote:

-+> theRemix

On Aug 20, 2009, at 12:15 PM, gershon wrote:

sounds like you need to set the mouseEnabled=false for the TextField.

DisplayObjectContainer.mouseChildren *should* handle this for me. it doesn't seem like it is.

can also try "ignoring" with if(e.target==tf) return; in the event callback.

thanks for the tip. i don't totally understand though. can you show me an example

var game_sprite:Sprite = new Sprite(); // pretend there's stuff in here
var point_sprite:Sprite = new Sprite();
var point_txt:TextField = new TextField(); // pretend there's text in here and all that

var point_sprite.addChild(point_txt);

game_sprite.addEventListener(MouseEvent.MOUSE_OVER, mouse_over_game_sprite);

private function mouse_over_game_sprite(_):Void
{
     // Does not trigger because point_sprite is above game_sprite
    trace("u wont see me");
}


how do i ignore? and in which event callback?

thanks,


hope that helps.


On Fri, Aug 21, 2009 at 1:00 AM, theRemix <[hidden email]> wrote:
I have a Sprite that contains a text field which displays points earned that is added above all other elements in a game that i'm creating.

this sprite is obstructing the MouseEvent listeners on game objects 'below' it.

i set flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled to = false; on the points display sprite. this doesn't help 'mute' the display object, or allow the mouse to trigger the MouseEvents on the display objects 'below' it.

what is the proper way, or is there a trick to doing this?

tia

-+> theRemix


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled

theRemix
In reply to this post by gershon
hey gershon,

thanks for your help. i got it working.

turns out if the DisplayObject is a child of another DisplayObject which does NOT have mouseChildren or mouseEnabled = false, then the first DisplayObject counts for it's parent's hit area, even though you set the child to mouseEnabled = false.

so, as long as the greatest ancestor has mouseChildren false, then it will work.

-+> theRemix

On Aug 20, 2009, at 2:10 PM, gershon wrote:

game_sprite.mouseChildren=false;
point_txt.mouseEnabled=point_txt.selectable=false;

either should do the trick i think...

about the callback:

private function mouse_over_game_sprite(e:MouseEvent):Void
{
if(Std.is(e.target, TextField) || e.target==point_txt || this.contains(e.target) || e.target!=this || e.target!=e.currentTarget)
    return;

trace("me u should see.");
}

e.target is the object currently hovered over, e.currentTarget is the object who's assigned the listener.



On Fri, Aug 21, 2009 at 1:26 AM, theRemix <[hidden email]> wrote:

-+> theRemix

On Aug 20, 2009, at 12:15 PM, gershon wrote:

sounds like you need to set the mouseEnabled=false for the TextField.

DisplayObjectContainer.mouseChildren *should* handle this for me. it doesn't seem like it is.

can also try "ignoring" with if(e.target==tf) return; in the event callback.

thanks for the tip. i don't totally understand though. can you show me an example

var game_sprite:Sprite = new Sprite(); // pretend there's stuff in here
var point_sprite:Sprite = new Sprite();
var point_txt:TextField = new TextField(); // pretend there's text in here and all that

var point_sprite.addChild(point_txt);

game_sprite.addEventListener(MouseEvent.MOUSE_OVER, mouse_over_game_sprite);

private function mouse_over_game_sprite(_):Void
{
     // Does not trigger because point_sprite is above game_sprite
    trace("u wont see me");
}


how do i ignore? and in which event callback?

thanks,


hope that helps.


On Fri, Aug 21, 2009 at 1:00 AM, theRemix <[hidden email]> wrote:
I have a Sprite that contains a text field which displays points earned that is added above all other elements in a game that i'm creating.

this sprite is obstructing the MouseEvent listeners on game objects 'below' it.

i set flash.display.DisplayObjectContainer.mouseChildren and flash.display.InteractiveObject.mouseEnabled to = false; on the points display sprite. this doesn't help 'mute' the display object, or allow the mouse to trigger the MouseEvents on the display objects 'below' it.

what is the proper way, or is there a trick to doing this?

tia

-+> theRemix


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org