搜学在线有限公司UJJHBJ
  • flash用右键菜单来控制显示、隐藏右键菜单

    //
    // 函数:当点击指定菜单项时,显示所有内置菜单项
    // 参数:
    // currentObject 对右键点击对象的引用
    // itemReference 对选定 ContextMenuItem 对象的引用
    //
    function showBuiltInItems(curr item):Void {
    // 临时存储自定义菜单项的路径
    var temporaryCustomItems = ;
    for (var everyProp in temporaryCustomItems) {
    temporaryCustomItems[everyProp]["enabled"] = true;
    }
    // 选中项变为不可用
    = false;
    // 临时存储内建菜单项的路径
    var temporaryBuiltInItems = ;
    // 通过 for..in 循环枚举 ContextMenu 类的 temporaryBuiltInItems 对象的属性,即内置菜单项的所有名称
    for (var eachProp in temporaryBuiltInItems) {
    // 输出属性名
    //trace(eachProp);
    // 改变各属性值为true,即显示
    temporaryBuiltInItems[eachProp] = true;
    }
    }
    //
    // 函数:当点击指定菜单项时,隐藏所有内置菜单项
    //
    function hideBuiltInItems(curr item):Void {
    // 临时存储自定义菜单项的路径
    var temporaryCustomItems = ;
    for (var everyProp in temporaryCustomItems) {
    temporaryCustomItems[everyProp]["enabled"] = true;
    }
    // 选中项变为不可用
    = false;
    // 隐藏所有内置菜单项
    ();
    }
    //
    // 创建一个 ContextMenu 类的对象
    var firstCo = new ContextMenu();
    // 隐藏指定 ContextMenu 对象中的所有内置菜单项(“设置”除外)
    ();
    // 添加新的菜单项
    (new ContextMenuItem("显示菜单", showBuiltInItems));
    (new ContextMenuItem("隐藏菜单", hideBuiltInItems, true, false));
    // 将 ContextMenu 对象会应用到根时间轴(或者其他指定的对象)
    = firstContextMemu;