« Tutorial : Understanding ExternalInterface in Flash 8 | Main | Flash Experts Forum »

Usable Flash Menus

Listen to this article Listen to this article :: Talkr

I am not going to give you gyans about Usability but just a simple way to make your Flash Navigation System more usable. How many times have you come across a site which has a flash menu system and desperately wanted to right click on it and choose "Open in New Window" - one hundred times may be? Yes, this is not a very big usablilty funda but adds value to your site especially if you rely on a flash based menu system for naviagtion. How long would it take one to create such an option for the flash menu, just a few minutes and a few lines of code.

Here is the code :

var cm:ContextMenu = new ContextMenu();

cm.hideBuiltInItems();

cm.customItems.push(new ContextMenuItem("Open in a new window", itemHandler));



function itemHandler(obj, item) {

    getURL(obj.__url, "_blank");

}

this.menu = cm;

this.__url = "http://www.macromedia.com";

Just add this to the timeline of your menu item movieclip.

Sample (Right click on the button):





|

TrackBack

TrackBack URL for this entry:
http://www.lastashero.com/blog/mt-tb.cgi/20

Comments

Sorry to have to report this, your example doesn't work with Safari on Mac

I don't know why Macromedia insist to keep two more useless items there. So I gave up to take any context menu in Flash.

Hi George ! Thanks for the feedback. But, I tested it on Mac OS (Tiger) with Safari and it works fine for me. Are you sure its not a problem with your player version?

- KP

Hey thats pretty slick. Thanks.

Another cool thing I've noticed but not seen mentioned is with embedded links in htmlText fields, it seems the player gives you a trimmed down 'open in new window' context menu when you right click em in a browser.

I also noticed it doesn't work in Firefox 1.5, but it does work when popup blocking is turned off. I suspect that might be the problem with Safari as well.

I concur, works fine in Safari: Version 2.0.2 (416.12) on MacOs: 10.4.3

Like chris mentioned, using a textfield with the TextFormat url property set makes an even nicer context menu for links. It gives the option to open, open in new window, and copy link. That's more familiar to non-Flash people I think.

The trick I've used is to use a second textfield in front of the label textfield. The reason for this is that if you just set the link for the label textfield, the hitArea is only where the text is. If you use a second textfield, make it an HTML textfield, set the alignment to be right, then set the text to be a space (so it doesn't display anything) the hitArea is the entire area of that second textfield.

It's more of a hack than just setting the contextMenu, but it is very effective.

A little observation about this feature, it "only works" well on Flash 8. Flash 7 supports contexts menu already but in a very limited way. In Flash 7 if a parent movieclip and a child movieclip both have context menus set, the parent's menu is always shown, even when clicking on the child.

Thanks Chad for confirming that it works fine on Mac OS X !

-KP

George, to answer your question about "why Macromedia insist to keep two more useless items there" - There should be a reason why MM is doing that but my guess is the "About Macromedia.." thingy is the only way by which one can identify and differentiate Flash content.

-KP

Derek : That's a real smart hack but turns out to be a pain on the *&* :) Well I never knew about this hack before, perhaps there should be a central place where people should be able to post these kindof hacks so it can come handy for people looking for quick solutions to such kindof problems.

-KP

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Recent Visitors

Feeds


Link to Podcast (RSS feed) for this blog

Aggregated By :