source: trunk/as3/com/jeroenwijering/plugins/ClickProxy.as @ 149

Revision 149, 2.1 KB checked in by jeroen, 4 years ago (diff)

fixed start offset, added expressinstall.swf and reinsterd plugins

Line 
1/**
2* This plugin sends mouse click information to javascript when a user clicks on a playing video.
3**/
4package com.jeroenwijering.plugins {
5
6
7import com.jeroenwijering.events.*;
8import flash.display.MovieClip;
9import flash.events.MouseEvent;
10import flash.external.ExternalInterface;
11
12
13public class ClickProxy extends MovieClip implements PluginInterface {
14
15
16        /** Configuration values of the plugin. **/
17        public var config:Object = {
18                listener:'clickListener'
19        };
20        /** Reference to the View of the player. **/
21        private var view:AbstractView;
22        /** Reference to the graphics. **/
23        private var clip:MovieClip;
24        /** initialize call for backward compatibility. **/
25        public var initialize:Function = initializePlugin;
26        /** Playback position of the video. **/
27        private var position:Number;
28
29
30        /** Constructor; nothing going on. **/
31        public function ClickProxy() {};
32
33
34        /** Start the search. **/
35        private function clickHandler(evt:MouseEvent=null) {
36                var obj:Object = {
37                        'client':view.config['client'],
38                        'id':view.config['id'],
39                        'version':view.config['version'],
40                        'position':position,
41                        'mousex':evt.target.mouseX,
42                        'mousey':evt.target.mouseY,
43                        'state':view.config['state']
44                };
45                if(ExternalInterface.available && view.skin.loaderInfo.url.indexOf('http') == 0) {
46                        try {
47                                ExternalInterface.call(config['listener'],obj);
48                        } catch (err:Error) {}
49                }
50        };
51
52
53        /** The initialize call is invoked by the player View. **/
54        public function initializePlugin(vie:AbstractView):void {
55                view = vie;
56                view.config['icons'] = false;
57                view.addControllerListener(ControllerEvent.RESIZE,resizeHandler);
58                view.addModelListener(ModelEvent.TIME,timeHandler);
59                clip = this.area;
60                clip.addEventListener(MouseEvent.CLICK,clickHandler);
61                clip.buttonMode = true;
62                clip.mouseChildren = false;
63                resizeHandler();
64        };
65
66
67        /** Resize the area. **/
68        private function resizeHandler(evt:ControllerEvent=null) {
69                clip.back.width = view.config['width'];
70                clip.back.height = view.config['height'];
71        };
72
73
74        /** Save playback position updates. **/
75        private function timeHandler(evt:ModelEvent) {
76                position = evt.data.position;
77        };
78
79
80}
81
82
83}
Note: See TracBrowser for help on using the repository browser.