header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Venkatesan
Points:0
Posts:0

3/3/2011 3:31:16 AM

Title: Menu in flex


Hi all,

On mouse over of a link, i open a menu like


optionsMenu = Menu.createMenu(this,menuDataProvider,false);
			optionsMenu.y = event.stageY;
			optionsMenu.x = event.stageX
			optionsMenu.show();

Now i want to hide the menu as soon as the user moves out of menu(like the one happening in menubar). i tried adding listener for rollout event for the link, but it dint work. can any1 help me out??



1
Derek
Points: 0
Posts:0
3/3/2011 10:15:15 AM



hi,
you can use the following code for hiding a menu on rollout. You can add a rollover listener to your base container so that when the mouse is moved out of menu it fires the mouseOver event of that container and hide it. See this example to hide menu control on mouseout of the menu in flex or flash builder


<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  layout="absolute" >
	<mx:Script>
		<![CDATA[
			import mx.controls.Menu;
			// Create and display the Menu control.
			var myMenu:Menu;
			private function showMenu(evt:Event):void {
				myMenu = Menu.createMenu(null, menuData, false);
				myMenu.labelField="@label";
				//show and set the position of menu to below button
				myMenu.show(evt.target.x, evt.target.y+evt.target.height);
			}

			protected function canvas1_mouseOverHandler(event:MouseEvent):void
			{
				if(myMenu){
					//hide menu on roll over of container canvas 
					myMenu.hide()
				}
			}

		]]>
	</mx:Script>
	<!-- Define menus here  -->
	<mx:XML format="e4x" id="menuData">
		<root>
			<menuitem label="MenuItem 1" >
				<menuitem label="SubMenuItem a" enabled="False"/>
				<menuitem label="SubMenuItem b"/>
			</menuitem>
		</root>
	</mx:XML>
	<!-- This button will create menu on rollover and click -->
	<mx:Canvas x="0" y="0" width="264" height="263" backgroundColor="#FFFFFF" mouseOver="canvas1_mouseOverHandler(event)">
		<mx:Button id="myButton" label="Open Menu" click="showMenu(event)" mouseEnabled="true" x="35" y="52"/>
	</mx:Canvas>
</mx:Application>



Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 0+0 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions