Changeset 237
- Timestamp:
- 07/14/09 08:58:44 (4 years ago)
- Location:
- plugins/search
- Files:
-
- 1 deleted
- 3 edited
-
com/jeroenwijering/plugins/Search.as (modified) (9 diffs)
-
search.swf (modified) (previous)
-
search.xml (modified) (2 diffs)
-
searchScreen.png (deleted)
Legend:
- Unmodified
- Added
- Removed
-
plugins/search/com/jeroenwijering/plugins/Search.as
r236 r237 20 20 21 21 22 /** Reference to the background c olor. **/22 /** Reference to the background clip. **/ 23 23 private var back:Sprite; 24 /** Reference to the border clip. **/ 25 private var border:Sprite; 24 26 /** Reference to the graphics. **/ 25 27 public var config:Object = { 26 script:'http://gdata.youtube.com/feeds/api/videos?vq=QUERY&format=5', 27 position:'over' 28 color:'cc0000', 29 label:'YouSearch', 30 position:'over', 31 script:'http://gdata.youtube.com/feeds/api/videos?vq=QUERY&format=5' 28 32 }; 29 /** Reference to the onscreen graphics. **/30 private var screen:Sprite;31 33 /** Reference to the textfield that contains the query. **/ 32 private var query:TextField; 34 private var input:TextField; 35 /** Reference to the textfield that labels the submit button. **/ 36 private var label:TextField; 37 /** Reference to the button graphic. **/ 38 private var submit:Sprite; 33 39 /** Reference to the View of the player. **/ 34 40 private var view:AbstractView; … … 49 55 back.graphics.drawRect(0,0,400,40); 50 56 } 51 back.graphics.beginFill(0xFFFFFF,0. 1);57 back.graphics.beginFill(0xFFFFFF,0.07); 52 58 back.graphics.drawRect(0,0,400,20); 53 back.graphics.beginFill(0x000000,0. 1);59 back.graphics.beginFill(0x000000,0.07); 54 60 back.graphics.drawRect(0,20,400,20); 55 61 addChild(back); 56 screen = new Sprite(); 57 screen.addChild(new Screen()); 58 //screen.scale9Grid = new Rectangle(0,0,100,20); 59 screen.x = screen.y = 10; 60 addChild(screen); 61 query = new TextField(); 62 query.type = TextFieldType.INPUT; 63 query.defaultTextFormat = new TextFormat("_sans",11,0x000000); 64 query.width = 180; 65 query.height = 30; 66 query.x = query.y = 10; 67 query.text = '...'; 68 addChild(query); 62 border = new Sprite(); 63 border.graphics.beginFill(0x878787); 64 border.graphics.drawRect(0,0,200,20); 65 border.x = border.y = 10; 66 addChild(border); 67 input = new TextField(); 68 input.background = true; 69 input.backgroundColor = 0xFFFFFF; 70 input.type = TextFieldType.INPUT; 71 input.defaultTextFormat = new TextFormat("_sans",11,0x000000); 72 input.height = 18; 73 input.x = input.y = 11; 74 input.text = '...'; 75 addChild(input); 76 submit = new Sprite(); 77 submit.graphics.beginFill(uint('0x'+config['color'])); 78 submit.graphics.drawRect(0,0,118,18); 79 submit.graphics.beginFill(0xFFFFFF,0.08); 80 submit.graphics.drawRect(0,0,118,9); 81 submit.graphics.beginFill(0x000000,0.08); 82 submit.graphics.drawRect(0,9,118,9); 83 submit.y = 11; 84 addChild(submit); 85 label = new TextField(); 86 var fmt:TextFormat = new TextFormat("_sans",11,0xFFFFFF); 87 fmt.align = 'center'; 88 label.defaultTextFormat = fmt; 89 label.width = 118; 90 label.text = config['label']; 91 submit.addChild(label); 69 92 }; 70 93 … … 72 95 /** Start a search. **/ 73 96 private function clickHandler(evt:MouseEvent=null):void { 74 var que:String = encodeURI( query.text);97 var que:String = encodeURI(input.text); 75 98 if(que.length > 3) { 76 99 if(view.config['playlist'] == 'none') { … … 80 103 view.sendEvent('LOAD',config['script'].replace('QUERY',que)); 81 104 } 82 query.text = '';105 input.text = ''; 83 106 }; 84 107 … … 86 109 /** Clear the field on focus. **/ 87 110 private function focusHandler(evt:FocusEvent):void { 88 if( query.text == '...') {89 query.text = '';111 if(input.text == '...') { 112 input.text = ''; 90 113 } 91 114 }; … … 97 120 view.addModelListener(ModelEvent.STATE,stateHandler); 98 121 view.addControllerListener(ControllerEvent.RESIZE,resizeHandler); 122 if(view.config['lightcolor'] && !view.config['search.color']) { 123 config['color'] = view.config['lightcolor']; 124 } 99 125 build(); 100 screen.addEventListener(MouseEvent.CLICK,clickHandler);101 screen.buttonMode = true;102 s creen.mouseChildren = false;103 query.addEventListener(FocusEvent.FOCUS_IN,focusHandler);104 query.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);126 input.addEventListener(FocusEvent.FOCUS_IN,focusHandler); 127 input.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler); 128 submit.addEventListener(MouseEvent.CLICK,clickHandler); 129 submit.buttonMode = true; 130 submit.mouseChildren = true; 105 131 resizeHandler(); 106 132 }; … … 109 135 /** Start the search when pressing the enter key. **/ 110 136 private function keyHandler(evt:KeyboardEvent):void { 111 if(evt.charCode == 13) { 137 if(evt.charCode == 13) { 112 138 clickHandler(); 113 139 } … … 120 146 x = config['x']; 121 147 y = config['y']; 122 } 148 } 123 149 back.width = view.config['width']; 124 screen.x = back.width/2 - screen.width/2; 150 border.width = back.width - 20; 151 input.width = back.width - 141; 152 submit.x = back.width - 129; 125 153 }; 126 154 … … 134 162 break; 135 163 default: 136 stage.focus = query;164 stage.focus = input; 137 165 visible = true; 138 166 break; -
plugins/search/search.xml
r236 r237 15 15 <flashvars> 16 16 <flashvar> 17 <name>color</name> 18 <default>CC0000</default> 19 <description> 20 Background color of the submit button. 21 If no color is set, but a player "lightcolor" is, that value is used. 22 </description> 23 </flashvar> 24 <flashvar> 17 25 <name>script</name> 18 26 <default>http://gdata.youtube.com/feeds/api/videos%3Fvq%3DQUERY%26format%3D5</default> … … 25 33 </flashvar> 26 34 <flashvar> 35 <name>label</name> 36 <default>YouSearch</default> 37 <description> 38 Text label of the search button 39 </description> 40 </flashvar> 41 <flashvar> 27 42 <name>position</name> 28 <default >over</default>43 <default /> 29 44 <description> 30 Position of the search bar. Can be " over", "bottom" or "top".31 When set to "over",the bar only shows when the video is paused/stopped.45 Position of the search bar. Can be "bottom" or "top". 46 Defaults to the "over" position, where the bar only shows when the video is paused/stopped. 32 47 </description> 33 48 </flashvar> 34 49 <flashvar> 35 50 <name>size</name> 36 <default >40</default>51 <default /> 37 52 <description> 38 Height of the se rch bar when placed at the "top" or "bottom" position.53 Height of the search bar when placed at the "top" or "bottom" position. Set this to "40". 39 54 </description> 40 55 </flashvar>
Note: See TracChangeset
for help on using the changeset viewer.
