//定义相关动作指令函数
function tab() {
}
function url1() {
getURL("http://www.webjx.com", "_blank");
}
function url2() {
getURL(http://www.webjx.com/ad.htm, "_blank");
}
function url3() {
getURL("http://wpa.qq.com/msgrd?V=1&Uin=76312395", "_blank");
}
//定义退出FLASH函数(放网页中无效)
function quit1() {
fscommand("quit", "");
}
//定义菜单对象expandmenu
var expandmenu = new ContextMenu();
//隐藏指定 ContextMenu 对象中的所有内置菜单项(“关于”除外)。
expandmenu.hideBuiltInItems();
//定义右键菜单
/*用法
new ContextMenuItem(caption, callbackFunction, [ separatorBefore, [ enabled, [ visible ] ] ] )
参数
caption 指定与菜单项关联的文本的字符串。
callbackFunction 您定义的函数,它在选择菜单项时被调用。
separatorBefore 布尔值,指示分隔条是否应该出现在上下文菜单中的特定菜单项之上。此参数是可选的;其默认值为 false。
enabled 布尔值,指示是启用还是禁用上下文菜单中的特定菜单项。此参数是可选的;其默认值为 true。
visible 布尔值,指示菜单项是否可见。此参数是可选的;其默认值为 true。
*/
var $tab1 = new ContextMenuItem("广告服务:", tab, false, false, true);
var $url1 = new ContextMenuItem("和我们联系", url2);
var $tab2 = new ContextMenuItem("All rights 2005:", tab, true, false, true);
var $url2 = new ContextMenuItem("- http://www.webjx.com -", url1);
var $tab3 = new ContextMenuItem("Design by:", tab, true, false, true);
var $url3 = new ContextMenuItem("网页教学", url1);
var $tab4 = new ContextMenuItem("与作者QQ聊:", tab, true, false, true);
var $url4 = new ContextMenuItem("76312395", url3);
var $tab5 = new ContextMenuItem("其它功能", tab, true, false, true);
var $url5 = new ContextMenuItem("退出", quit1);
//使用 customItems 数组将新的菜单项添加到 ContextMenu 对象 expandmenu
expandmenu.customItems.push($tab1, $url1, $tab2, $url2, $tab3, $url3, $tab4, $url4, $tab5, $url5);
//调用了上下文菜单
expandmenu.onSelect = menuHandler;
//将 expandmenu 对象与对象 _root.menu 相关联
_root.menu = expandmenu;
//that's all

完整示例:

引用内容 引用内容

function goFullScreen () {
    Stage["displayState"] = "fullScreen";
}
//
function exitFullScreen () {
    Stage["displayState"] = "normal";
}

function tab() {
}

function mailto() {
    
    getURL("mailto:info@futureproduct.com.hk", "_blank");
}

//
function menuHandler (obj, menuObj) {
    if (Stage["displayState"] == "normal") {
        menuObj.customItems[0].enabled = true;
        menuObj.customItems[1].enabled = false;
    }
    else {
        menuObj.customItems[0].enabled = false;
        menuObj.customItems[1].enabled = true;
    }
}
//
var fullscreenCM:ContextMenu = new ContextMenu (menuHandler);
//
fullscreenCM.hideBuiltInItems ();
//
var fs:ContextMenuItem = new ContextMenuItem ("Go Full Screen", goFullScreen);
fullscreenCM.customItems.push (fs);
//
var xfs:ContextMenuItem = new ContextMenuItem ("Exit Full Screen", exitFullScreen);
fullscreenCM.customItems.push (xfs);
//
var fp:ContextMenuItem = new ContextMenuItem ("菲博特电子科技(深圳)有限公司",tab,true,true,true);
var dh:ContextMenuItem = new ContextMenuItem ("电话:0755-26825671",tab);
var cz:ContextMenuItem = new ContextMenuItem ("传真:0755-26825672",tab);
var mail:ContextMenuItem = new ContextMenuItem ("联系我们",mailto,true,true,true);
fullscreenCM.customItems.push (fp,dh,cz,mail);

//
_root.menu = fullscreenCM;

 

posted on 2010-04-08 03:23  sn_wolf  阅读(386)  评论(0编辑  收藏  举报