source: trunk/as3/com/jeroenwijering/views/RightclickView.as @ 19

Revision 19, 1.8 KB checked in by jeroen, 5 years ago (diff)

bugfixes: HTTPModel metadata cleared, JS API working without ID, YT proxy loading, init height/width before playerReady call

  • 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                addItem('Toggle Captions Display',captionHandler);
32                if(view.config['fullscreen'] == true && view.skin.stage['displayState']!=null) {
33                        addItem('Toggle Fullscreen Mode',fullscreenHandler);
34                }
35                if(view.config['abouttext']) {
36                        addItem(view.config['abouttext'],aboutHandler);
37                } else {
38                        addItem('About '+view.config['player']+'...',aboutHandler);
39                }
40        };
41
42
43        /** Add a custom menu item. **/
44        private function addItem(txt:String,hdl:Function) {
45                var itm = new ContextMenuItem(txt);
46                itm.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,hdl);
47                itm.separatorBefore = true;
48                context.customItems.push(itm);
49        };
50
51
52        /** Toggle the fullscreen mode. **/
53        private function fullscreenHandler(evt:ContextMenuEvent) {
54                view.sendEvent('fullscreen');
55        };
56
57
58        /** Toggle the smoothing mode. **/
59        private function qualityHandler(evt:ContextMenuEvent) {
60                view.sendEvent('quality');
61        };
62
63
64        /** Toggle the fullscreen mode. **/
65        private function captionHandler(evt:ContextMenuEvent) {
66                view.sendEvent('caption');
67        };
68
69
70        /** jump to the about page. **/
71        private function aboutHandler(evt:ContextMenuEvent) {
72                navigateToURL(new URLRequest(view.config['aboutlink']),'_blank');
73        };
74
75
76};
77
78
79}
Note: See TracBrowser for help on using the repository browser.