Component Headquarters

Menu Component (Version 2.0.1)

853 downloads / 5602 views

Rating: 4.13

Author

Name
Elvis Mehmedovic
Site
http://emehmedovic.com/
Contact
mailto:me@emehmedovic.com

Release Date

14 Feb 2008 17:30

Platform

AS 2.0, Flash Player 7/8/9

Description

Menu Component is an XMCA 0.3 based component. Resizability is provided by Align Components 4.0.3. Use this components to create low fat menus, menubars and context menus.

Features automatic adaptation to font size, resizability, skinability (three default skins provided), high customizability, and low weight.

After installing the extension, you can find Menu Component in the Components Panel in Flash.

Preview and Downloads

Discussion

Elvis Mehmedovic (17 Jul 2005 12:24)

Short API Reference:

Menu Component
==============================================


class xm.components.MenuComponent extends resizableComponent

Menu component renders all menu types. Each spawned menu is an instance of menu component.


Methods
-------------

function draw(Void):Void - Renders the menu visible, or forces an already visible menu to refresh. In case the menu is a pulldown menu, prior to this call, set _x and _y of the component to the desired top-left corner position. If there should be insufficient space to display the pull down menu, the position will be automatically adjusted.

function hide(Void):Void - Hides the menu.


Constants
---------------

static var checkChar:String = "×" - Predefined textual check character.
static var radioChar:String = "•" - Predefined textual radio character.

Properties
----------------

items:Array - An array of menu item objects; defines the content of the menu. Consult examples to learn how to construct menu structure using items array.
interactionController:MenuInteractionController - Reference to Menu Interaction Controller object.

menuProperties:MenuProperties - Behavior and appearance of the parent menu.
spawnMenuProperties:MenuProperties - Behavior and appearance of the children menus.

(Inherited: width, height, maxWidth, minWidth, maxHeight, minHeight)

Events
----------

beforeShow - Invoked just before draw method starts rendering the menu.
afterShow - Invoked just after draw method has finished rendering the menu.
hide - Invoked after hiding the menu.

beforeSpawn - Invoked before spawning a pulldown menu.
afterSpawn - Invoked after spawning a pulldown menu.
removingSpawn - Invoked when removing a pulldown menu.

(Inherited: resize)

Inherited Dispatcher Methods
----------------------------

(Same as in V2 components; see documentation for V2 components. You can also use on(event) syntax.)

function dispatchEvent(p_eventObj:Object):Void
function addEventListener(p_eventName:String, p_handler):Void
function removeEventListener(p_eventName:String, p_handler):Void

(Advanced)

function addEventListenerL(p_eventName:String, p_obj:Object, p_handler):Void
function removeEventListenerL(p_eventName:String, p_obj:Object, p_handler):Void
function removeAllEventListeners(p_eventName:String):Void

Menu Interaction Controller
==============================================


class xm.components.MenuInteractionController

Menu component renders a single menu. Menu Interaction Controller manages user interaction with the menu, and coordinates multiple menus (parent-child relationships).

Methods
-------------

function activate(Void):Void - Activates the bottom-most parent menu.
function closeAll(Void):Void - Closes all children menus. If the menu is a context menu, parent menu will be closed as well.

Properties
----------------

enabled:Boolean - Enables or disables the menu.
activatorKey:Number - Keyboard activator; default: 120 (F9).
disableKeyboard:Boolean - Disables keyboard.
menus:Array - Array of Menu components; menus[0] is the bottom-most parent menu.
hasFocus:Boolean – Keyboard focus.

Events
----------

gotFocus - Invoked when menus receive keyboard focus.
afterShow - Invoked when menus lose keyboard focus.
rollOver - Invoked when pointer moves over the parent or any of the children.
rollOut - Invoked when pointer moves outside the parent or any of the children.
itemSelect - Invoked when an item is selected; event object contains item (reference to the selected item object) and menu (reference to Menu object) properties.

Dispatcher Methods
----------------------------

(Same as in V2 components; see documentation for V2 components. You can also use on(event) syntax.)

function dispatchEvent(p_eventObj:Object):Void
function addEventListener(p_eventName:String, p_handler):Void
function removeEventListener(p_eventName:String, p_handler):Void

(Advanced)

function addEventListenerL(p_eventName:String, p_obj:Object, p_handler):Void
function removeEventListenerL(p_eventName:String, p_obj:Object, p_handler):Void
function removeAllEventListeners(p_eventName:String):Void

Menu Properties
==============================================


class xm.components.MenuProperties

Properties defining behavior and appearance of the menu.

Constructor
---------------------

new MenuProperties() - Creates the object and sets defaults.
new MenuProperties(paramObj) - Creates the object and sets defaults. Properties defined in paramObj override defaults. In case paramObj defines vertical as true, defaults for vertical menu are used; otherwise defaults for horizontal menu are used.

Properties
----------------

vertical:Boolean - Menu orientation.

customDimensions:Object - Pulldown menus: if defined, customDimensions.width and customDimensions.height will be used as dimensions of the pulldown menu.

leftMargin,
rightMargin,
topMargin,
bottomMargin:Number - Background margins.

itemLeftMargin,
itemRightMargin,
itemTopMargin,
itemBottomMargin:Number - Item margins.

textXOffsets,
textYOffsets:Array - Textfield offsets; e.g. [normalStateOffset:Number, overStateOffset:Number, selectedStateOffset:Number, disabledStateOffset:Number]

spawnDelay,
spawnOffsetX,
spawnOffsetY:Number

backgroundSymbol,
itemSymbol,
separatorSymbol:String - Linkage identifiers.

separatorHeight,
separatorWidth:Number

shortcutSpace,
iconSpace:Number,
arrowSpace:Number - Space to allocate for shortcuts, icons and arrows.

arrowOffsetX,
arrowOffsetY:Number

symbolOffsetX,
symbolOffsetY:Number

shortcutStrSpace,
iconStrSpace:String - Space to allocate for shortcuts and items, expressed as a string. E.g. "x "; this way space will grow together with the font size.

showShortcuts, showIcons,
showArrow:Boolean

itemSpacing:Number

forceTightFit:Boolean -
forcePulldownBehavior:Boolean - Forces pulldown menu behavior (used for context menus).

textFormats:Array - Array of TextFormat objects; [normalStateTF:TextFormat, overStateTF:TextFormat, selectedStateTF:TextFormat, disabledStateTF:TextFormat]
textFieldProperties:Object - Object containing text field properties.

Mark Martin (31 Aug 2005 16:45)

I really like your menu component. I was wondering if you could give me a tip though. How would make a menubar that goes the width of your movie? I would love to use the bundled graphic elements to make the menu bar, it is just hard to determine where they go.

any suggestions would be greatly appreciated

Thank you

Ngqabutho (17 Nov 2005 6:18)

Interesting component.. its realy kick ass

fred (6 Jun 2006 16:04)

I do not see any method to load my xml file, or text file as elemement of the menu, and I do not see any event of clicking a menu? Do I miss something?
thanks

duranike (26 Jun 2006 4:44)

i have been trying and trying and cant get it to work -> How do i dyamically add items to the menu list pulldown. I found the comment code for the m.apply(o,a) function but i dont know what that is.

I have tried just recreating the viewMenu array seperately but that doesnt seem to work. Any ideas?

Elvis Mehmedovic (26 Jun 2006 5:16)

You could add to arrays, and call draw() method afterwards.

duranike (26 Jun 2006 5:44)

ok cool. what is the best way to add to the array. And maybe from outside the movie.

Elvis Mehmedovic (26 Jun 2006 5:54)

It's a plain array object. Do whatever you usually do (e.g. use push method). And again, it's your decision how to reference the component/arrays from an external SWF.

duranike (26 Jun 2006 15:33)

Im still having problems.
Why doesn’t this work?

addthis = "value"
myme = "{caption: \"" + addthis + "\"}"
viewMenu.push(myme)
menu.draw()

but this does
viewMenu.push({caption: "value"}

any help?

duranike (29 Jun 2006 21:27)

For anyone who havent used this yet. Its great!!

Any tip on making a menu item enabled in the middle of a process after initializing it to be enabled: false? I don’t have to repopulate the whole menu with an enabled: true vale do i?

duranike (30 Jun 2006 19:18)

any ideas?

j (9 Aug 2006 21:03)

leftMargin, rightMargin, topMargin, bottomMargin:Number - Background margins.

where are these used? im trying to take the vertical menu spacing on the classic and make it smaller. whats the best way of doing this without hacking apart the whole component?

leftMargin, rightMargin, topMargin, bottomMargin:Number - Background margins.

annoyomous (10 Aug 2006 18:43)

any way to change the menu activation to a rollover rather then on press?

Ben (16 Aug 2006 4:24)

Elvis awesome menu, i am having trouble though adding
fscommand eg. quit functions to the menu. also gotoAndPlay
functions is it possible to do an example as im using this for a
standalone swf.

thanks

Ben (16 Aug 2006 6:46)

its ok i figured it out, instead of open you make your own function works good.

great stuff

Matthew Luke (23 Nov 2006 17:39)

Great Components!!! I'm using your menu, but need to change the text colors for the buttons different states: up, over, and down. How do I do that? On both the main menus as well as the spawned sub-menus

Matthew Luke (23 Nov 2006 18:30)

The better question is how can I have 1 text format style for the main menus and another different text format style for the drop-down menus?

Cojak (2 Oct 2007 9:40)

Hi,
I can't get it working. Where is this array example? I downloaded source of preview, but couldn't find it.

Ben (25 Feb 2008 23:43)

could you do an example of how to "closeAll" i cannot get it working thanks

erewr (23 Jun 2008 3:17)

dfsdf

fsfsdfsf (13 Nov 2009 5:41)

dsfdsfsdfsd

gytuygti (8 Dec 2009 6:39)

guyguy

Misc.

Links