Changeset 1880 for branches/sharing/src/as/Sharing.as
- Timestamp:
- 07/04/11 07:28:59 (23 months ago)
- File:
-
- 1 edited
-
branches/sharing/src/as/Sharing.as (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/sharing/src/as/Sharing.as
r1879 r1880 1 1 package { 2 2 3 import com.longtailvideo.jwplayer.events.PlaylistEvent; 4 import com.longtailvideo.jwplayer.player.IPlayer; 5 import com.longtailvideo.jwplayer.plugins.IPlugin; 6 import com.longtailvideo.jwplayer.plugins.PluginConfig; 7 import com.longtailvideo.jwplayer.view.components.DockButton; 8 import com.longtailvideo.jwplayer.utils.Logger; 3 import com.longtailvideo.jwplayer.events.*; 4 import com.longtailvideo.jwplayer.player.*; 5 import com.longtailvideo.jwplayer.plugins.*; 9 6 10 7 import flash.display.DisplayObject; 11 import flash.display.LoaderInfo;12 8 import flash.display.Sprite; 13 9 import flash.events.MouseEvent; 14 10 import flash.external.ExternalInterface; 11 import flash.filters.DropShadowFilter; 15 12 import flash.net.URLRequest; 16 13 import flash.net.navigateToURL; … … 18 15 import flash.text.TextField; 19 16 import flash.text.TextFormat; 20 import flash.utils.setTimeout;21 17 22 18 … … 46 42 47 43 /** Reference to the background sheet. **/ 48 private var _backSheet:DisplayObject; 44 private var _back:Sprite; 45 /** The current embed code. **/ 46 private var _code:String; 47 /** Reference to the code field background. **/ 48 private var _codeBack:DisplayObject; 49 49 /** Reference to the code copy button. **/ 50 private var _codeButton: DisplayObject;50 private var _codeButton:Sprite; 51 51 /** Reference to the code text field. **/ 52 52 private var _codeField:TextField; 53 /** The form with all code elements. **/ 54 private var _codeForm:Sprite; 53 55 /** Reference to the code label. **/ 54 56 private var _codeLabel:TextField; 55 57 /** The plugin configuration options.**/ 56 58 private var _config:Object; 57 /** Reference to the container with options. **/58 private var _ container:Sprite;59 /** The form with all buttons. **/ 60 private var _form:Sprite; 59 61 /** The current video link. **/ 60 62 private var _link:String; 63 /** Reference to the link field background. **/ 64 private var _linkBack:DisplayObject; 61 65 /** Reference to the link copy button. **/ 62 private var _linkButton: DisplayObject;66 private var _linkButton:Sprite; 63 67 /** Reference to the link text field. **/ 64 68 private var _linkField:TextField; 69 /** Reference to the link form. **/ 70 private var _linkForm:Sprite; 65 71 /** Reference to the link label. **/ 66 72 private var _linkLabel:TextField; … … 68 74 private var _player:IPlayer; 69 75 /** Reference to the facebook button. **/ 70 private var _facebookButton: DisplayObject;76 private var _facebookButton:Sprite; 71 77 /** Reference to the twitter button. **/ 72 private var _twitterButton: DisplayObject;78 private var _twitterButton:Sprite; 73 79 74 80 75 81 /** The background screen was clicked. **/ 76 82 private function _backHandler(evt:MouseEvent):void { 77 visible = false; 83 _back.visible = false; 84 _form.visible = false; 85 // Only 5.7+... 86 try { _player.controls.display.show(); } catch (error:Error) {} 78 87 }; 79 88 … … 83 92 stage.focus = _codeField; 84 93 _codeField.setSelection(0,999999); 85 System.setClipboard(_code Field.text);94 System.setClipboard(_code); 86 95 }; 87 96 … … 95 104 /** The dock icon was clicked. **/ 96 105 private function _dockHandler(evt:MouseEvent):void { 97 visible = true; 106 _back.visible = true; 107 _form.visible = true; 108 // Only 5.7+... 109 try { _player.controls.display.hide(); } catch (error:Error) {} 98 110 }; 99 111 … … 122 134 _config = config; 123 135 _player.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_ITEM, _itemHandler); 124 _player.controls.dock.addButton(new DockIcon(), "share", _dockHandler) as DockButton; 125 this.visible = false; 126 // Add the backsheet 127 _backSheet = new BackSheet(); 128 _backSheet.addEventListener(MouseEvent.CLICK,_backHandler); 129 //addChild(_backSheet); 130 // Add the container. 131 _container = new Sprite(); 132 addChild(_container); 133 // Add the fields 136 _player.controls.dock.addButton(new DockIcon(), "share", _dockHandler); 137 // Add the background and form. 138 _back = new Sprite(); 139 _back.visible = false; 140 _back.buttonMode = true; 141 _back.addChild(new BackSheet()); 142 _back.addEventListener(MouseEvent.CLICK,_backHandler); 143 addChild(_back); 144 _form = new Sprite(); 145 _form.visible = false; 146 addChild(_form); 147 148 // Add the embed code fields 149 _codeForm = new Sprite(); 150 _form.addChild(_codeForm); 151 _codeLabel = new TextField(); 152 _codeLabel.defaultTextFormat = new TextFormat('Arial', 13, 0xFFFFFF, true); 153 _codeLabel.text = "Embed code"; 154 _codeLabel.x = -5; 155 _codeLabel.y = 3; 156 _codeLabel.filters = new Array(new DropShadowFilter(1,45,0,1,0,0,1)); 157 _codeForm.addChild(_codeLabel); 158 _codeBack = new InputBackground(); 159 _codeForm.addChild(_codeBack); 160 _codeBack.x = 80; 134 161 _codeField = new TextField(); 162 _codeField.defaultTextFormat = new TextFormat('Arial',11,0x000000); 163 _codeForm.addChild(_codeField); 164 _codeField.x = 84; 165 _codeField.y = 5; 166 _codeField.width = 178; 167 _codeField.height = 20; 168 _codeButton = new Sprite(); 169 _codeForm.addChild(_codeButton); 170 _codeButton.buttonMode = true; 171 _codeButton.addChild(new CopyButton()); 172 _codeButton.addEventListener(MouseEvent.CLICK,_codeHandler); 173 _codeButton.x = 260; 174 175 // Add the video link fields 176 _linkForm = new Sprite(); 177 _form.addChild(_linkForm); 178 _linkForm.y = 40; 179 _linkLabel = new TextField(); 180 _linkLabel.defaultTextFormat = new TextFormat('Arial', 13, 0xFFFFFF, true); 181 _linkLabel.text = "Video link"; 182 _linkLabel.x = 10; 183 _linkLabel.y = 3; 184 _linkLabel.filters = new Array(new DropShadowFilter(1,45,0,1,0,0,1)); 185 _linkForm.addChild(_linkLabel); 186 _linkBack = new InputBackground(); 187 _linkForm.addChild(_linkBack); 188 _linkBack.x = 80; 135 189 _linkField = new TextField(); 190 _linkField.defaultTextFormat = new TextFormat('Arial',11,0x000000); 191 _linkForm.addChild(_linkField); 192 _linkField.x = 84; 193 _linkField.y = 5; 194 _linkField.width = 178; 195 _linkField.height = 20; 196 _linkButton = new Sprite(); 197 _linkForm.addChild(_linkButton); 198 _linkButton.buttonMode = true; 199 _linkButton.addChild(new CopyButton()); 200 _linkButton.addEventListener(MouseEvent.CLICK,_linkHandler); 201 _linkButton.x = 260; 202 203 // Add facebook and twitter buttons. 204 _facebookButton = new Sprite(); 205 _facebookButton.addChild(new FacebookButton()); 206 _facebookButton.buttonMode = true; 207 _facebookButton.addEventListener(MouseEvent.CLICK,_facebookHandler); 208 _facebookButton.x = 80; 209 _facebookButton.y = 40; 210 _linkForm.addChild(_facebookButton); 211 _twitterButton = new Sprite(); 212 _twitterButton.addChild(new TwitterButton()); 213 _twitterButton.buttonMode = true; 214 _twitterButton.addEventListener(MouseEvent.CLICK,_twitterHandler); 215 _twitterButton.x = 190; 216 _twitterButton.y = 40; 217 _linkForm.addChild(_twitterButton); 136 218 }; 137 219 … … 139 221 /** Change the embed code when an item changes. */ 140 222 public function _itemHandler(evt:PlaylistEvent):void { 141 /** 142 if(_player.playlist.currentItem['sharing.code'] && 143 _player.playlist.currentItem['sharing.code'] != _config['code']) { 144 _embedField.text = _player.playlist.currentItem['sharing.code']; 145 } else if (_config['code'] == true) { 146 _embedField.text = _embedCode; 147 } else if (_config['code'].length == 8) { 148 _embedField.text = getBotrEmbed(); 149 } else { 150 _embedField.text = _config['code']; 151 } 152 if(_player.playlist.currentItem['sharing.link'] && 153 _player.playlist.currentItem['sharing.link'] != _config['link']) { 154 _shareField.text = _player.playlist.currentItem['sharing.link']; 155 } else if(_player.playlist.currentItem['link'] && 156 _player.playlist.currentItem['link'] != _player.config['link'] && 157 _config['link'] == true) { 158 _shareField.text = _player.playlist.currentItem['link']; 159 } else if (_config['link'] == true) { 160 _shareField.text = _pageURL; 161 } else { 162 _shareField.text = _config['link']; 163 } 164 **/ 223 // Set the embed code. 224 var item:Object = _player.playlist.currentItem; 225 _code = ''; 226 if(item['sharing.code']) { 227 _code = item['sharing.code']; 228 } else if(_config.code) { 229 _code = _config.code; 230 } 231 if(_code.substr(0,3) == '%3C') { 232 _code = decodeURIComponent(_code); 233 } 234 _codeField.text = _code; 235 if(_code == '') { 236 _codeForm.visible = false; 237 _linkForm.y = 20; 238 } else { 239 _codeForm.visible = true; 240 _linkForm.y = 40; 241 } 242 // Set the video link. 243 _link = _getPageURL(); 244 if(item['sharing.link']) { 245 _link = item['sharing.link']; 246 } else if(_config.link) { 247 _link = _config.link; 248 } 249 _linkField.text = _link; 165 250 }; 166 251 … … 170 255 stage.focus = _linkField; 171 256 _linkField.setSelection(0,999999); 172 System.setClipboard(_link Field.text);257 System.setClipboard(_link); 173 258 }; 174 259 … … 176 261 /** Reposition the screens when the player resizes itself **/ 177 262 public function resize(wid:Number, hei:Number):void { 178 _back Sheet.width = wid;179 _back Sheet.height = hei;180 _ container.x = Math.round(wid/2 - 160);181 _ container.y = Math.round(hei/2 - 70);263 _back.width = wid; 264 _back.height = hei; 265 _form.x = Math.round(wid/2 - 160); 266 _form.y = Math.round(hei/2 - 54); 182 267 }; 183 268
Note: See TracChangeset
for help on using the changeset viewer.
