Flash Q
- Started
- Last post
- 10 Responses
- ********
Hi All. Have a small problem with rollover.
I am creating a DropDown Class, where the menu items are individual MC's stacked underneath.
When I press and hold on the dropdown, I can't seem to get the rollovers to work on the menu items MC's.
Any help would be appreciated.
Cheers
- Epictive0
Posting the class file would be really helpful to people trying to help. My guess is you set a button actions on the clip you are attaching the menu items into. The outmost clip's button actions will always take over ones it contains. I would make a clip inside the clip with the open actions, and when the menu is open set a mouseMove listener to know if someone has rolled out of the area.
- caseyc0
You could try onDragOver but for things like this, you should avoid the built in mouse events.
Youre going to need to use hitTest etc...
- Epictive0
I would not use hitTest. You would have to create an interval or enterframe to check it constantly. You only need to check if the mouse has rolled out when the mouse moves, so use a mouse listener. It is stupid to have it polling when you could have an interupt. I am pretty sure the problem you are having is because of the reasion I stated before. But without the code I can only guess.
- unfittoprint0
a on/off triggerlike the following:
I use the drawing API to create a rectangular thick border [_alpha=0] around the content.
when the section menu button is clicked, that border's events are enabled [except useHandCursor].
a rollOver means the user is rolling out of the menu, therefore disabling it.
- Epictive0
unfitt,
If a user moves the mouse fast enough (or quickly out of the flash content) it won't always trigger or if the user is clicking and holding on an item in the drop down, the user could drag over the border area and not trigger a rollOver leaving the menu open. I also don't like to slow down flash with alphas unless needed.
- unfittoprint0
agreed with memory managment but an mc with only a rectangle outline has a minimum impact in the overall's user resources.
regarding the border technique:
I'm refering to something > 10px wide. It will be difficult not to be triggered.
Personally I hate this non OOP approach, but a constant loop interval at movie's rate, checking the mouse's _y/_x is the only is the only other viable option. and more memory un-friendly.
- Epictive0
10 px does make it harder to not trigger dragging fast, but it still doesn't address the fact a user can click an hold on an menu item and drag over and out of that area and not trigger it. I still think the onMouseMove is the best solution. It isn't always running. It only checks when you move the mouse. If the mouse is outside of the area you can close the menu. No loops, no line hacks. And you can expand on it easier. Like if you want to allow the user to be able to be out of the area for a one second before it closes. So if the accidentally rollOut it doesn't snap closed right away.
- unfittoprint0
ok.
if the onMouseMove events relates to the holder of section items, not the items
themselves:for the items to be triggered the holder cannot have events or at least they should be disabled. Therefore onMouseMove will not function.
only
if the event works in each of the section items instead.
right?
- Epictive0
You can have onMouseMove defined basically anywhere. You don't need to have it on each of the section items. Just once place. You can have it on the holder, you just cannont have onRelease, onRollover, etc... Or you can create a clip anywhere and have it check. I just have something like this in my class:
this.onMouseMove = function(Void) {
if (!this.hitTest(_root._xmouse, _root._ymouse, false)) {
this.$close();
delete this.onMouseMove;
}
};
- unfittoprint0
ah. a onMouseMove still enables the events of the items within.
didn't know that. thx.