PageRenderTime 45ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 0ms

/client/com/yahoo/astra/fl/managers/AlertManager.as

http://reliability-circuit-generator.googlecode.com/
ActionScript | 707 lines | 377 code | 64 blank | 266 comment | 164 complexity | d5313e22490c6d17632284639a425013 MD5 | raw file
  1. /*
  2. Copyright (c) 2009 Yahoo! Inc. All rights reserved.
  3. The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
  4. */
  5. ???package com.yahoo.astra.fl.managers
  6. {
  7. import com.yahoo.astra.fl.controls.containerClasses.DialogBox;
  8. import flash.display.Sprite;
  9. import flash.display.DisplayObject;
  10. import flash.events.Event;
  11. import flash.display.Stage;
  12. import flash.events.MouseEvent;
  13. import fl.core.UIComponent;
  14. import flash.filters.BitmapFilterQuality;
  15. import flash.filters.BlurFilter;
  16. import flash.filters.BitmapFilter;
  17. import flash.text.TextFormat;
  18. import flash.text.TextFormatAlign;
  19. import com.yahoo.astra.utils.TextUtil;
  20. //--------------------------------------
  21. // Class description
  22. //--------------------------------------
  23. /**
  24. * The AlertManager class extends UIComponent and manages the queuing
  25. * and displaying of Alerts.
  26. *
  27. * @see fl.core.UIComponent
  28. *
  29. * @langversion 3.0
  30. * @playerversion Flash 9.0.28.0
  31. * @author Dwight Bridges
  32. */
  33. public class AlertManager extends UIComponent
  34. {
  35. //--------------------------------------
  36. // Constructor
  37. //--------------------------------------
  38. /**
  39. * @private (singleton constructor)
  40. *
  41. * @param container - object calling the alert
  42. */
  43. public function AlertManager(container:DisplayObject = null)
  44. {
  45. super();
  46. if(isLivePreview)
  47. {
  48. _livePreviewSkin = getDisplayObjectInstance("Background_skin") as Sprite;
  49. _livePreviewTitleBar = getDisplayObjectInstance("Title_skin") as Sprite;
  50. this.addChild(_livePreviewSkin);
  51. this.addChild(_livePreviewTitleBar);
  52. }
  53. else if(_allowInstantiation)
  54. {
  55. if(container != null)
  56. {
  57. _stage = container.stage;
  58. }
  59. else if(this.stage)
  60. {
  61. _stage = stage;
  62. parent.removeChild(this);
  63. }
  64. _allowInstantiation = false;
  65. if(_stage)
  66. {
  67. _stage.addEventListener(Event.RESIZE, stageResizeHandler, false, 0, true);
  68. _stage.addEventListener(Event.FULLSCREEN, stageResizeHandler, false, 0, true);
  69. _stage.addChild(this);
  70. }
  71. _overlay = new Sprite();
  72. addChild(_overlay);
  73. _overlay.visible = false;
  74. }
  75. }
  76. /**
  77. * @private
  78. */
  79. private static function setStage(container:Stage):void
  80. {
  81. _stage = container;
  82. _stage.addEventListener(Event.RESIZE, _alertManager.stageResizeHandler, false, 0, true);
  83. _stage.addEventListener(Event.FULLSCREEN, _alertManager.stageResizeHandler, false, 0, true);
  84. _stage.addChild(_alertManager);
  85. _overlay = new Sprite();
  86. _alertManager.addChild(_overlay);
  87. _overlay.visible = false;
  88. }
  89. //--------------------------------------
  90. // Properties
  91. //--------------------------------------
  92. /**
  93. * @private
  94. */
  95. //array containing an object for each alert requested by the createAlert method
  96. //the object contains parameters for the dialog box
  97. private static var _alertQueue:Array = [];
  98. /**
  99. * @private
  100. */
  101. private static var _alert:DialogBox;
  102. /**
  103. * @private
  104. */
  105. private static var _alertManager:AlertManager;
  106. /**
  107. * @private
  108. */
  109. private static var _stage:Stage;
  110. /**
  111. * @private
  112. */
  113. //used to enforce singleton class
  114. private static var _allowInstantiation:Boolean = true;
  115. /**
  116. * Alpha value of the overlay
  117. */
  118. public static var overlayAlpha:Number = .2;
  119. /**
  120. * The blur value of the parent object when the alert is present and modal
  121. */
  122. public static var modalBackgroundBlur:int = 2;
  123. /**
  124. * Maximum width of the alert
  125. */
  126. public static var maxWidth:int = 360;
  127. /**
  128. * Minimum width of the alert
  129. */
  130. public static var minWidth:int = 300;
  131. /**
  132. * Padding for the alert
  133. */
  134. public static var padding:int = 5;
  135. /**
  136. * Amount of space between buttons on the alert
  137. */
  138. public static var buttonSpacing:int = 2;
  139. /**
  140. * Amount of space between button rows on the alert
  141. */
  142. public static var buttonRowSpacing:int = 1;
  143. /**
  144. * Height of the buttons on the alert
  145. */
  146. public static var buttonHeight:int = 20;
  147. /**
  148. * Color of the text for the title bar on the alert
  149. */
  150. private static var _titleTextColor:uint;
  151. /**
  152. * Gets or sets the text color for the title bar. <strong>Note:</strong> Text color can now be styled by passing
  153. * a <code>TextFormat</code> object to the <code>setTitleBarStyle</code> method.
  154. *
  155. * @deprecated
  156. */
  157. public static function get titleTextColor():uint
  158. {
  159. AlertManager.getInstance();
  160. var tf:TextFormat;
  161. if(_alertManager.titleBarStyles.textFormat != null)
  162. {
  163. tf = _alertManager.titleBarStyles.textFormat as TextFormat;
  164. }
  165. else if(_alert.titleBar != null && (_alert.titleBar as UIComponent).getStyle("textFormat") != null)
  166. {
  167. tf = (_alert.titleBar as UIComponent).getStyle("textFormat") as TextFormat;
  168. }
  169. else
  170. {
  171. tf = new TextFormat("_sans", 11, 0xffffff, true, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0);
  172. }
  173. return tf.color as uint;
  174. }
  175. /**
  176. * @private (setter)
  177. */
  178. public static function set titleTextColor(value:uint):void
  179. {
  180. if(isNaN(value)) return;
  181. AlertManager.getInstance();
  182. var tempTf:TextFormat;
  183. if(_alertManager.titleBarStyles.textFormat != null)
  184. {
  185. tempTf = _alertManager.titleBarStyles.textFormat as TextFormat;
  186. }
  187. else if(_alert.titleBar != null && (_alert.titleBar as UIComponent).getStyle("textFormat") != null)
  188. {
  189. tempTf = (_alert.titleBar as UIComponent).getStyle("textFormat") as TextFormat;
  190. }
  191. else
  192. {
  193. tempTf = new TextFormat("_sans", 11, 0xffffff, true, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0);
  194. }
  195. AlertManager.setTitleBarStyle("textFormat", TextUtil.changeTextFormatProps(TextUtil.cloneTextFormat(tempTf), {color:value}));
  196. }
  197. /**
  198. * Color of the message text on the alert. <strong>Note:</strong> Text color can now be styled by passing a <code>TextFormat</code>
  199. * object to the <code>setMessageBoxStyle</code> method.
  200. *
  201. * @deprecated
  202. */
  203. public static function get textColor():uint
  204. {
  205. AlertManager.getInstance();
  206. var tf:TextFormat;
  207. if(_alertManager.messageBoxStyles.textFormat != null)
  208. {
  209. tf = _alertManager.messageBoxStyles.textFormat as TextFormat;
  210. }
  211. else if(_alert.messageBox != null && (_alert.messageBox as UIComponent).getStyle("textFormat") != null)
  212. {
  213. tf = (_alert.messageBox as UIComponent).getStyle("textFormat") as TextFormat;
  214. }
  215. else
  216. {
  217. tf = new TextFormat("_sans", 11, 0xffffff);
  218. }
  219. return tf.color as uint;
  220. }
  221. /**
  222. * @private (setter)
  223. */
  224. public static function set textColor(value:uint):void
  225. {
  226. if(isNaN(value)) return;
  227. AlertManager.getInstance();
  228. var tempTf:TextFormat;
  229. if(_alertManager.messageBoxStyles.textFormat != null)
  230. {
  231. tempTf = _alertManager.messageBoxStyles.textFormat as TextFormat;
  232. }
  233. else if(_alert.messageBox != null && (_alert.messageBox as UIComponent).getStyle("textFormat") != null)
  234. {
  235. tempTf = (_alert.messageBox as UIComponent).getStyle("textFormat") as TextFormat;
  236. }
  237. else
  238. {
  239. tempTf =new TextFormat("_sans", 11, 0xffffff);
  240. }
  241. AlertManager.setMessageBoxStyle("textFormat", TextUtil.changeTextFormatProps(TextUtil.cloneTextFormat(tempTf), {color:value}));
  242. }
  243. /**
  244. * Indicates whether the alert has a drop shadow
  245. */
  246. public static var hasDropShadow:Boolean = true;
  247. /**
  248. * direction of the alert's drop shadow
  249. */
  250. public static var shadowDirection:String = "right";
  251. /**
  252. * @private
  253. */
  254. private static var _overlay:Sprite;
  255. /**
  256. * The DisplayObject that uses the createAlert method to display an alert. The
  257. * AlertManager
  258. */
  259. protected var container:DisplayObject;
  260. /**
  261. * @private (protected)
  262. */
  263. //Copy of container's filters property. Used to return the container to it's original
  264. //state when the alert is removed.
  265. protected var parentFilters:Array;
  266. /**
  267. * @private
  268. *
  269. * Holds styles for TitleBar
  270. */
  271. public var titleBarStyles:Object = {};
  272. /**
  273. * @private
  274. *
  275. * Holds styles for MessageBox
  276. */
  277. public var messageBoxStyles:Object = {};
  278. /**
  279. * @private
  280. *
  281. * Holds styles for Buttons
  282. */
  283. private var buttonStyles:Object = {};
  284. /**
  285. * @private
  286. *
  287. * Holds styles for DialogBox
  288. */
  289. private var alertStyles:Object = {};
  290. /**
  291. * @private
  292. */
  293. private var _livePreviewTitleBar:Sprite;
  294. /**
  295. * @private
  296. */
  297. private var _livePreviewSkin:Sprite;
  298. //--------------------------------------
  299. // Public Methods
  300. //--------------------------------------
  301. /**
  302. * Creates an instance of AlertManager.
  303. *
  304. * @param container - display object creating an alert box
  305. *
  306. * @return AlertManager
  307. */
  308. public static function getInstance(container:DisplayObject = null):AlertManager
  309. {
  310. if(_alertManager == null)
  311. {
  312. _allowInstantiation = true;
  313. _alertManager = new AlertManager(container);
  314. _allowInstantiation = false;
  315. }
  316. return _alertManager;
  317. }
  318. /**
  319. * Creates an alert and puts it in the queue. If it is the first alert or all
  320. * previous alerts have been displayed, it will show the alert. If this is the
  321. * first alert, the class is instantiated.
  322. *
  323. * @param container - display object creating an alert box
  324. * @param message - message to be displayed
  325. * @param title - text to show in the title bar
  326. * @param buttons - array containing the name of the buttons to be displayed
  327. * @param callBackFunction - function to be called when a button is pressed
  328. * @param iconClass - string value indicating the library object to be used for an icon
  329. * @param isModal - boolean indicating whether or not to prevent interaction with the parent while the message box is present
  330. * @param props - Optional parameters will only affect the single alert instance. Any of the following any of the following
  331. * properties can be used:
  332. * <br />
  333. * <table class="innertable" width="100%">
  334. * <tr><th>Property</th><th>Purpose</th></tr>
  335. * <tr><td>maxWidth</td><td>Indicates the maximum allowed width of the alert.</td></tr>
  336. * <tr><td>minWidth</td><td>Indicates the minimum allowed width of the alert.</td></tr>
  337. * <tr><td>padding</td><td>Indicates the amount of padding on the alert.</td></tr>
  338. * <tr><td>buttonHeight</td><td>Indicates the height of buttons on an alert.</td></tr>
  339. * <tr><td>buttonSpacing</td><td>Indicates the space between buttons on an alert.</td></tr>
  340. * <tr><td>hadDropShadow</td><td>Indicates whether or not the alert has a drop shadow.</td></tr>
  341. * <tr><td>shadowDirection</td><td>Indicates the direction of a drop shadow.</td></tr>
  342. * <tr><td>titleBarStyles</td><td>Set styles on the title bar of the alert box.</td></tr>
  343. * <tr><td>messageBoxStyles</td><td>Sets styles on the message text field of the alert.</td></tr>
  344. * <tr><td>buttonStyles</td><td>Styles set on the alert buttons.</td></tr>
  345. * <tr><td>alertStyles</td><td>Sets styles on the alert.</td></tr>
  346. * <tr><td>textColor (deprecated)</td><td>Sets the color of the message text. <strong>Note:</code> this property has been
  347. * deprecated in favor of using the <code>alertStyles.textFormat</code> style.</td></tr>
  348. * <tr><td>titleTextColor (deprecated)</td><td>Sets the color of the title text. <strong>Note:</code> this property has
  349. * been deprecated in favor of using the <code>titleBarStyles.textFormat</code> style.</td></tr>
  350. * </table>
  351. *
  352. * @return AlertManager
  353. *
  354. * @langversion 3.0
  355. * @playerversion Flash 9.0.28.0
  356. */
  357. public static function createAlert(container:DisplayObject,
  358. message:String,
  359. title:String = "Alert",
  360. buttons:Array = null,
  361. callBackFunction:Function = null,
  362. iconClass:String = null,
  363. isModal:Boolean = true,
  364. props:Object = null):AlertManager
  365. {
  366. AlertManager.getInstance(container);
  367. if(_stage == null) setStage(container.stage);
  368. if(_alert == null)
  369. {
  370. _alert = new DialogBox(_stage);
  371. _alertManager.addChild(_alert);
  372. }
  373. _alertManager.copyRendererStylesToChild(_alert.titleBar, _alertManager.titleBarStyles);
  374. _alertManager.copyRendererStylesToChild(_alert.messageBox, _alertManager.messageBoxStyles);
  375. _alertManager.setButtonStyles(_alertManager.buttonStyles);
  376. _alertManager.copyRendererStylesToChild(_alert, _alertManager.alertStyles);
  377. if(buttons == null) buttons = ["OK"];
  378. var functions:Array = [];
  379. if(callBackFunction != null) functions.push(callBackFunction);
  380. functions.push(_alertManager.manageQueue);
  381. var alertParams:Object = {
  382. message:message,
  383. title:title,
  384. isModal:isModal,
  385. buttons:buttons,
  386. functions:functions,
  387. iconClass:iconClass,
  388. props:props,
  389. container:container
  390. };
  391. if(_alertQueue.length == 0)
  392. {
  393. _alert.maxWidth = (props != null && !isNaN(props.maxWidth))?Math.round(props.maxWidth) as int:maxWidth;
  394. _alert.minWidth = (props != null && !isNaN(props.minWidth))?Math.round(props.minWidth) as int:minWidth;
  395. _alert.padding = (props != null && !isNaN(props.padding))?Math.round(props.padding) as int:padding;
  396. _alert.buttonHeight = (props != null && !isNaN(props.buttonHeight))?Math.round(props.buttonHeight) as int:buttonHeight;
  397. _alert.buttonRowSpacing = (props != null && !isNaN(props.buttonRowSpacing))?Math.round(props.buttonRowSpacing) as int:buttonRowSpacing;
  398. _alert.buttonSpacing = (props != null && !isNaN(props.buttonSpacing))?Math.round(props.buttonSpacing) as int:buttonSpacing;
  399. _alert.hasDropShadow = (props != null && props.hasDropShadow != null)?props.hasDropShadow:hasDropShadow;
  400. _alert.shadowDirection = (props != null && props.shadowDirection != null)?props.shadowDirection:shadowDirection;
  401. if(props != null && props.titleBarStyles != null) _alertManager.copyRendererStylesToChild(_alert.titleBar, props.titleBarStyles);
  402. if(props != null && props.messageBoxStyles != null) _alertManager.copyRendererStylesToChild(_alert.messageBox, props.messageBoxStyles);
  403. if(props != null && !isNaN(props.textColor)) _alert.messageBox.setStyle("textFormat", _alertManager.replaceUIComponentTextColor(_alert.messageBox as UIComponent, props.textColor));//AlertManager.textColor = props.textColor as uint;
  404. if(props != null && !isNaN(props.titleTextColor)) _alert.titleBar.setStyle("textFormat", _alertManager.replaceUIComponentTextColor(_alert.titleBar as UIComponent, props.titleTextColor));
  405. if(props != null && props.buttonStyles != null) _alertManager.setButtonStyles(props.buttonStyles);
  406. if(props != null && props.alertStyles != null) _alertManager.copyRendererStylesToChild(_alert, props.alertStyles);
  407. _alert.update(message, title, buttons, functions, iconClass);
  408. _overlay.visible = isModal;
  409. if(isModal)
  410. {
  411. _alertManager.container = container;
  412. var newFilters:Array;
  413. newFilters = _alertManager.container.filters.concat();
  414. _alertManager.parentFilters = _alertManager.container.filters.concat();
  415. newFilters.push(_alertManager.getBlurFilter());
  416. _alertManager.container.filters = newFilters;
  417. }
  418. }
  419. _alertQueue.push(alertParams);
  420. return _alertManager;
  421. }
  422. /**
  423. * Removes the current alert from the messages array. If there are more alerts,
  424. * call pass the params for the next alert to the DialogBox object. Otherwise,
  425. * hide the alert object and the cover.</p>
  426. *
  427. * @evnt - Mouse event received from the DialogBox object
  428. *
  429. * @langversion 3.0
  430. * @playerversion Flash 9.0.28.0
  431. */
  432. public function manageQueue(evnt:MouseEvent):void
  433. {
  434. _alertQueue.splice(0, 1);
  435. _alertManager.container.filters = _alertManager.parentFilters;
  436. if(_alertQueue.length > 0)
  437. {
  438. _stage.setChildIndex(this, _stage.numChildren - 1);
  439. var params:Object = _alertQueue[0];
  440. var props:Object = params.props;
  441. _alert.maxWidth = (props != null && !isNaN(props.maxWidth))?Math.round(props.maxWidth) as int:maxWidth;
  442. _alert.minWidth = (props != null && !isNaN(props.minWidth))?Math.round(props.minWidth) as int:minWidth;
  443. _alert.padding = (props != null && !isNaN(props.padding))?Math.round(props.padding) as int:padding;
  444. _alert.buttonHeight = (props != null && !isNaN(props.buttonHeight))?Math.round(props.buttonHeight) as int:buttonHeight;
  445. _alert.buttonRowSpacing = (props != null && !isNaN(props.buttonRowSpacing))?Math.round(props.buttonRowSpacing) as int:buttonRowSpacing;
  446. _alert.buttonSpacing = (props != null && !isNaN(props.buttonSpacing))?Math.round(props.buttonSpacing) as int:buttonSpacing;
  447. _alert.hasDropShadow = (props != null && props.hasDropShadow != null)?props.hasDropShadow:hasDropShadow;
  448. _alert.shadowDirection = (props != null && props.shadowDirection != null)?props.shadowDirection:shadowDirection;
  449. if(props != null && props.titleBarStyles != null) _alertManager.copyRendererStylesToChild(_alert.titleBar, props.titleBarStyles);
  450. if(props != null && props.messageBoxStyles != null) _alertManager.copyRendererStylesToChild(_alert.messageBox, props.messageBoxStyles);
  451. if(props != null && !isNaN(props.textColor)) _alert.messageBox.setStyle("textFormat", _alertManager.replaceUIComponentTextColor(_alert.messageBox as UIComponent, props.textColor));//AlertManager.textColor = props.textColor as uint;
  452. if(props != null && !isNaN(props.titleTextColor)) _alert.titleBar.setStyle("textFormat", _alertManager.replaceUIComponentTextColor(_alert.titleBar as UIComponent, props.titleTextColor));
  453. if(props != null && props.buttonStyles != null) _alertManager.setButtonStyles(props.buttonStyles);
  454. if(props != null && props.alertStyles != null) _alertManager.copyRendererStylesToChild(_alert, props.alertStyles);
  455. _alert.update(params.message, params.title, params.buttons, params.functions, params.iconClass);
  456. _overlay.visible = params.isModal;
  457. if(params.isModal)
  458. {
  459. _alertManager.container = params.container;
  460. var newFilters:Array;
  461. newFilters = _alertManager.container.filters.concat();
  462. _alertManager.parentFilters = _alertManager.container.filters.concat();
  463. newFilters.push(_alertManager.getBlurFilter());
  464. _alertManager.container.filters = newFilters;
  465. }
  466. }
  467. else
  468. {
  469. _alert.visible = false;
  470. _overlay.visible = false;
  471. }
  472. }
  473. /**
  474. * Gets a blur filter to add to the parent's <code>filters</code> property.
  475. *
  476. * @return BitmapFilter with specified blur values
  477. *
  478. * @langversion 3.0
  479. * @playerversion Flash 9.0.28.0
  480. */
  481. public function getBlurFilter():BitmapFilter
  482. {
  483. var blurFilter:BlurFilter = new BlurFilter();
  484. blurFilter.blurX = modalBackgroundBlur;
  485. blurFilter.blurY = modalBackgroundBlur;
  486. blurFilter.quality = BitmapFilterQuality.HIGH;
  487. return blurFilter;
  488. }
  489. /**
  490. * Set styles on the TitleBar
  491. *
  492. * @see com.yahoo.astra.fl.controls.containerClasses.TitleBar
  493. */
  494. public static function setTitleBarStyle(name:String, style:Object):void
  495. {
  496. AlertManager.getInstance();
  497. if (_alertManager.titleBarStyles[name] == style) return;
  498. _alertManager.titleBarStyles[name] = style;
  499. if(_alert != null && _alert.titleBar != null) (_alert.titleBar as UIComponent).setStyle(name, style);
  500. }
  501. /**
  502. * Sets styles on a the Alert message
  503. *
  504. * @see com.yahoo.astra.fl.controls.containerClasses.MessageBox
  505. */
  506. public static function setMessageBoxStyle(name:String, style:Object):void
  507. {
  508. AlertManager.getInstance();
  509. if (_alertManager.messageBoxStyles[name] == style) { return; }
  510. _alertManager.messageBoxStyles[name] = style;
  511. if(_alert != null && _alert.messageBox != null) (_alert.messageBox as UIComponent).setStyle(name, style);
  512. }
  513. /**
  514. * Sets the styles for buttons
  515. *
  516. * @see com.yahoo.astra.fl.controls.containerClasses.AutoSizeButton
  517. */
  518. public static function setButtonStyle(name:String, style:Object):void
  519. {
  520. AlertManager.getInstance();
  521. if(_alertManager.buttonStyles[name] == style) return;
  522. _alertManager.buttonStyles[name] = style;
  523. if(_alert != null && _alert.buttonBar != null) _alert.buttonBar.setButtonStyle(name, style);
  524. }
  525. /**
  526. * Sets styles for the Alert
  527. *
  528. * @see com.yahoo.astra.fl.controls.containerClasses.DialogBox
  529. */
  530. public static function setAlertStyle(name:String, style:Object):void
  531. {
  532. AlertManager.getInstance();
  533. if(_alertManager.alertStyles[name] == style) return;
  534. _alertManager.alertStyles[name] = style;
  535. if(_alert != null) _alert.setStyle(name, style);
  536. }
  537. //--------------------------------------
  538. // Protected Methods
  539. //-------------------------------------
  540. /**
  541. * @private (protected)
  542. *
  543. * @langversion 3.0
  544. * @playerversion Flash 9.0.28.0
  545. */
  546. protected override function configUI():void
  547. {
  548. super.configUI();
  549. }
  550. /**
  551. * @private (protected)
  552. *
  553. * @langversion 3.0
  554. * @playerversion Flash 9.0.28.0
  555. */
  556. //Set the width and height to that of the stage and redraw the cover object.
  557. protected override function draw():void
  558. {
  559. if(this.isLivePreview)
  560. {
  561. _livePreviewSkin.width = this.width;
  562. _livePreviewSkin.height = this.height;
  563. _livePreviewTitleBar.width = this.width;
  564. _livePreviewTitleBar.height = Math.min(20,this.height/5);
  565. }
  566. else
  567. {
  568. //set the dimensions
  569. this.width = _stage.stageWidth;
  570. this.height = _stage.stageHeight;
  571. this.x = _stage.x;
  572. this.y = _stage.y;
  573. _overlay.x = _overlay.y = 0;
  574. _overlay.width = this.width;
  575. _overlay.height = this.height;
  576. _overlay.graphics.clear();
  577. _overlay.graphics.beginFill(0xeeeeee, overlayAlpha);
  578. _overlay.graphics.moveTo(0,0);
  579. _overlay.graphics.lineTo(this.width, 0);
  580. _overlay.graphics.lineTo(this.width, this.height);
  581. _overlay.graphics.lineTo(0, this.height);
  582. _overlay.graphics.lineTo(0, 0);
  583. _overlay.graphics.endFill();
  584. if(_alert != null) _alert.positionAlert();
  585. }
  586. }
  587. /**
  588. * @private (protected)
  589. *
  590. * @param evnt - event fired from the stage
  591. *
  592. * @langversion 3.0
  593. * @playerversion Flash 9.0.28.0
  594. */
  595. //Call the draw function when the stage is resized
  596. protected function stageResizeHandler(evnt:Event):void
  597. {
  598. draw();
  599. }
  600. /**
  601. * @private
  602. *
  603. * @param styleMap - styles to be set on the buttonBar instance
  604. */
  605. private function setButtonStyles(styleMap:Object):void
  606. {
  607. for(var n:String in styleMap)
  608. {
  609. _alert.buttonBar.setButtonStyle(n, styleMap[n])
  610. }
  611. }
  612. /**
  613. * @private
  614. *
  615. * @langversion 3.0
  616. * @playerversion Flash 9.0.28.0
  617. */
  618. private function copyRendererStylesToChild(child:UIComponent,styleMap:Object):void
  619. {
  620. for (var n:String in styleMap)
  621. {
  622. child.setStyle(n, styleMap[n]);
  623. }
  624. }
  625. /**
  626. * @private
  627. * Helper function used to handle deprecated text color properties
  628. */
  629. private function replaceUIComponentTextColor(ui:UIComponent, value:uint):TextFormat
  630. {
  631. var tempTf:TextFormat;
  632. if(ui != null && ui.getStyle("textFormat") != null)
  633. {
  634. tempTf = ui.getStyle("textFormat") as TextFormat;
  635. }
  636. else
  637. {
  638. tempTf = new TextFormat("_sans", 11, value);
  639. }
  640. return TextUtil.changeTextFormatProps(TextUtil.cloneTextFormat(tempTf), {color:value});
  641. }
  642. }
  643. }