I am using drop down menus with invisible buttons to open and close the menus. When I roll outside the canvas area (e.g. Outside the actual SWF ) sometimes the menu sticks on the open state.
Is there a way to write code for the following: If mouse is outside the canvas, close all menus?
Sorry to be impatient, but so far no one has been able to help! Would really appreciate some feedback here....
I am using the following code to control the "open" / "closed" state of a drop down navigation. There are two navs in total.
_global.isopen=false;
_global.OpenMenu=function(menuname)
{
if (_global.isopen==false)
{
_global.isopen=true;
eval("_root."+menuname).gotoAndPlay("over");
}
}
_global.CloseMenu=function(menuname)
{
if (_global.isopen==true)
{
_global.isopen=false;
eval("_root."+menuname).gotoAndPlay("out");
}
}
I have an invisible button that controls the "rollout" state and the following code to control the "rollOver" state. ("mainmenu") is replaced by ("roammenu") on the other menu.
ON THE MENU BUTTON:
on (rollOver) {
_global.OpenMenu("mainmenu");
}
PROBLEM - when I roll out of the canvas or SWF sometimes the menus stick open. I need to find a way to: close all open menus if someone rolls out of the canvas and somewhere onto the HTML page.
Divarch, Flash does not currently have support to track objects outside of the swf. A rollout event will not solve the problem. Frankly, there's no real way to bulletproof someone from rolling out of the stage fast enough to preempt the rollOut actions.
Thanks annexion for making me look at the original q again! I missed the 'outside .swf' part
So, @cytone:
Outside the canvas: no! At least not bulletproof.
But, as almost always, Flash can be worked around. You could try with setting the interval for a 'isopen' status check, then if false for some time, close all menus.
It could work, now just trying to incorporate it in your code.