播放器中常用:右键菜单全屏与退出全屏的切换[AS3]
2012-02-06 12:08:55 来源:本站整理核心提示:怎么才能使右键菜单选项文字在点击一下后,再出现时文字改变,播放器中常用:右键菜单全屏与退出全屏的切换[AS3],就是要做个右键菜单全屏选项,点击全屏
怎么才能使右键菜单选项文字在点击一下后,再出现时文字改变,就是要做个右键菜单全屏选项,点击全屏,再右击菜单出现时原来的全屏选项文字 变为退出全屏,如此反复/舞台设置?以下是AS3教程:
- //舞台设置
- stage.frameRate=24;
- //右键设置
- var myContextMenu:ContextMenu = new ContextMenu();
- removeDefaultItems();
- addCustomMenuItems();
- this.contextMenu = myContextMenu;
- function removeDefaultItems():void {
- myContextMenu.hideBuiltInItems();
- var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems;
- }
- function addCustomMenuItems():void {
- var zuozhe:ContextMenuItem = new ContextMenuItem("制作:刘常");
- myContextMenu.customItems.push(zuozhe);
- var wangzhi:ContextMenuItem = new ContextMenuItem("刘常网易博客",true);
- myContextMenu.customItems.push(wangzhi);
- var emaile:ContextMenuItem = new ContextMenuItem("邮箱liu888chang@126.com",true);
- myContextMenu.customItems.push(emaile);
- var dizhi:ContextMenuItem = new ContextMenuItem("湖北省荆州市公安县埠河中学",true);
- myContextMenu.customItems.push(dizhi);
- var _close:ContextMenuItem = new ContextMenuItem("关闭",true);
- myContextMenu.customItems.push(_close);
- var _quanping:ContextMenuItem = new ContextMenuItem("全屏",true);
- myContextMenu.customItems.push(_quanping);
- wangzhi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, wz);
- _close.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, gb);
- _quanping.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, qp);
- }
- function wz(event:ContextMenuEvent):void {
- var url:URLRequest=new URLRequest("http://blog.163.com/liu888chang@126/");
- navigateToURL(url,"_blank");
- }
- function gb(event:ContextMenuEvent):void {
- fscommand("quit");
- }
- function qp(event:ContextMenuEvent):void {
- stage.displayState="fullScreen";
- myContextMenu.customItems.pop();
- var _quanping:ContextMenuItem = new ContextMenuItem("退出全屏",true);
- myContextMenu.customItems.push(_quanping);
- _quanping.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, tcqp);
- }
- function tcqp(event:ContextMenuEvent):void {
- stage.displayState="normal";
- myContextMenu.customItems.pop();
- var _quanping:ContextMenuItem = new ContextMenuItem("全屏",true);
- myContextMenu.customItems.push(_quanping);
- _quanping.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, qp);
- }
赞助商链接