| 1 | package com.longtailvideo.plugins.captions { |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | import flash.accessibility.AccessibilityProperties; |
|---|
| 5 | import flash.display.*; |
|---|
| 6 | import flash.events.*; |
|---|
| 7 | import flash.text.*; |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | /** A selector up or down button. **/ |
|---|
| 11 | public class SelectorUpDown extends Sprite { |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | /** Embeds of the default graphics. **/ |
|---|
| 15 | [Embed(source="../../../../../assets/back.png")] |
|---|
| 16 | private const ButtonBack:Class; |
|---|
| 17 | [Embed(source="../../../../../assets/up.png")] |
|---|
| 18 | private const UpIcon:Class; |
|---|
| 19 | [Embed(source="../../../../../assets/down.png")] |
|---|
| 20 | private const DownIcon:Class; |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | /** Background of the button. **/ |
|---|
| 24 | private var _back:DisplayObject; |
|---|
| 25 | /** Textfield of the button. **/ |
|---|
| 26 | private var _icon:DisplayObject; |
|---|
| 27 | /** Handler to call when the button is clicked. **/ |
|---|
| 28 | private var _handler:Function; |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | /** Constructor. **/ |
|---|
| 32 | public function SelectorUpDown(up:Boolean,handler:Function) { |
|---|
| 33 | _handler = handler; |
|---|
| 34 | _back = new ButtonBack(); |
|---|
| 35 | _back.alpha = 0; |
|---|
| 36 | addChild(_back); |
|---|
| 37 | if(up) { |
|---|
| 38 | _icon = new UpIcon(); |
|---|
| 39 | } else { |
|---|
| 40 | _icon = new DownIcon(); |
|---|
| 41 | } |
|---|
| 42 | _icon.x = 77; |
|---|
| 43 | addChild(_icon); |
|---|
| 44 | // Insert accessibility options (tabbing / screenreader label). |
|---|
| 45 | tabEnabled = true; |
|---|
| 46 | tabChildren = false; |
|---|
| 47 | buttonMode = true; |
|---|
| 48 | mouseChildren = false; |
|---|
| 49 | var acs:AccessibilityProperties = new AccessibilityProperties(); |
|---|
| 50 | if(up) { |
|---|
| 51 | tabIndex = 500; |
|---|
| 52 | acs.name = "scroll up language list"; |
|---|
| 53 | } else { |
|---|
| 54 | tabIndex = 599; |
|---|
| 55 | acs.name = "scroll down language list"; |
|---|
| 56 | } |
|---|
| 57 | accessibilityProperties = acs; |
|---|
| 58 | // Set event handlers. |
|---|
| 59 | addEventListener(MouseEvent.CLICK,_clickHandler); |
|---|
| 60 | addEventListener(MouseEvent.MOUSE_OUT,_outHandler); |
|---|
| 61 | addEventListener(MouseEvent.MOUSE_OVER,_overHandler); |
|---|
| 62 | }; |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | /** Register the click. **/ |
|---|
| 66 | private function _clickHandler(event:MouseEvent):void { |
|---|
| 67 | _handler(); |
|---|
| 68 | }; |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | /** Fade the back on rollover. **/ |
|---|
| 72 | private function _outHandler(event:MouseEvent):void { |
|---|
| 73 | _back.alpha = 0; |
|---|
| 74 | }; |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | /** Fade the back on rollover. **/ |
|---|
| 78 | private function _overHandler(event:MouseEvent):void { |
|---|
| 79 | _back.alpha = 1; |
|---|
| 80 | }; |
|---|
| 81 | |
|---|
| 82 | }; |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | } |
|---|