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.
David
Points:0
Posts:0

7/10/2010 3:32:58 PM

Title: How do I add URL links to the MenuBar component in Flash CS3?


I am using the MenuBar for my website menu and I want to set the buttons to link to my website pages.

I've followed instructions in both my manual and the Flash help and I'm still a bit lost. I don't know a line of Actionscript except stop(); Code please.

Thanks




1
Shawn
Points: 680
Posts:0
7/10/2010 9:45:36 PM



there is no nitive functionality in flex menubar to use links. you can extend the menubar class to add such functionality

2
Wilbur
Points: 510
Posts:0
7/11/2010 1:08:24 AM



see this example to use menuBar in flex to open links . We are using here "navigateToURL" to open link on menuItem click

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();" >
	<mx:Script>
		<![CDATA[
			import mx.events.MenuEvent;
			import mx.controls.Alert;
			import mx.collections.*;
			[Bindable]
			public var menuCollection :XMLListCollection;
			private var menubarXML:XMLList =
				<>
					<menuitem label="Menu1" data="top">
						<menuitem label="yahoo.com" data="1"/>
						<menuitem label="msn.com" data="2"/>
					</menuitem>
					<menuitem label="Menu2" data="top">
						<menuitem label="MenuItem 3" data="3"/>
					</menuitem>
				</>;
			
			// create menu items
			private function init():void {
				menuCollection = new XMLListCollection(menubarXML);
			}
			
			// click handler for menubar
			private function menuHandler(event:MenuEvent):void  {
				if(event.item.@label=="yahoo.com"){
					var url:URLRequest = new URLRequest('http://yahoo.com'); 
						navigateToURL(url,'_parent'); 
				}else if(event.item.@label=="msn.com"){
					var url:URLRequest = new URLRequest('http://msn.com'); 
					navigateToURL(url,'_parent');
				}
			}
		]]>
	</mx:Script>
	<mx:Panel title="MenuBar Control Example" height="70%" width="70%" paddingTop="6" paddingLeft="6">
	<mx:MenuBar labelField="@label" itemClick="menuHandler(event);"	dataProvider="{menuCollection }" />
	</mx:Panel>
</mx:Application>



3
David
Points: 0
Posts:0
7/11/2010 5:05:02 AM



Will this work in Flash? I don't have/use Flex.

4
RedBull
Points: 930
Posts:0
7/11/2010 6:56:28 AM



use the below code to open a url on button click in flash cs

myButton.addEventListener(MouseEvent.CLICK, buttonClick)
//button click function
function buttonClick(evt:Event){
var url:URLRequest = new URLRequest('http://msn.com'); 
navigateToURL(url,'_parent');
}


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 8+6 



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