Custom cursor issue with nested movieclips - actionscript-3

I made a custom cursor and add mouse event listeners to it, so it can animate according to mouse clicks (Up/Down) and also hide after 4 seconds if the user didn't click or move the mouse.
The custom cursor was working OK, but after loading external SWF to the container I found that custom cursor event listeners is not working with all movie clips on the child SWF (external loaded SWF). So It is not animating with mouse events and not resetting hide timer, which causing mouse to hide even if the user are moving or clicking it.
The hierarchy of movie clips as follows:
-- Scene 1
-- container's Buttons and controls MCs
-- myLoader content //added under the controls MC
-- content_mc //contains the child movie clips
-- child's movie clips //contains animations and simple buttons
I tried to set
myLoader.mouseChildren = false;
This solves the custom cursor issue but also blocked all mouse events on the child SWF and make all child's buttons unclickable.
So, I wonder if you can help me finding a way to make the custom cursor events working with the nested movie clips without blocking the nested movie clips mouse events.

You should find that if you place the listener at the top level class and set capture to true you should get all the events you need

Related

Flash / AS3 - How to Disable Child SWF Mouse Clicks Without Disabling Mouse Hover Events

I have a flash browser application that loads in a child swf using a Loader object.
The child swf has a mouseclick listener that calls nativateToUrl, and opens a new web page. It also contains mouse hover events that make things in the swf move around.
This application that does the loading is like a container for the child swf and should open a different web page when it is clicked. So essentially I want to suppress the child swf mouseEvent and listen for the mouse click on the container swf, opening the new URL.
I have heard of other people putting an invisible sprite over the original content so that the child swf doesn't actually catch a mouseclick event. However, this won't work in my case because then it doesn't get the mouse hover events either. I want the mousehover events to go through and make the things in the child swf move but also suppress the click event.
So, for all the flash masterminds out there... is this possible? And how can I do it?
:) thanks.
If you want to suppress all MouseEvent.CLICK events from reaching a loaded SWF, you can do the following:
Let's assume you have the following setup:
var loader:Loader = new Loader();
loader.load(new URLRequest("child.swf"));
addChild(loader);
What you can do, is listen on the capture phase for a click event on the Loader:
loader.addEventListener(MouseEvent.CLICK, handler, true);//the third parameter (true) tells flash to listen on the capture phase of an event's lifecycle
Then in the click handler from that, cancel the event so it doesn't propagate down to the loaded SWF:
function handler(e:Event):void {
e.stopImmediatePropagation();
}
If you don't understand the phases of events, this diagram from Adobe may help:
Source
As an aside, if you wanted to suppress all mouse stuffs from the SWF, a much better way (instead of adding an invisible sprite) is to just do this:
loader.mouseChildren = false;

Actionscript track onmouseup outside stage, possible?

So I'm working on a button that plays a sound when clicked or 'mousedown' on, and stops playing when releasing the mousebutton. The mouseup event is set on the stage object.
So the issue is when the cursor is dragged outside the flash movie and then released, the sound doesn't stop since the onmouseup doesn't register anymore.
Thus is there a way to detect either mouseup events, or mouse coordinates outside the stage/flash object itself with actionscript?
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#event:mouseLeave
Add an Event.MOUSE_LEAVE listener to the Stage. This event fires in 2 ways:
Mouse button is already released and leaves the Stage
Mouse button is down and leaves the Stage, then mouse button is released
If your mouse button is down and you leave the Stage, it doesn't fire. An example reason is this: You start dragging a MovieClip and you go off Stage, when you come back to the Stage naturally you expect to still be dragging.

AS3 / Using different movieClips in one frame

For a project I have several movie clips into one frame in those movieClips you will find a button to go to the next movieClip.
All pages (movieClips) overlap each other.
The movie clips in this case are all different pages that I want to connect through a button.
When I click on the button in the movie clip I can not use gotoAndPlay because I want everything in the same frame. I think I should use removeChild for the other movie clips to remove them and only show the one i need when I press the button?
So is there an alternative for gotoAndPlay(); or should i just use removeChild(); if you click the button?
I have little experience with AS3 so I do not know exactly how I should do it.
You can either:
set the visibility with .visible = false/true;
set their alpha with .alpha = 0 - 1; (if they are interactive, they will stay interactive so careful about that)
remove them and add them (as you already proposed)
move them off screen (bad solution)
I would probably set their visibility. Or you can do it with removeChild. There is no gotoAndPlay() for this scenario.

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.

Multiple mouse event as3

I got a MovieClip that is listening to mouse over and out events.
Inside this movie clip I want to show a button when mouse over.
The problem is that movie clip gets the mouse out event when moving to the button area.
I want him to get mouse out event only when living his rect area.
I found one solution: to make mouse position calculation and compare them to my movieClip position to detect if I should handle or ignore the event.
But is there more simple, more Adobe solution?
Edit: The inner button need to receive mouse events as well
set mouseChildren = false for your MovieClip or use ROLL_OVER and ROLL_OUT, here's a great article on the subject
ROLL_OVER and ROLL_OUT events should work (use them instead of MOUSE_OVER and MOUSE_OUT).
Does the inner button need to receive MouseEvents as well? If not, just set it's
button.mouseEnabled = false;
or you can set the parent movie clip's
movieclip.mouseChildren = false;