| 1 | package com.longtailvideo.jwplayer.view.components { |
|---|
| 2 | import com.longtailvideo.jwplayer.events.MediaEvent; |
|---|
| 3 | import com.longtailvideo.jwplayer.events.PlayerEvent; |
|---|
| 4 | import com.longtailvideo.jwplayer.events.PlayerStateEvent; |
|---|
| 5 | import com.longtailvideo.jwplayer.events.PlaylistEvent; |
|---|
| 6 | import com.longtailvideo.jwplayer.events.ViewEvent; |
|---|
| 7 | import com.longtailvideo.jwplayer.player.IPlayer; |
|---|
| 8 | import com.longtailvideo.jwplayer.player.PlayerState; |
|---|
| 9 | import com.longtailvideo.jwplayer.utils.Strings; |
|---|
| 10 | import com.longtailvideo.jwplayer.view.interfaces.IControlbarComponent; |
|---|
| 11 | |
|---|
| 12 | import flash.display.DisplayObject; |
|---|
| 13 | import flash.display.MovieClip; |
|---|
| 14 | import flash.display.Sprite; |
|---|
| 15 | import flash.events.MouseEvent; |
|---|
| 16 | import flash.text.TextField; |
|---|
| 17 | import flash.text.TextFieldAutoSize; |
|---|
| 18 | import flash.text.TextFormat; |
|---|
| 19 | import flash.ui.Mouse; |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | /** |
|---|
| 23 | * Sent when the user interface requests that the player play the currently loaded media |
|---|
| 24 | * |
|---|
| 25 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_PLAY |
|---|
| 26 | */ |
|---|
| 27 | [Event(name="jwPlayerViewPlay", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 28 | /** |
|---|
| 29 | * Sent when the user interface requests that the player pause the currently playing media |
|---|
| 30 | * |
|---|
| 31 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_PAUSE |
|---|
| 32 | */ |
|---|
| 33 | [Event(name="jwPlayerViewPause", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 34 | /** |
|---|
| 35 | * Sent when the user interface requests that the player stop the currently playing media |
|---|
| 36 | * |
|---|
| 37 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_STOP |
|---|
| 38 | */ |
|---|
| 39 | [Event(name="jwPlayerViewStop", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 40 | /** |
|---|
| 41 | * Sent when the user interface requests that the player play the next item in its playlist |
|---|
| 42 | * |
|---|
| 43 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_NEXT |
|---|
| 44 | */ |
|---|
| 45 | [Event(name="jwPlayerViewNext", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 46 | /** |
|---|
| 47 | * Sent when the user interface requests that the player play the previous item in its playlist |
|---|
| 48 | * |
|---|
| 49 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_PREV |
|---|
| 50 | */ |
|---|
| 51 | [Event(name="jwPlayerViewPrev", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 52 | /** |
|---|
| 53 | * Sent when the user interface requests that the player navigate to the playlist item's <code>link</code> property |
|---|
| 54 | * |
|---|
| 55 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_LINK |
|---|
| 56 | */ |
|---|
| 57 | [Event(name="jwPlayerViewLink", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 58 | /** |
|---|
| 59 | * |
|---|
| 60 | * |
|---|
| 61 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_MUTE |
|---|
| 62 | */ |
|---|
| 63 | [Event(name="jwPlayerViewMute", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 64 | /** |
|---|
| 65 | * |
|---|
| 66 | * |
|---|
| 67 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_FULLSCREEN |
|---|
| 68 | */ |
|---|
| 69 | [Event(name="jwPlayerViewFullscreen", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 70 | /** |
|---|
| 71 | * |
|---|
| 72 | * |
|---|
| 73 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_VOLUME |
|---|
| 74 | */ |
|---|
| 75 | [Event(name="jwPlayerViewVolume", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 76 | /** |
|---|
| 77 | * |
|---|
| 78 | * |
|---|
| 79 | * @eventType com.longtailvideo.jwplayer.events.ViewEvent.JWPLAYER_VIEW_SEEK |
|---|
| 80 | */ |
|---|
| 81 | [Event(name="jwPlayerViewSeek", type="com.longtailvideo.jwplayer.events.ViewEvent")] |
|---|
| 82 | public class ControlbarComponent extends CoreComponent implements IControlbarComponent { |
|---|
| 83 | protected var _buttons:Object = {}; |
|---|
| 84 | protected var _dividers:Array; |
|---|
| 85 | protected var _defaultLayout:String = "[play|stop|prev|next|elapsed][time][duration|fullscreen|mute volume]"; |
|---|
| 86 | protected var _currentLayout:String; |
|---|
| 87 | protected var _layoutManager:ControlbarLayoutManager; |
|---|
| 88 | protected var _width:Number; |
|---|
| 89 | protected var _height:Number; |
|---|
| 90 | |
|---|
| 91 | public function ControlbarComponent(player:IPlayer) { |
|---|
| 92 | super(player, "controlbar"); |
|---|
| 93 | _layoutManager = new ControlbarLayoutManager(this); |
|---|
| 94 | _dividers = []; |
|---|
| 95 | setupBackground(); |
|---|
| 96 | setupDefaultButtons(); |
|---|
| 97 | addEventListeners(); |
|---|
| 98 | updateControlbarState(); |
|---|
| 99 | setTime(0,0); |
|---|
| 100 | updateVolumeSlider(); |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | private function addEventListeners():void { |
|---|
| 105 | player.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_LOADED, playlistHandler); |
|---|
| 106 | player.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_UPDATED, playlistHandler); |
|---|
| 107 | player.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_ITEM, playlistHandler); |
|---|
| 108 | player.addEventListener(PlayerStateEvent.JWPLAYER_PLAYER_STATE, stateHandler); |
|---|
| 109 | player.addEventListener(MediaEvent.JWPLAYER_MEDIA_MUTE, stateHandler); |
|---|
| 110 | player.addEventListener(MediaEvent.JWPLAYER_MEDIA_VOLUME, updateVolumeSlider); |
|---|
| 111 | player.addEventListener(MediaEvent.JWPLAYER_MEDIA_BUFFER, mediaHandler); |
|---|
| 112 | player.addEventListener(MediaEvent.JWPLAYER_MEDIA_TIME, mediaHandler); |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | private function playlistHandler(evt:PlaylistEvent):void { |
|---|
| 117 | resetSlider(); |
|---|
| 118 | updateControlbarState(); |
|---|
| 119 | redraw(); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | private function resetSlider():void { |
|---|
| 124 | var scrubber:Slider = getButton('time') as Slider; |
|---|
| 125 | if (scrubber) { |
|---|
| 126 | scrubber.reset(); |
|---|
| 127 | } |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | private function stateHandler(evt:PlayerEvent):void { |
|---|
| 132 | updateControlbarState(); |
|---|
| 133 | redraw(); |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | private function updateControlbarState():void { |
|---|
| 138 | var newLayout:String = _defaultLayout; |
|---|
| 139 | if (player.state == PlayerState.PLAYING) { |
|---|
| 140 | newLayout = newLayout.replace('play', 'pause'); |
|---|
| 141 | hideButton('play'); |
|---|
| 142 | } else if (player.state == PlayerState.IDLE) { |
|---|
| 143 | resetSlider(); |
|---|
| 144 | if (_player.playlist.currentItem){ |
|---|
| 145 | setTime(0,_player.playlist.currentItem.duration); |
|---|
| 146 | } |
|---|
| 147 | hideButton('pause'); |
|---|
| 148 | } else { |
|---|
| 149 | hideButton('pause'); |
|---|
| 150 | } |
|---|
| 151 | if (player.playlist.length <= 1) { |
|---|
| 152 | newLayout = newLayout.replace("|prev|next", ""); |
|---|
| 153 | hideButton('prev'); |
|---|
| 154 | hideButton('next'); |
|---|
| 155 | } |
|---|
| 156 | if (player.mute) { |
|---|
| 157 | newLayout = newLayout.replace("mute", "unmute"); |
|---|
| 158 | hideButton("mute"); |
|---|
| 159 | } else { |
|---|
| 160 | hideButton("unmute"); |
|---|
| 161 | } |
|---|
| 162 | if (player.fullscreen) { |
|---|
| 163 | newLayout = newLayout.replace("fullscreen", "normalscreen"); |
|---|
| 164 | hideButton("fullscreen"); |
|---|
| 165 | } else { |
|---|
| 166 | hideButton("normalscreen"); |
|---|
| 167 | } |
|---|
| 168 | _currentLayout = removeInactive(newLayout); |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | private function removeInactive(layout:String):String { |
|---|
| 173 | var buttons:Array = _defaultLayout.match(/\W*([A-Za-z0-9]+?)\W/g); |
|---|
| 174 | for (var i:Number = 0; i < buttons.length; i++){ |
|---|
| 175 | var button:String = (buttons[i] as String).replace(/\W/g,""); |
|---|
| 176 | if (!_buttons[button]) { |
|---|
| 177 | layout = layout.replace(button,""); |
|---|
| 178 | layout = layout.replace("||", "|"); |
|---|
| 179 | } |
|---|
| 180 | } |
|---|
| 181 | return layout; |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | private function mediaHandler(evt:MediaEvent):void { |
|---|
| 185 | var scrubber:Slider = getButton('time') as Slider; |
|---|
| 186 | switch (evt.type) { |
|---|
| 187 | case MediaEvent.JWPLAYER_MEDIA_BUFFER: |
|---|
| 188 | //setTime(evt.position, evt.duration); |
|---|
| 189 | if (scrubber) { |
|---|
| 190 | //scrubber.setProgress(evt.position / evt.duration *100); |
|---|
| 191 | scrubber.setBuffer(evt.bufferPercent); |
|---|
| 192 | } |
|---|
| 193 | break; |
|---|
| 194 | case MediaEvent.JWPLAYER_MEDIA_TIME: |
|---|
| 195 | setTime(evt.position, evt.duration); |
|---|
| 196 | if (scrubber) { |
|---|
| 197 | scrubber.setProgress(evt.position / evt.duration * 100); |
|---|
| 198 | if (evt.bufferPercent >= 0){ |
|---|
| 199 | scrubber.setBuffer(evt.bufferPercent); |
|---|
| 200 | } |
|---|
| 201 | } |
|---|
| 202 | break; |
|---|
| 203 | default: |
|---|
| 204 | scrubber.reset(); |
|---|
| 205 | break; |
|---|
| 206 | } |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | private function updateVolumeSlider(evt:MediaEvent = null):void { |
|---|
| 210 | var volume:Slider = getButton('volume') as Slider; |
|---|
| 211 | if (volume){ |
|---|
| 212 | if (!_player.config.mute) { |
|---|
| 213 | volume.setBuffer(100); |
|---|
| 214 | volume.setProgress(_player.config.volume); |
|---|
| 215 | volume.resize(getSkinElement("volumeSliderRail").width,volume.height); |
|---|
| 216 | } else { |
|---|
| 217 | volume.reset(); |
|---|
| 218 | volume.resize(getSkinElement("volumeSliderRail").width,volume.height); |
|---|
| 219 | } |
|---|
| 220 | } |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | private function setTime(position:Number, duration:Number):void { |
|---|
| 225 | if (position < 0) { |
|---|
| 226 | position = 0; |
|---|
| 227 | } |
|---|
| 228 | if (duration < 0) { |
|---|
| 229 | duration = 0; |
|---|
| 230 | } |
|---|
| 231 | var elapsedText:TextField = getButton('elapsed') as TextField; |
|---|
| 232 | elapsedText.text = Strings.digits(position); |
|---|
| 233 | var durationField:TextField = getButton('duration') as TextField; |
|---|
| 234 | durationField.text = Strings.digits(duration); |
|---|
| 235 | redraw(); |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | private function setupBackground():void { |
|---|
| 240 | var back:DisplayObject = getSkinElement("background"); |
|---|
| 241 | var capLeft:DisplayObject = getSkinElement("capLeft"); |
|---|
| 242 | var capRight:DisplayObject = getSkinElement("capRight"); |
|---|
| 243 | //var shade:DisplayObject = getSkinElement("shade"); |
|---|
| 244 | |
|---|
| 245 | if (!back) { |
|---|
| 246 | var newBackground:Sprite = new Sprite(); |
|---|
| 247 | newBackground.name = "background"; |
|---|
| 248 | newBackground.graphics.beginFill(0, 1); |
|---|
| 249 | newBackground.graphics.drawRect(0, 0, 1, 1); |
|---|
| 250 | newBackground.graphics.endFill(); |
|---|
| 251 | back = newBackground as DisplayObject; |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | _buttons['background'] = back; |
|---|
| 255 | addChild(back); |
|---|
| 256 | _height = back.height; |
|---|
| 257 | player.config.pluginConfig("controlbar")['size'] = back.height; |
|---|
| 258 | |
|---|
| 259 | if (capLeft) { |
|---|
| 260 | _buttons['capLeft'] = capLeft; |
|---|
| 261 | addChild(capLeft); |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | if (capRight) { |
|---|
| 265 | _buttons['capRight'] = capRight; |
|---|
| 266 | addChild(capRight); |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | /*if (shade) { |
|---|
| 270 | _buttons['shade'] = shade; |
|---|
| 271 | addChild(shade); |
|---|
| 272 | }*/ |
|---|
| 273 | } |
|---|
| 274 | |
|---|
| 275 | |
|---|
| 276 | private function setupDefaultButtons():void { |
|---|
| 277 | addComponentButton('play', 'Play', ViewEvent.JWPLAYER_VIEW_PLAY); |
|---|
| 278 | addComponentButton('pause', 'Pause', ViewEvent.JWPLAYER_VIEW_PAUSE); |
|---|
| 279 | addComponentButton('prev', 'Previous', ViewEvent.JWPLAYER_VIEW_PREV); |
|---|
| 280 | addComponentButton('next', 'Next', ViewEvent.JWPLAYER_VIEW_NEXT); |
|---|
| 281 | addComponentButton('stop', 'Stop', ViewEvent.JWPLAYER_VIEW_STOP); |
|---|
| 282 | addComponentButton('fullscreen', 'Fullscreen', ViewEvent.JWPLAYER_VIEW_FULLSCREEN, true); |
|---|
| 283 | addComponentButton('normalscreen', 'Normalscreen', ViewEvent.JWPLAYER_VIEW_FULLSCREEN, false); |
|---|
| 284 | addComponentButton('unmute', 'Mute', ViewEvent.JWPLAYER_VIEW_MUTE, false); |
|---|
| 285 | addComponentButton('mute', 'Unmute', ViewEvent.JWPLAYER_VIEW_MUTE, true); |
|---|
| 286 | addTextField('elapsed'); |
|---|
| 287 | addTextField('duration'); |
|---|
| 288 | addSlider('time', Slider.HORIZONTAL, ViewEvent.JWPLAYER_VIEW_CLICK, seekHandler); |
|---|
| 289 | addSlider('volume', Slider.HORIZONTAL, ViewEvent.JWPLAYER_VIEW_CLICK, volumeHandler); |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | |
|---|
| 293 | private function addComponentButton(name:String, text:String, event:String, eventData:* = null):void { |
|---|
| 294 | var button:ComponentButton = new ComponentButton(); |
|---|
| 295 | button.name = name; |
|---|
| 296 | button.setOutIcon(getSkinElement(name + "Button")); |
|---|
| 297 | button.setOverIcon(getSkinElement(name + "ButtonOver")); |
|---|
| 298 | button.setBackground(getSkinElement(name + "ButtonBack")); |
|---|
| 299 | button.outColor = player.config.lightcolor; |
|---|
| 300 | button.overColor = player.config.backcolor; |
|---|
| 301 | button.clickFunction = function():void { |
|---|
| 302 | forward(new ViewEvent(event, eventData)); |
|---|
| 303 | } |
|---|
| 304 | if (getSkinElement(name + "Button") |
|---|
| 305 | || getSkinElement(name + "ButtonOver") |
|---|
| 306 | || getSkinElement(name + "ButtonBack")) { |
|---|
| 307 | button.init(); |
|---|
| 308 | addButtonDisplayObject(button, name); |
|---|
| 309 | } |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | private function addSlider(name:String, orientation:String, event:String, callback:Function):void { |
|---|
| 314 | var slider:Slider = new Slider(getSkinElement(name + "SliderRail") as Sprite, getSkinElement(name + "SliderBuffer") as Sprite, getSkinElement(name + "SliderProgress") as Sprite, getSkinElement(name + "SliderThumb") as Sprite, orientation); |
|---|
| 315 | slider.addEventListener(event, callback); |
|---|
| 316 | slider.name = name; |
|---|
| 317 | _buttons[name] = slider; |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | |
|---|
| 321 | private function addTextField(name:String):void { |
|---|
| 322 | var textFormat:TextFormat = new TextFormat(); |
|---|
| 323 | textFormat.font = "_sans"; |
|---|
| 324 | textFormat.size = 10; |
|---|
| 325 | textFormat.bold = true; |
|---|
| 326 | textFormat.color = player.config.frontcolor.color; |
|---|
| 327 | var textField:TextField = new TextField(); |
|---|
| 328 | textField.defaultTextFormat = textFormat; |
|---|
| 329 | textField.selectable = false; |
|---|
| 330 | textField.autoSize = TextFieldAutoSize.LEFT; |
|---|
| 331 | textField.name = name; |
|---|
| 332 | addChild(textField); |
|---|
| 333 | _buttons[name] = textField; |
|---|
| 334 | } |
|---|
| 335 | |
|---|
| 336 | |
|---|
| 337 | private function forward(evt:ViewEvent):void { |
|---|
| 338 | dispatchEvent(evt); |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | private function volumeHandler(evt:ViewEvent):void { |
|---|
| 343 | dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_VOLUME, evt.data * 100)); |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | |
|---|
| 347 | private function seekHandler(evt:ViewEvent):void { |
|---|
| 348 | var duration:Number = 0; |
|---|
| 349 | try { |
|---|
| 350 | duration = player.playlist.currentItem.duration; |
|---|
| 351 | } catch (err:Error) { |
|---|
| 352 | } |
|---|
| 353 | var percent:Number = Math.round(duration * evt.data); |
|---|
| 354 | dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_SEEK, percent)); |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | |
|---|
| 358 | public function addButton(icon:DisplayObject, name:String, handler:Function = null):MovieClip { |
|---|
| 359 | _defaultLayout = _defaultLayout.replace("|fullscreen","|"+name+"|fullscreen"); |
|---|
| 360 | return addButtonDisplayObject(icon, name, handler); |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | private function addButtonDisplayObject(icon:DisplayObject, name:String, handler:Function = null):MovieClip{ |
|---|
| 364 | if (icon) { |
|---|
| 365 | var clipMC:MovieClip = new MovieClip(); |
|---|
| 366 | if (handler != null) { |
|---|
| 367 | clipMC.addEventListener(MouseEvent.CLICK, handler); |
|---|
| 368 | } |
|---|
| 369 | clipMC.name = name; |
|---|
| 370 | clipMC.addChild(icon); |
|---|
| 371 | _buttons[name] = clipMC; |
|---|
| 372 | return clipMC; |
|---|
| 373 | } |
|---|
| 374 | return null; |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | public function removeButton(name:String):void { |
|---|
| 378 | _buttons[name] = null; |
|---|
| 379 | redraw(); |
|---|
| 380 | } |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | private function hideButton(name:String):void { |
|---|
| 384 | if (_buttons[name]) { |
|---|
| 385 | _buttons[name].visible = false; |
|---|
| 386 | } |
|---|
| 387 | } |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | public function getButton(buttonName:String):DisplayObject { |
|---|
| 391 | if (buttonName == "divider") { |
|---|
| 392 | var divider:DisplayObject = getSkinElement("divider"); |
|---|
| 393 | if (divider) { |
|---|
| 394 | _dividers.push(divider); |
|---|
| 395 | } |
|---|
| 396 | return divider; |
|---|
| 397 | } |
|---|
| 398 | return _buttons[buttonName]; |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| 401 | |
|---|
| 402 | public function resize(width:Number, height:Number):void { |
|---|
| 403 | _width = width; |
|---|
| 404 | |
|---|
| 405 | if (getConfigParam('position') == 'over' || _player.fullscreen == true) { |
|---|
| 406 | player.config.pluginConfig("controlbar")['x'] = getConfigParam('margin'); |
|---|
| 407 | player.config.pluginConfig("controlbar")['y'] = height - background.height - getConfigParam('margin'); |
|---|
| 408 | _width = width - 2 * getConfigParam('margin'); |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | //shade.width = _width; |
|---|
| 412 | |
|---|
| 413 | var backgroundWidth:Number = _width; |
|---|
| 414 | |
|---|
| 415 | backgroundWidth -= capLeft.width; |
|---|
| 416 | capLeft.x = 0; |
|---|
| 417 | |
|---|
| 418 | backgroundWidth -= capRight.width; |
|---|
| 419 | capRight.x = _width - capRight.width; |
|---|
| 420 | |
|---|
| 421 | background.width = backgroundWidth; |
|---|
| 422 | background.x = capLeft.width; |
|---|
| 423 | setChildIndex(capLeft,numChildren-1); |
|---|
| 424 | setChildIndex(capRight,numChildren-1); |
|---|
| 425 | |
|---|
| 426 | updateControlbarState(); |
|---|
| 427 | redraw(); |
|---|
| 428 | Mouse.show(); |
|---|
| 429 | } |
|---|
| 430 | |
|---|
| 431 | |
|---|
| 432 | private function redraw():void { |
|---|
| 433 | clearDividers(); |
|---|
| 434 | _layoutManager.resize(_width, _height); |
|---|
| 435 | } |
|---|
| 436 | |
|---|
| 437 | |
|---|
| 438 | private function clearDividers():void { |
|---|
| 439 | for (var i:Number = 0; i < _dividers.length; i++){ |
|---|
| 440 | _dividers[i].visible = false; |
|---|
| 441 | _dividers[i] = null; |
|---|
| 442 | } |
|---|
| 443 | _dividers = []; |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | public function get layout():String { |
|---|
| 447 | return _currentLayout; |
|---|
| 448 | } |
|---|
| 449 | |
|---|
| 450 | |
|---|
| 451 | private function getFont(textField:TextField):String { |
|---|
| 452 | var result:String; |
|---|
| 453 | if (textField) { |
|---|
| 454 | textField.getTextFormat().font; |
|---|
| 455 | } |
|---|
| 456 | return result; |
|---|
| 457 | } |
|---|
| 458 | |
|---|
| 459 | |
|---|
| 460 | private function get background():DisplayObject { |
|---|
| 461 | if (_buttons['background']) { |
|---|
| 462 | return _buttons['background']; |
|---|
| 463 | } |
|---|
| 464 | return (new Sprite()); |
|---|
| 465 | } |
|---|
| 466 | |
|---|
| 467 | |
|---|
| 468 | /*private function get shade():DisplayObject { |
|---|
| 469 | if (_buttons['shade']) { |
|---|
| 470 | return _buttons['shade']; |
|---|
| 471 | } |
|---|
| 472 | return (new Sprite()); |
|---|
| 473 | }*/ |
|---|
| 474 | |
|---|
| 475 | private function get capLeft():DisplayObject { |
|---|
| 476 | if (_buttons['capLeft']) { |
|---|
| 477 | return _buttons['capLeft']; |
|---|
| 478 | } |
|---|
| 479 | return (new Sprite()); |
|---|
| 480 | } |
|---|
| 481 | |
|---|
| 482 | private function get capRight():DisplayObject { |
|---|
| 483 | if (_buttons['capRight']) { |
|---|
| 484 | return _buttons['capRight']; |
|---|
| 485 | } |
|---|
| 486 | return (new Sprite()); |
|---|
| 487 | } |
|---|
| 488 | } |
|---|
| 489 | } |
|---|
| 490 | |
|---|