Menus

Right-Click Menu

mProjector replaces the standard Flash right-click (cntl-click on a Mac using a one button mouse) menu with it's own customizable popup menu.This menu appears when the user right-mouse-clicks any visible part of the application.

By default, mProjector's right-click menu includes: 3 items effecting the application's z-order, an "About" item and a "Close" or "Quit" item.

The right-click menu can be modified or completely removed using mProjector's mMenu ActionScript class. mProjector enables you to include a event handler to respond to custom menu item selections.

The following sample creates a custom right-click menu and an event handler.

AS3.0 Sample

//AS3 Example
import stm.mprojector.mMenu;
import stm.mprojector.mMenuEvent;	

mMenu.removeAllItems();
mMenu.addItem("Minimize");
mMenu.addItem("Restore");
mMenu.addSeparator();
mMenu.addItem("Online Documentation");
mMenu.addItem("Contact Tech Support");
mMenu.addItem("Forum");
mMenu.addItem("Check for Updates");
mMenu.addSeparator();
mMenu.addItem("Visit Screentime Media");

public function menuEventHandler(e:mMenuEvent):void {
	switch (e.item)
    {
        case "Minimize":
            mWindow.minimize();
            break;
        case "Restore":
            mWindow.restore();
            break;
        case "Online Documentation":
            mSystem.openDocument("http://www.Screentime.comwww.Screentime.com/software/flash-projector/docs/");
            break;        
        case "Contact Tech Support":
            mSystem.openDocument("mailto:support@Screentime.com");
            break;        
        case "Forum":
            getURL("http://forum.Screentime.com");
            break;
        case "Check for Updates":
            mSystem.openDocument("/mprojector/updates/");
            break;
        case "Visit Screentime Media":
            mSystem.openDocument("/");
            break;	    
    }
} 

mMenu.addEventListener(mMenuEvent.COMMAND, menuEventHandler);

AS2.0 Example

mMenu.removeAllItems();
mMenu.addItem("Minimize");
mMenu.addItem("Restore");
mMenu.addSeparator();
mMenu.addItem("Online Documentation");
mMenu.addItem("Contact Tech Support");
mMenu.addItem("Forum");
mMenu.addItem("Check for Updates");
mMenu.addSeparator();
mMenu.addItem("Visit Screentime Media");

mMenu.onCommand = function (menuName, itemName)
{
	switch (itemName)
    {
        case "Minimize":
            mWindow.minimize();
            break;
        case "Restore":
            mWindow.restore();
            break;
        case "Online Documentation":
            mSystem.openDocument("/software/flash-projector/docs/");
            break;        
        case "Contact Tech Support":
            mSystem.openDocument("mailto:support@Screentime.com");
            break;        
        case "Forum":
            getURL("http://forum.Screentime.com");
            break;
        case "Check for Updates":
            mSystem.openDocument("/mprojector/updates/");
            break;
        case "Visit Screentime Media":
            mSystem.openDocument("/");
            break;	    
    }
} 

mProjector Macintosh enables you to add menus to the menu bar of your application as well as to the right-click menu (ctrl-click menu). The main menu bar is shown at the top of the screen when your application is active.

AS3.0 Sample

import stm.mprojector.mMenu;  
import stm.mprojector.mMenuEvent;   
 

mMenu.createMenu("Help");
mMenu.addWebLinkToMenu("Online Documentation", "www.Screentime.com/software/flash-projector/docs/", "Help");
mMenu.addWebLinkToMenu("Contact Tech Support", "mailto:support@Screentime.com", "Help");
mMenu.addWebLinkToMenu("Forum", "forum.Screentime.com/", "Help");
mMenu.addSeparator("Help");
mMenu.addItem("Register", "Help");
mMenu.addWebLinkToMenu("Check for Updates", "www.Screentime.com/software/flash-projector/docs/", "Help");
mMenu.addWebLinkToMenu("Visit Screentime", "www.Screentime.com/", "Help");
mMenu.addMenuToMenuBar("Help");

public function menuEventHandler(e:mMenuEvent):void {
	switch (e.item)
    {
        case "Register":
 			// do something here to register the application.
            break;	    
    }
} 

mMenu.addEventListener(mMenuEvent.COMMAND, menuEventHandler);

AS2.0 Sample

mMenu.createMenu("Help");
mMenu.addWebLinkToMenu("Online Documentation", "www.Screentime.com/software/flash-projector/docs/", "Help");
mMenu.addWebLinkToMenu("Contact Tech Support", "mailto:support@Screentime.com", "Help");
mMenu.addWebLinkToMenu("Forum", "forum.Screentime.com/", "Help");
mMenu.addSeparator("Help");
mMenu.addItem("Register", "Help");
mMenu.addWebLinkToMenu("Check for Updates", "www.Screentime.com/software/flash-projector/docs/", "Help");
mMenu.addWebLinkToMenu("Visit Screentime", "www.Screentime.com/", "Help");
mMenu.addMenuToMenuBar("Help");

mMenu.onCommand = function (menuName, itemName)
{
	if (itemName=="Register")
	{
		//register user
	}
}

Windows System Tray Click Menu

mProjector enables customization of the Windows system tray menu and Mac status icon and menu. The system tray menu appears when the user right-clicks on the system tray icon. The status menu appears in the upper right in the Mac application menu bar.

The following sample creates a Windows system tray menu.

AS2.0 Sample

/* Custom Windows System Tray Menu */
// build menu 
mMenu.removeAllItems("System Tray Menu");
mMenu.addItem("Online Documentation", "System Tray Menu");
mMenu.addItem("Contact Tech Support", "System Tray Menu");
mMenu.addItem("Forum", "System Tray Menu");
mMenu.addItem("Check for Updates", "System Tray Menu");
mMenu.addSeparator();
mMenu.addItem("Visit Screentime Media", "System Tray Menu");

Mac Application Menu Bar Menus

On Macintosh, mProjector enables you to add menus to the application's menu bar. The main menu bar is shown at the top of the screen when your application is active. When adding a new menu use mMenu.createMenu() to create it and mMenu.addMenuToMenuBar() to make it visible.

The following sample adds a Help menu to the Mac application's menu bar.

//AS 2.0


/* Mac Application Menu Bar Help Menu */

// build menu
mMenu.createMenu("Help");
mMenu.addItem("Online Documentation", "Help");
mMenu.addItem("Contact Tech Support", "Help");
mMenu.addItem("Forum", "Help");
mMenu.addSeparator("Help");
mMenu.addItem("Register", "Help");
mMenu.addItem("Check for Updates", "Help");
mMenu.addItem("Visit Screentime", "Help");
mMenu.addMenuToMenuBar("Help");


// handle user selections
mMenu.onCommand = function (menuName, itemName)
{
	if ((itemSelected[0]=="Help") && (itemSelected[1]=="Register")) {
		//register user
	} else {
		switch (itemName)
		{
			case "Minimize":
				mWindow.minimize();
				break;
			case "Restore":
				mWindow.restore();
				break;
			case "Online Documentation":
				mSystem.openDocument("/software/flash-projector/docs/");
				break;        
			case "Contact Tech Support":
				mSystem.openDocument("mailto:support@Screentime.com");
				break;        
			case "Forum":
				getURL("http://forum.Screentime.com");
				break;
			case "Check for Updates":
				mSystem.openDocument("/mprojector/updates/");
				break;
			case "Visit Screentime Media":
				mSystem.openDocument("/");
				break;	    
		}
}

If you are building an application for Mac and Windows users use mSystem.isMac() and mSystem.isWindows() to implement a cross-platform menu strategy.

Implementing Cross Platform Menus

The following sample code implements a cross-platform menus.

//AS 2.0


function buildMenus() {
	/* Custom Right Click Menu (CNTL-CLICK on one button Mac) */
	mMenu.removeAllItems();
	mMenu.addItem("Minimize");
	mMenu.addItem("Restore");
	mMenu.addSeparator();
	mMenu.addItem("Online Documentation");
	mMenu.addItem("Contact Tech Support");
	mMenu.addItem("Forum");
	mMenu.addItem("Check for Updates");
	mMenu.addSeparator();
	mMenu.addItem("Visit Screentime Media");
	
	if (mSystem.isWindows()) {
		/* Custom Windows System Tray Menu */
		mMenu.removeAllItems("System Tray Menu");
		mMenu.addItem("Online Documentation", "System Tray Menu");
		mMenu.addItem("Contact Tech Support", "System Tray Menu");
		mMenu.addItem("Forum", "System Tray Menu");
		mMenu.addItem("Check for Updates", "System Tray Menu");
		mMenu.addSeparator();
		mMenu.addItem("Visit Screentime Media", "System Tray Menu");
	} else if (mSystem.isMac()) {
		/* Mac Application Menu Bar Help Menu */
		mMenu.createMenu("Help");
		mMenu.addItem("Online Documentation", "Help");
		mMenu.addItem("Contact Tech Support", "Help");
		mMenu.addItem("Forum", "Help");
		mMenu.addSeparator("Help");
		mMenu.addItem("Register", "Help");
		mMenu.addItem("Check for Updates", "Help");
		mMenu.addItem("Visit Screentime", "Help");
		mMenu.addMenuToMenuBar("Help");
	}
}

// handle user selections
mMenu.onCommand = function (menuName, itemName)
{
	if ((itemSelected[0]=="Help") && (itemSelected[1]=="Register")) {
		//register user
	} else {
		switch (itemName)
		{
			case "Minimize":
				mWindow.minimize();
				break;
			case "Restore":
				mWindow.restore();
				break;
			case "Online Documentation":
				mSystem.openDocument("/software/flash-projector/docs/");
				break;        
			case "Contact Tech Support":
				mSystem.openDocument("mailto:support@Screentime.com");
				break;        
			case "Forum":
				getURL("http://forum.Screentime.com");
				break;
			case "Check for Updates":
				mSystem.openDocument("/mprojector/updates/");
				break;
			case "Visit Screentime Media":
				mSystem.openDocument("/");
				break;	    
		}
}