source: plugins/as3/com/jeroenwijering/plugins/Resizer.as @ 66

Revision 66, 1.9 KB checked in by jeroen, 5 years ago (diff)

string of bugfixes and enahncements to the 4.2 player - see changelog

Line 
1/**
2* Shows a bar that can be dragged to resize the playlist.
3**/
4package com.jeroenwijering.plugins {
5
6
7import com.jeroenwijering.events.*;
8import flash.display.MovieClip;
9import flash.events.MouseEvent;
10import flash.geom.Rectangle;
11import flash.utils.setInterval;
12import flash.utils.clearInterval;
13
14
15public class Resizer extends MovieClip implements PluginInterface {
16
17
18        /** Reference to the View of the player. **/
19        private var view:AbstractView;
20        /** Reference to the graphics. **/
21        private var clip:MovieClip;
22        /** Resizing interval. **/
23        private var interval:Number;
24        /** initialize call for backward compatibility. **/
25        public var initialize:Function = initializePlugin;
26
27
28        /** Set internal handlers on init. **/
29        public function Resizer() {
30                clip = this;
31                clip.resizeBar.buttonMode = true;
32                clip.resizeBar.mouseChildren = false;
33                clip.resizeBar.addEventListener(MouseEvent.MOUSE_DOWN,downHandler);
34        };
35
36
37        /** Set the new playlistsize and redraw the stage. **/
38        private function doResize() {
39                var pls = clip.stage.stageWidth-clip.mouseX-view.config['margins'].split(',')[0];
40                view.config['playlistsize'] = pls;
41                view.sendEvent('REDRAW');
42        };
43
44
45        /** Start dragging when mouse is down. **/
46        private function downHandler(evt:MouseEvent):void {
47                interval = setInterval(doResize,50);
48        };
49
50
51        /** The initialize call is invoked by the player View. **/
52        public function initializePlugin(vie:AbstractView):void {
53                view = vie;
54                view.addControllerListener(ControllerEvent.RESIZE,resizeHandler);
55                clip.stage.addEventListener(MouseEvent.MOUSE_UP,upHandler);
56                resizeHandler();
57        };
58
59
60        /** Handle a resize. **/
61        private function resizeHandler(evt:ControllerEvent=undefined) {
62                clip.resizeBar.x = view.config['width'];
63                clip.resizeBar.height = view.config['height'];
64        };
65
66
67        /** Stop dragging when mouse is up again. **/
68        private function upHandler(evt:MouseEvent):void {
69                clearInterval(interval);
70        };
71
72
73}
74
75
76}
Note: See TracBrowser for help on using the repository browser.