root/trunk/as3/com/jeroenwijering/views/RightclickView.as @ 1

Revision 1, 1.7 kB (checked in by jeroen, 18 months ago)

initial commit of old repository into public one

  • Property svn:executable set to *
Line 
1/**
2* Interface for the rightclick menu.
3**/
4package com.jeroenwijering.views {
5
6
7import flash.events.ContextMenuEvent;
8import flash.net.navigateToURL;
9import flash.net.URLRequest;
10import flash.ui.ContextMenu;
11import flash.ui.ContextMenuItem;
12import com.jeroenwijering.player.View;
13
14
15public class RightclickView {
16
17
18        /** Reference to the MVC view. **/
19        private var view:View;
20        /** Reference to the contextmenu. **/
21        private var context:ContextMenu;
22
23
24        /** Contructor; sets up rightclick menu. **/
25        public function RightclickView(vie:View) {
26                view = vie;
27                context = new ContextMenu();
28                context.hideBuiltInItems();
29                view.skin.contextMenu = context;
30                addItem('Toggle Playback Quality',qualityHandler);
31                if(view.config['fullscreen'] == true  && view.skin.stage.displayState != null) {
32                        addItem('Toggle Fullscreen Mode',fullscreenHandler);
33                }
34                if(view.config['abouttext']) {
35                        addItem(view.config['abouttext'],aboutHandler);
36                } else {
37                        addItem('About '+view.config['player']+'...',aboutHandler);
38                }
39        };
40
41
42        /** Add a custom menu item. **/
43        private function addItem(txt:String,hdl:Function) {
44                var itm = new ContextMenuItem(txt);
45                itm.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,hdl);
46                itm.separatorBefore = true;
47                context.customItems.push(itm);
48        };
49
50
51        /** Toggle the fullscreen mode. **/
52        private function fullscreenHandler(evt:ContextMenuEvent) {
53                view.sendEvent('fullscreen');
54        };
55
56
57        /** Toggle the smoothing mode. **/
58        private function qualityHandler(evt:ContextMenuEvent) {
59                view.sendEvent('quality');
60        };
61
62
63        /** jump to the about page. **/
64        private function aboutHandler(evt:ContextMenuEvent) {
65                navigateToURL(new URLRequest(view.config['aboutlink']),'_blank');
66        };
67
68
69};
70
71
72}
Note: See TracBrowser for help on using the browser.