MOUSE_OUT outside of a movieclip? - actionscript-3

I'm having a little problem here,
I'm new to Actionscript 3, and what I'm trying to do is build a navigation menu.
What I did is I made a movieclip, added two listeners to it, MOUSE_OVER, and MOUSE_OUT,
the MOUSE_OVER tells the menu to play, so it then animates the opening of it,
the problem though, that when I put my mouse on the buttons themselves, the menu thinks that the mouse is out of it,
I understand that the mouse left the menu itself and entered some other object,
I thought of making a new rectangle, and on the mouse out, to check whether the mouse is really out of the menu's regions, it didn't work though,
I'd be glad to know how to do that,
thanks in advance

You should use the MouseEvent.ROLL_OUT event which fires only if you your mouse is out of the clip and all its children whereas MOUSE_OUT only considers the clip itself.

Related

Move mouse out of bounds Actionscript 3

My problem is really simple
I´ve an artifact with a mouse inside. When you use it it simulates moving the mouse cursor indefinitely to the right.
Of course when i run my project at some point the mouse will reach the right side of the movieclip and the Mouse_Move event wont work anymore
I need a way make my actionscript to recongnise mouse movement even if im out of bounds
(It´s a mobile aplication so using full screen wont work)
In other words i need a Mouse-Motion Listener!
Though it is not possible to track mouse movements outside of flash with only ActionScript, you could capture the mouse position with javascript in the browser and pass it to your SWF.
See this blog as an example. http://www.nelsond8.com/?p=515
You cannot track the mouse position or actions when it moves outside of the stage.
You can however track when the mouse actually leaves the stage using Event.MOUSE_LEAVE:
function mouseLeave(e:Event):void
{
trace("Mouse left the stage.");
}
stage.addEventListener(Event.MOUSE_LEAVE, mouseLeave);
From here you can decide what the most appropriate course of action will be for your application - adding some 'pause' functionality is pretty common.
Tip: MouseEvent.MOUSE_MOVE is what you should use to detect when the mouse re-enters the stage.

Flash Expandable Banner - Detect Mouse Leave

I have created an expandable banner ad in Flash. Everything is great except one thing. How can I detect when the user is no longer hovering over the flash ad? I have tried to ad a "hit area" which can be used to detect MOUSE_OUT. The issue is, there is a video playing, as well as social media buttons which need to be clickable. If I place a hit area over these, they are no longer clickable. If I place the hit area behind the buttons, the MOUSE_OUT event triggers when you hover over the button.
What is the best practice for a scenario such as this? I have also tried detecting MOUSE_LEAVE on the stage object, but this doesn't seem to function correctly once deployed on an HTML page. Thanks for the assistance.
You can try adding an ENTER_FRAME event that constantly checks stage.mouseX and stage.mouseY. These values should report correctly while the mouse is on the Flash content, and will report the last known mouse coordinates when the mouse is no longer on the stage. However, the last known mouse coordinates may not always be the actual width or height of the stage, so you probably want to add some tolerance in there.
For instance, if your (expanded) Flash content width is 500px, in the ENTER_FRAME event you can check if stage.mouseX is less than 10px (mouse moving off to the left) or more than 490px (mouse is moving off to the right) and minimize the Flash content. Repeat for the height, and adjust tolerance values as needed.
This should give you the effect you want. The only downside that I can see is the overhead of the ENTER_FRAME event just to check whether the mouse has left the content, but I don't see any way around that.

AS3 mouseClick ignore a movieclip

Is there a way in AS3 to make a the mouse ignore a certain movieclip? I need it to be on top of the other movieclips (due to transparancy effects), but have it in a way that allows clicking on the movieclips underneath it. I know about ".mouseChildren = false", but that only makes all the stuff inside that movieclip unclickable, but it still functions as a "barrier" on top of all the others buttons.
Is there a way to do this, or do I need to remove it completely ?
You need to set both .mouseChildren and .mouseEnabled to false before you can click on objects behind the MovieClip. This makes the mouse ignore the objects within the MovieClip and the MovieClip itself.
Source: http://pixelfumes.blogspot.com/2008/01/clicking-through-movieclips-to.html
EDIT: Oops, didn't see that comment by Alex, sorry.

As3: Button only working in certain locations?

I really don't know how to explain this problem. I'm really stumped as to what is causing it.
Here is the code:
var abutton:AButton = new AButton; //Where AButton is a button defined in my library
addChildAt(abutton, numChildren);
abutton.addEventListener(MouseEvent.CLICK, attack);
It doesn't want to work when certain movie clips are underneath it, but I don't want to make it more complicated by switching to another screen. Is it possible to make the button work with movieclips underneath?
What do you mean by "certain movieclips"? What do you mean by not working? The CLICK event isn't firing? Normally if a click isn't working on a button, it means that something else it trapping the mouse click above your button. This can be another Sprite, MovieClip or TextField.
Add a click listener to the stage, and have it print out target and currentTarget. Then, when you button doesn't work, the stage listener will still fire and you'll be able to see the object that's blocking your button.

How to click through a display object in Flash with AS3?

I am creating a photo editor app where, at some point, the photo you edit is supposed to be dropped between two layers of DisplayObjects (a background image and an image mask.)
There is a problem, though. When the image you are editing is dropped between the background and the image mask layers, it becomes unclickable, and therefore gets stuck there, with no chance of dragging it again. (The photo editor uses TransformManager library.)
I am looking for a way to allow you to select the image you are editing no matter if there is another DisplayObject on top of it. And that probably means finding some way to click through the image mask.
Is there a way to do that?
I tried setting mouseChildren = false on imageMask, but that didn't have the desired effect.
Many thanks.
I had similar problems and I managed to solve it by using both
displayobject.mouseChildren = false;
and
displayobject.mouseEnabled = false;
on the object that you want to click through.
How about this?
mask.mouseEnabled = false;
You can always attach a Mouse Click listener to the container, and then either use GetObjectsUnderPoint and check for your object or do a hit test and see if the mouse position is over your intended object.
The hit test would look something like this !this.YourPhoto.hitTestPoint(stage.mouseX, stage.mouseY, false)
b
If I understand your problem, this handy class should solve it:
http://www.mosessupposes.com/utilities/InteractivePNG.html
Take a look at what senocular does here, specifically in the handleUpdate method. Basically: getting a list of everything under the mousePoint to find your object.
I think I stumbled upon similar problem, although in as2.
In flash when you position movie clip over movie clip, and the movie clip on the top has any mouse events implemented, it captures all mouse events so they never reach occluded movie clip.
The solution is not to have any mouse events for the top movie clip and have the movie clip positioned at the bottom capture mouse event and redirect some of them to the top movie clip (you can check mouse position with hitTest to determine if they should be redirected).
i had a strange bug i used;
movieClip.mouseEnabled = false;
but wasn't working for some reason.. was driving me crazy!! as i have used it so many times before. tried lots of different things nothing worked then i deleted the MovieClip and the created a new one and worked.. so the MovieClip's contents must have been corrupt or something as it had a old dynamic Text Area box embedded within the MovieClip.
hope this helps someone out there..