Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a simple text menu 1

Status
Not open for further replies.

rio38

Programmer
Jul 18, 2007
7
US
I have been trying to create a simple drop-down text menu in Flash 8 and have read many, many tutorials. None of htem seem to really do what I am looking for without jumping through hoops. I have a Flash header for the site already. This header contains a menu that consists of text which I use for a menu.
I would like to make this into a drop-down style menu. Is there a simple way of ustilizing the existing text to create a drop-down menu?

Thanks.
 
Thank you very much. I added a menubar component and read the help file on it, but can't get it to have a black background with white text.

Do you have an example of how to change the attributes?
 
To change the appearance of a component, use styles and skins.

Things you can change with styles are somewhat limited. In this case this is pretty much all you can do:
Code:
with (my_mb) {
	setStyle("themeColor",0);
	setStyle("color",0xffffff);
}

with (my_menu) {
	setStyle("backgroundColor",0);
	setStyle("rollOverColor",0xdddddd);
	setStyle("selectionColor",0xdddddd);
	setStyle("textSelectedColor",0);
}
As you see it's getting closer to what you after, but not 100%.

The rest of the customization needs to be done through the skins: <Basically with skins you can change the appearance in anyway you like.

Kenneth Kawamoto
 
Thanks again. I almost have it, but I can't seem to get teh rollover working properly. Whenever I rollover teh "File" menu, teh background turns white behind the word "File". I do not want the background to change color when rolled over. I tried teh useRollOver=False, but it didn't work.
 
I had a look at MenuBar; I could make everything black but I couldn't make the text white...!

But thinking about it, making your own menu bar is very easy. It's just a MovieClip with Menu.show() on onPress. If you need a code example just let me know.

Kenneth Kawamoto
 
A code example would be great. I will also look at the LiveDocs for it. I can make teh text white, but my problem was that when the pointer was over the menu item, teh background for that menu item would turn white, which I did not want to happen.

Thanks again.
 
I think, to change that you need to change the ActivatorSkin MovieClip in the Button Assets folder.

To create a Menu Bar of your own, do the following:

Create a MovieClip - in this case black rectangle with white text "File" on it. Name it "mcMBFile" on Stage. You also need the Menu Component in the Library.

The code - this is based on the Flash doc with my additions:
Code:
import mx.controls.Menu;

//Create Menu
var my_menu:Menu = Menu.createMenu();

my_menu.addMenuItem({label:"New", instanceName:"newInstance"});
my_menu.addMenuItem({label:"Open", instanceName:"openInstance"});
my_menu.addMenuItem({label:"Close", instanceName:"closeInstance"});

with (my_menu) {
	setStyle("themeColor",0);
	setStyle("color",0xffffff);
	setStyle("backgroundColor",0);
	setStyle("rollOverColor",0xdddddd);
	setStyle("selectionColor",0xdddddd);
	setStyle("textSelectedColor",0);
}

//Menu Bar item
mcMBFile.useHandCursor = false;

mcMBFile.onRelease = function():Void  {
	my_menu.show(this._x,this._y+this._height);
	this.enabled = false;
};

//Create listener object.
var mbListener:Object = new Object();
mbListener.change = function(evt_obj:Object) {
	var menuItem_obj:Object = evt_obj.menuItem;
	switch (menuItem_obj.attributes.instanceName) {
		case "newInstance" :
			trace("New menu item");
			break;
		case "openInstance" :
			trace("Open menu item");
			break;
		case "closeInstance" :
			trace("Close menu item");
			break;
	}
	trace(menuItem_obj);
};
mbListener.menuHide = function(o:Object):Void  {
	mcMBFile.enabled = true;
};
//Add listener.
my_menu.addEventListener("change",mbListener);
my_menu.addEventListener("menuHide",mbListener);


Kenneth Kawamoto
 
Thank you so much for your help, that seems to work very well. How do I get the menu items, either the main or sub items to link to a web page?
 
How do I get rid of the popup that just shows teh action? Do I need the trace statements?

I changed the trace statements in teh case block to getURL statements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top