PageRenderTime 58ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/Sample/mx/managers/PopUpManagerImpl.as

https://github.com/ingydotnet/yaml-oscon2009-talk
ActionScript | 1826 lines | 1056 code | 243 blank | 527 comment | 201 complexity | 201013c0b84a75aea0a3bca90e6454ae MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // ADOBE SYSTEMS INCORPORATED
  4. // Copyright 2006-2007 Adobe Systems Incorporated
  5. // All Rights Reserved.
  6. //
  7. // NOTICE: Adobe permits you to use, modify, and distribute this file
  8. // in accordance with the terms of the license agreement accompanying it.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. package mx.managers
  12. {
  13. import flash.display.DisplayObject;
  14. import flash.display.DisplayObjectContainer;
  15. import flash.display.Graphics;
  16. import flash.display.InteractiveObject;
  17. import flash.display.Shape;
  18. import flash.display.Sprite;
  19. import flash.events.Event;
  20. import flash.events.IEventDispatcher;
  21. import flash.events.MouseEvent;
  22. import flash.geom.Point;
  23. import flash.geom.Rectangle;
  24. import flash.display.Stage;
  25. import flash.utils.Proxy;
  26. import mx.automation.IAutomationObject;
  27. import mx.containers.Canvas;
  28. import mx.controls.Alert;
  29. import mx.core.ApplicationGlobals;
  30. import mx.core.FlexSprite;
  31. import mx.core.IChildList;
  32. import mx.core.IFlexDisplayObject;
  33. import mx.core.IFlexModule;
  34. import mx.core.IInvalidating;
  35. import mx.core.ISWFLoader;
  36. import mx.core.IUIComponent;
  37. import mx.core.UIComponentGlobals;
  38. import mx.core.mx_internal;
  39. import mx.effects.Blur;
  40. import mx.effects.IEffect;
  41. import mx.effects.Fade;
  42. import mx.events.EffectEvent;
  43. import mx.events.FlexEvent;
  44. import mx.events.FlexMouseEvent;
  45. import mx.events.MoveEvent;
  46. import mx.events.SWFBridgeRequest;
  47. import mx.managers.ISystemManager;
  48. import mx.managers.SystemManager;
  49. import mx.managers.SystemManagerProxy;
  50. import mx.styles.IStyleClient;
  51. import mx.utils.NameUtil;
  52. import mx.events.InterManagerRequest;
  53. import mx.core.UIComponent;
  54. import mx.events.SandboxMouseEvent;
  55. use namespace mx_internal;
  56. [ExcludeClass]
  57. /**
  58. * @private
  59. * The PopUpManager singleton class creates new top-level windows and
  60. * places or removes those windows from the layer on top of all other
  61. * visible windows. See the SystemManager for a description of the layering.
  62. * It is used for popup dialogs, menus, and dropdowns in the ComboBox control
  63. * and in similar components.
  64. *
  65. * <p>The PopUpManager also provides modality, so that windows below the popup
  66. * cannot receive mouse events, and also provides an event if the user clicks
  67. * the mouse outside the window so the developer can choose to dismiss
  68. * the window or warn the user.</p>
  69. *
  70. * @see PopUpManagerChildList
  71. */
  72. public class PopUpManagerImpl implements IPopUpManager
  73. {
  74. include "../core/Version.as";
  75. //--------------------------------------------------------------------------
  76. //
  77. // Class variables
  78. //
  79. //--------------------------------------------------------------------------
  80. /**
  81. * @private
  82. */
  83. private static var instance:IPopUpManager;
  84. //--------------------------------------------------------------------------
  85. //
  86. // Class methods
  87. //
  88. //--------------------------------------------------------------------------
  89. /**
  90. * @private
  91. */
  92. public static function getInstance():IPopUpManager
  93. {
  94. if (!instance)
  95. instance = new PopUpManagerImpl();
  96. return instance;
  97. }
  98. //--------------------------------------------------------------------------
  99. //
  100. // Constructor
  101. //
  102. //--------------------------------------------------------------------------
  103. /**
  104. * @private
  105. */
  106. public function PopUpManagerImpl()
  107. {
  108. super();
  109. var sm:ISystemManager = ISystemManager(SystemManagerGlobals.topLevelSystemManagers[0]);
  110. sm.addEventListener(SWFBridgeRequest.CREATE_MODAL_WINDOW_REQUEST, createModalWindowRequestHandler, false, 0, true);
  111. sm.addEventListener(SWFBridgeRequest.SHOW_MODAL_WINDOW_REQUEST, showModalWindowRequest, false, 0, true);
  112. sm.addEventListener(SWFBridgeRequest.HIDE_MODAL_WINDOW_REQUEST, hideModalWindowRequest, false, 0, true);
  113. }
  114. //--------------------------------------------------------------------------
  115. //
  116. // Variables
  117. //
  118. //--------------------------------------------------------------------------
  119. /**
  120. * @private
  121. * The class used to create the shield that makes a window appear modal.
  122. */
  123. mx_internal var modalWindowClass:Class;
  124. /**
  125. * @private
  126. * An array of information about currently active popups
  127. */
  128. private var popupInfo:Array;
  129. //--------------------------------------------------------------------------
  130. //
  131. // Methods
  132. //
  133. //--------------------------------------------------------------------------
  134. /**
  135. * Creates a top-level window and places it above other windows in the
  136. * z-order.
  137. * It is good practice to call the <code>removePopUp()</code> method
  138. * to remove popups created by using the <code>createPopUp()</code> method.
  139. *
  140. * If the class implements IFocusManagerContainer, the window will have its
  141. * own FocusManager so that, if the user uses the TAB key to navigate between
  142. * controls, only the controls in the window will be accessed.
  143. *
  144. * <p><b>Example</b></p>
  145. *
  146. * <pre>pop = mx.managers.PopUpManager.createPopUp(pnl, TitleWindow, false); </pre>
  147. *
  148. * <p>Creates a popup window based on the TitleWindow class, using <code>pnl</code> as the MovieClip
  149. * for determining where to place the popup. It is defined to be a non-modal window
  150. * meaning that other windows can receive mouse events</p>
  151. *
  152. * @param parent DisplayObject to be used for determining which SystemManager's layers
  153. * to use and optionally the reference point for centering the new
  154. * top level window. It may not be the actual parent of the popup as all popups
  155. * are parented by the SystemManager.
  156. *
  157. * @param className Class of object that is to be created for the popup.
  158. * The class must implement IFlexDisplayObject.
  159. *
  160. * @param modal If <code>true</code>, the window is modal which means that
  161. * the user will not be able to interact with other popups until the window
  162. * is removed.
  163. *
  164. * @param childList The child list in which to add the popup.
  165. * One of <code>PopUpManagerChildList.APPLICATION</code>,
  166. * <code>PopUpManagerChildList.POPUP</code>,
  167. * or <code>PopUpManagerChildList.PARENT</code> (default).
  168. *
  169. * @return Reference to new top-level window.
  170. *
  171. * @see PopUpManagerChildList
  172. */
  173. public function createPopUp(parent:DisplayObject,
  174. className:Class,
  175. modal:Boolean = false,
  176. childList:String = null):IFlexDisplayObject
  177. {
  178. const window:IUIComponent = new className();
  179. addPopUp(window, parent, modal, childList);
  180. return window;
  181. }
  182. /**
  183. * Pops up a top-level window.
  184. * It is good practice to call <code>removePopUp()</code> to remove popups
  185. * created by using the <code>createPopUp()</code> method.
  186. * If the class implements IFocusManagerContainer, the window will have its
  187. * own FocusManager so that, if the user uses the TAB key to navigate between
  188. * controls, only the controls in the window will be accessed.
  189. *
  190. * <p><b>Example</b></p>
  191. *
  192. * <pre>var tw = new TitleWindow();
  193. * tw.title = "My Title";
  194. * mx.managers.PopUpManager.addPopUp(tw, pnl, false);</pre>
  195. *
  196. * <p>Creates a popup window using the <code>tw</code> instance of the
  197. * TitleWindow class and <code>pnl</code> as the Sprite for determining
  198. * where to place the popup.
  199. * It is defined to be a non-modal window.</p>
  200. *
  201. * @param window The IFlexDisplayObject to be popped up.
  202. *
  203. * @param parent DisplayObject to be used for determining which SystemManager's layers
  204. * to use and optionally the reference point for centering the new
  205. * top level window. It may not be the actual parent of the popup as all popups
  206. * are parented by the SystemManager.
  207. *
  208. * @param modal If <code>true</code>, the window is modal which means that
  209. * the user will not be able to interact with other popups until the window
  210. * is removed.
  211. *
  212. * @param childList The child list in which to add the pop-up.
  213. * One of <code>PopUpManagerChildList.APPLICATION</code>,
  214. * <code>PopUpManagerChildList.POPUP</code>,
  215. * or <code>PopUpManagerChildList.PARENT</code> (default).
  216. *
  217. * @see PopUpManagerChildList
  218. */
  219. public function addPopUp(window:IFlexDisplayObject,
  220. parent:DisplayObject,
  221. modal:Boolean = false,
  222. childList:String = null):void
  223. {
  224. // trace("POPUP: window is " + window);
  225. // All popups go on the local root.
  226. // trace("POPUP: root is " + parent.root);
  227. // trace("POPUP: initial parent is " + parent);
  228. const visibleFlag:Boolean = window.visible;
  229. if (parent is IUIComponent && window is IUIComponent &&
  230. IUIComponent(window).document == null)
  231. IUIComponent(window).document = IUIComponent(parent).document;
  232. if (parent is IUIComponent && IUIComponent(parent).document is IFlexModule &&
  233. window is UIComponent && UIComponent(window).moduleFactory == null)
  234. UIComponent(window).moduleFactory = IFlexModule(IUIComponent(parent).document).moduleFactory;
  235. var sm:ISystemManager = getTopLevelSystemManager(parent);
  236. var children:IChildList;
  237. var topMost:Boolean;
  238. if (!sm)
  239. {
  240. // check if parent is our sandbox root
  241. sm = ISystemManager(SystemManagerGlobals.topLevelSystemManagers[0]);
  242. if (sm.getSandboxRoot() != parent)
  243. {
  244. //trace("error: popup root was not SystemManager");
  245. return; // and maybe a nice error message
  246. }
  247. }
  248. var smp:ISystemManager = sm;
  249. // if using a bridge, then create a System Manager Proxy to host
  250. // the popup. The System Manager Proxy is the display object
  251. // added to the top-level system manager's children, not
  252. // the popup itself.
  253. var sbRoot:DisplayObject = sm.getSandboxRoot();
  254. var request:SWFBridgeRequest = null;
  255. if (sm.useSWFBridge())
  256. {
  257. if (sbRoot != sm)
  258. {
  259. smp = new SystemManagerProxy(sm);
  260. request = new SWFBridgeRequest(SWFBridgeRequest.ADD_POP_UP_REQUEST, false, false,
  261. sm.swfBridgeGroup.parentBridge,
  262. { window: DisplayObject(smp),
  263. parent: parent,
  264. modal: modal,
  265. childList: childList});
  266. sbRoot.dispatchEvent(request);
  267. }
  268. else
  269. smp = sm; // host w/o system manager proxy.
  270. }
  271. if (window is IUIComponent)
  272. IUIComponent(window).isPopUp = true;
  273. if (!childList || childList == PopUpManagerChildList.PARENT)
  274. topMost = smp.popUpChildren.contains(parent);
  275. else
  276. topMost = (childList == PopUpManagerChildList.POPUP);
  277. children = topMost ? smp.popUpChildren : smp;
  278. children.addChild(DisplayObject(window));
  279. window.visible = false;
  280. if (!popupInfo)
  281. popupInfo = [];
  282. const o:PopUpData = new PopUpData();
  283. o.owner = DisplayObject(window);
  284. o.topMost = topMost;
  285. o.systemManager = smp;
  286. popupInfo.push(o);
  287. if (window is IFocusManagerContainer)
  288. {
  289. if (IFocusManagerContainer(window).focusManager)
  290. smp.addFocusManager(IFocusManagerContainer(window));
  291. else
  292. // Popups get their own focus loop
  293. IFocusManagerContainer(window).focusManager =
  294. new FocusManager(IFocusManagerContainer(window), true);
  295. }
  296. // add a placeholder for an untrusted popup if this system manager
  297. // is hosting the popup.
  298. if (!sm.isTopLevelRoot() && sbRoot && sm == sbRoot)
  299. {
  300. request = new SWFBridgeRequest(SWFBridgeRequest.ADD_POP_UP_PLACE_HOLDER_REQUEST, false, false, null, { window: DisplayObject(window)});
  301. request.requestor = sm.swfBridgeGroup.parentBridge;
  302. request.data.placeHolderId = NameUtil.displayObjectToString(DisplayObject(window));
  303. sm.dispatchEvent(request);
  304. }
  305. // force into automation hierarchy
  306. if (window is IAutomationObject)
  307. IAutomationObject(window).showInAutomationHierarchy = true;
  308. if (window is ILayoutManagerClient )
  309. UIComponentGlobals.layoutManager.validateClient(ILayoutManagerClient (window), true);
  310. o.parent = parent;
  311. if (window is IUIComponent)
  312. {
  313. IUIComponent(window).setActualSize(
  314. IUIComponent(window).getExplicitOrMeasuredWidth(),
  315. IUIComponent(window).getExplicitOrMeasuredHeight());
  316. }
  317. if (modal)
  318. {
  319. // create a modal window shield which blocks input and sets up mouseDownOutside logic
  320. createModalWindow(parent, o, children, visibleFlag, smp, sbRoot);
  321. }
  322. else
  323. {
  324. o._mouseDownOutsideHandler = nonmodalMouseDownOutsideHandler;
  325. o._mouseWheelOutsideHandler = nonmodalMouseWheelOutsideHandler;
  326. window.visible = visibleFlag;
  327. }
  328. // Add show/hide listener so mouse out listeners can be added when
  329. // a pop up is shown because applications can be launched and
  330. // terminated between the time a pop up is hidden to when it is
  331. // shown again.
  332. o.owner.addEventListener(FlexEvent.SHOW, showOwnerHandler);
  333. o.owner.addEventListener(FlexEvent.HIDE, hideOwnerHandler);
  334. addMouseOutEventListeners(o);
  335. // Listen for unload so we know to kill the window (and the modalWindow if modal)
  336. // this handles _all_ cleanup
  337. window.addEventListener(Event.REMOVED, popupRemovedHandler);
  338. if (window is IFocusManagerContainer && visibleFlag)
  339. {
  340. if (!(smp is SystemManagerProxy) && smp.useSWFBridge())
  341. // We want the top-level root to activate the window.
  342. SystemManager(smp).dispatchActivatedWindowEvent(DisplayObject(window));
  343. else
  344. smp.activate(IFocusManagerContainer(window));
  345. }
  346. // trace("END POPUP: addPopUp" + parent);
  347. }
  348. private function getTopLevelSystemManager(parent:DisplayObject):ISystemManager
  349. {
  350. var localRoot:DisplayObjectContainer;
  351. var sm:ISystemManager;
  352. if (parent.parent is SystemManagerProxy)
  353. localRoot = DisplayObjectContainer(SystemManagerProxy(parent.parent).systemManager);
  354. else if (parent is IUIComponent && IUIComponent(parent).systemManager is SystemManagerProxy)
  355. localRoot = DisplayObjectContainer(SystemManagerProxy(IUIComponent(parent).systemManager).systemManager);
  356. else
  357. localRoot = DisplayObjectContainer(parent.root);
  358. // If the parent isn't rooted yet,
  359. // Or the root is the stage (which is the case in a second AIR window)
  360. // use the global system manager instance.
  361. if ((!localRoot || localRoot is Stage) && parent is IUIComponent)
  362. localRoot = DisplayObjectContainer(IUIComponent(parent).systemManager);
  363. if (localRoot is ISystemManager)
  364. {
  365. sm = ISystemManager(localRoot);
  366. if (!sm.isTopLevel())
  367. sm = sm.topLevelSystemManager;
  368. }
  369. return sm;
  370. }
  371. /**
  372. * Centers a popup window over whatever window was used in the call
  373. * to the <code>createPopUp()</code> or <code>addPopUp()</code> method.
  374. *
  375. * <p>Note that the position of the popup window may not
  376. * change immediately after this call since Flex may wait to measure and layout the
  377. * popup window before centering it.</p>
  378. *
  379. * @param The IFlexDisplayObject representing the popup.
  380. */
  381. public function centerPopUp(popUp:IFlexDisplayObject):void
  382. {
  383. if (popUp is IInvalidating)
  384. IInvalidating(popUp).validateNow();
  385. const o:PopUpData = findPopupInfoByOwner(popUp);
  386. // If we don't find the pop owner or if the owner's parent is not specified or is not on the
  387. // stage, then center based on the popUp's current parent.
  388. var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
  389. if (popUpParent)
  390. {
  391. var systemManager:ISystemManager = o.systemManager;
  392. var x:Number;
  393. var y:Number;
  394. var appWidth:Number;
  395. var appHeight:Number;
  396. var parentWidth:Number;
  397. var parentHeight:Number;
  398. var s:Rectangle; // the screen
  399. var rect:Rectangle
  400. var clippingOffset:Point = new Point();
  401. var pt:Point;
  402. var isTopLevelRoot:Boolean;
  403. var sbRoot:DisplayObject = systemManager.getSandboxRoot();
  404. // Only need to calc the visible rect when the sandbox root is an untrusted application.
  405. // Otherwise the alert will float over the entire application.
  406. if (systemManager != sbRoot)
  407. {
  408. var request:InterManagerRequest = new InterManagerRequest(InterManagerRequest.SYSTEM_MANAGER_REQUEST, false, false,
  409. "isTopLevelRoot");
  410. sbRoot.dispatchEvent(request);
  411. isTopLevelRoot = Boolean(request.value);
  412. }
  413. else
  414. isTopLevelRoot = systemManager.isTopLevelRoot();
  415. if (isTopLevelRoot)
  416. {
  417. // The sandbox root is the top level root.
  418. // The application width is just the screen width.
  419. s = systemManager.screen;
  420. appWidth = s.width;
  421. appHeight = s.height;
  422. }
  423. else
  424. {
  425. if (systemManager != sbRoot)
  426. {
  427. request = new InterManagerRequest(InterManagerRequest.SYSTEM_MANAGER_REQUEST, false, false,
  428. "getVisibleApplicationRect");
  429. sbRoot.dispatchEvent(request);
  430. rect = Rectangle(request.value);
  431. }
  432. else
  433. rect = systemManager.getVisibleApplicationRect();
  434. // Offset the top, left of the window to bring it into view.
  435. clippingOffset = new Point(rect.x, rect.y);
  436. clippingOffset = DisplayObject(systemManager).globalToLocal(clippingOffset);
  437. appWidth = rect.width;
  438. appHeight = rect.height;
  439. }
  440. // If parent is a UIComponent, check for clipping between
  441. // the object and its SystemManager
  442. if (popUpParent is UIComponent)
  443. {
  444. rect = UIComponent(popUpParent).getVisibleRect();
  445. var offset:Point = popUpParent.globalToLocal(rect.topLeft);
  446. clippingOffset.x += offset.x;
  447. clippingOffset.y += offset.y;
  448. parentWidth = rect.width;
  449. parentHeight = rect.height;
  450. }
  451. else
  452. {
  453. parentWidth = popUpParent.width;
  454. parentHeight = popUpParent.height;
  455. }
  456. // The appWidth may smaller than parentWidth if the application is
  457. // clipped by the parent application.
  458. x = Math.max(0, (Math.min(appWidth, parentWidth) - popUp.width) / 2);
  459. y = Math.max(0, (Math.min(appHeight, parentHeight) - popUp.height) / 2);
  460. pt = new Point(clippingOffset.x, clippingOffset.y);
  461. pt = popUpParent.localToGlobal(pt);
  462. pt = popUp.parent.globalToLocal(pt);
  463. popUp.move(Math.round(x) + pt.x, Math.round(y) + pt.y);
  464. }
  465. }
  466. /**
  467. * Removes a popup window popped up by
  468. * the <code>createPopUp()</code> or <code>addPopUp()</code> method.
  469. *
  470. * @param window The IFlexDisplayObject representing the popup window.
  471. */
  472. public function removePopUp(popUp:IFlexDisplayObject):void
  473. {
  474. // all we want to do here is verify that this popup is one of ours
  475. // and remove it from the display list; the REMOVED handler will do the rest
  476. // (this is so that we never leak memory, popups will self-manage even if
  477. // removePopUp is not called).
  478. if (popUp && popUp.parent)
  479. {
  480. const o:PopUpData = findPopupInfoByOwner(popUp);
  481. if (o)
  482. {
  483. var sm:ISystemManager = o.systemManager;
  484. if (!sm)
  485. {
  486. var iui:IUIComponent = popUp as IUIComponent;
  487. // cross-versioning error sometimes returns wrong parent
  488. if (iui)
  489. sm = ISystemManager(iui.systemManager);
  490. else
  491. return;
  492. }
  493. if (o.topMost)
  494. sm.popUpChildren.removeChild(DisplayObject(popUp));
  495. else
  496. sm.removeChild(DisplayObject(popUp));
  497. }
  498. }
  499. }
  500. /**
  501. * Makes sure a popup window is higher than other objects in its child list
  502. * The SystemManager does this automatically if the popup is a top level window
  503. * and is moused on,
  504. * but otherwise you have to take care of this yourself.
  505. *
  506. * @param The IFlexDisplayObject representing the popup.
  507. */
  508. public function bringToFront(popUp:IFlexDisplayObject):void
  509. {
  510. if (popUp && popUp.parent)
  511. {
  512. const o:PopUpData = findPopupInfoByOwner(popUp);
  513. if (o)
  514. {
  515. const sm:ISystemManager = ISystemManager(popUp.parent);
  516. if (sm is SystemManagerProxy)
  517. {
  518. // Since the proxy is parented to the SystemManager we need to
  519. // be it to the front, not the pop up.
  520. var request:InterManagerRequest = new InterManagerRequest(InterManagerRequest.SYSTEM_MANAGER_REQUEST,
  521. false, false,
  522. "bringToFront",
  523. {topMost: o.topMost, popUp: sm});
  524. sm.getSandboxRoot().dispatchEvent(request);
  525. }
  526. else if (o.topMost)
  527. sm.popUpChildren.setChildIndex(DisplayObject(popUp), sm.popUpChildren.numChildren - 1);
  528. else
  529. sm.setChildIndex(DisplayObject(popUp), sm.numChildren - 1);
  530. }
  531. }
  532. }
  533. /**
  534. * @private
  535. *
  536. * Create the modal window.
  537. * This is called in two different cases.
  538. * 1. Create a modal window for a local pop up.
  539. * 2. Create a modal window for a remote pop up. In this case o.owner will be null.
  540. */
  541. private function createModalWindow(parentReference:DisplayObject,
  542. o:PopUpData,
  543. childrenList:IChildList,
  544. visibleFlag:Boolean,
  545. sm:ISystemManager,
  546. sbRoot:DisplayObject):void
  547. {
  548. const popup:IFlexDisplayObject = IFlexDisplayObject(o.owner);
  549. const popupStyleClient:IStyleClient = popup as IStyleClient;
  550. var duration:Number = 0;
  551. // Create a modalWindow the size of the stage
  552. // that eats all mouse clicks.
  553. var modalWindow:Sprite;
  554. if (modalWindowClass)
  555. {
  556. modalWindow = new modalWindowClass();
  557. }
  558. else
  559. {
  560. modalWindow = new FlexSprite();
  561. modalWindow.name = "modalWindow";
  562. }
  563. if (!sm && parentReference)
  564. sm = IUIComponent(parentReference).systemManager;
  565. var smp:SystemManagerProxy;
  566. var realSm:ISystemManager;
  567. if (sm is SystemManagerProxy)
  568. {
  569. smp = SystemManagerProxy(sm);
  570. realSm = smp.systemManager;
  571. }
  572. else
  573. realSm = sm;
  574. realSm.numModalWindows++;
  575. // Add it to the collection just below the popup
  576. if (popup)
  577. childrenList.addChildAt(modalWindow,
  578. childrenList.getChildIndex(DisplayObject(popup)));
  579. else
  580. childrenList.addChild(modalWindow);
  581. // force into the automation hierarchy
  582. if (popup is IAutomationObject)
  583. IAutomationObject(popup).showInAutomationHierarchy = true;
  584. // set alpha of the popup and get it out of the focus loop
  585. if (!isNaN(o.modalTransparency))
  586. modalWindow.alpha = o.modalTransparency;
  587. else if (popupStyleClient)
  588. modalWindow.alpha = popupStyleClient.getStyle("modalTransparency");
  589. else
  590. modalWindow.alpha = 0;
  591. o.modalTransparency = modalWindow.alpha;
  592. modalWindow.tabEnabled = false;
  593. const s:Rectangle = realSm.screen;
  594. const g:Graphics = modalWindow.graphics;
  595. var c:Number = 0xFFFFFF;
  596. if (!isNaN(o.modalTransparencyColor))
  597. c = o.modalTransparencyColor;
  598. else if (popupStyleClient)
  599. {
  600. c = popupStyleClient.getStyle("modalTransparencyColor");
  601. o.modalTransparencyColor = c;
  602. }
  603. // trace("createModalWindow: drawing modal " + s);
  604. g.clear();
  605. g.beginFill(c, 100);
  606. g.drawRect(s.x, s.y, s.width, s.height);
  607. g.endFill();
  608. o.modalWindow = modalWindow;
  609. if (o.exclude)
  610. {
  611. o.modalMask = new Sprite();
  612. updateModalMask(realSm, modalWindow,
  613. o.useExclude ? o.exclude : null,
  614. o.excludeRect, o.modalMask);
  615. modalWindow.mask = o.modalMask;
  616. childrenList.addChild(o.modalMask);
  617. // update the modal window mask when the size or position of the area
  618. // we are excluding changes.
  619. o.exclude.addEventListener(Event.RESIZE, o.resizeHandler);
  620. o.exclude.addEventListener(MoveEvent.MOVE, o.resizeHandler);
  621. }
  622. // a modal mousedownoutside handler just dispatches the event
  623. o._mouseDownOutsideHandler = dispatchMouseDownOutsideEvent;
  624. o._mouseWheelOutsideHandler = dispatchMouseWheelOutsideEvent;
  625. // the following handlers all get removed in REMOVED on the popup
  626. // Set the resize handler so the modal can stay the size of the screen
  627. realSm.addEventListener(Event.RESIZE, o.resizeHandler);
  628. if (popup)
  629. {
  630. // Listen for show so we know to show the modal window
  631. popup.addEventListener(FlexEvent.SHOW, popupShowHandler);
  632. // Listen for hide so we know to hide the modal window
  633. popup.addEventListener(FlexEvent.HIDE, popupHideHandler);
  634. }
  635. if (visibleFlag)
  636. showModalWindow(o, sm, false);
  637. else
  638. popup.visible = visibleFlag;
  639. if (realSm.useSWFBridge())
  640. {
  641. if (popupStyleClient)
  642. {
  643. o.modalTransparencyDuration = popupStyleClient.getStyle("modalTransparencyDuration");
  644. o.modalTransparencyBlur = popupStyleClient.getStyle("modalTransparencyBlur");
  645. }
  646. dispatchModalWindowRequest(SWFBridgeRequest.CREATE_MODAL_WINDOW_REQUEST, realSm, sbRoot, o, visibleFlag);
  647. }
  648. }
  649. private function dispatchModalWindowRequest(type:String,
  650. sm:ISystemManager,
  651. sbRoot:DisplayObject,
  652. o:PopUpData,
  653. visibleFlag:Boolean):void
  654. {
  655. // if our first target is a sandbox root that is the top level root,
  656. // then we don't need to send a modal request.
  657. if (!o.isRemoteModalWindow && sm != sbRoot)
  658. {
  659. var request:InterManagerRequest = new InterManagerRequest(InterManagerRequest.SYSTEM_MANAGER_REQUEST, false, false,
  660. "isTopLevelRoot");
  661. sbRoot.dispatchEvent(request);
  662. if (Boolean(request.value))
  663. return;
  664. }
  665. var modalRequest:SWFBridgeRequest = new SWFBridgeRequest(type, false, false, null,
  666. { skip: !o.isRemoteModalWindow && sm != sbRoot,
  667. useExclude: o.useExclude,
  668. show: visibleFlag,
  669. remove: false,
  670. transparencyDuration: o.modalTransparencyDuration,
  671. transparency: o.modalTransparency,
  672. transparencyColor: o.modalTransparencyColor,
  673. transparencyBlur: o.modalTransparencyBlur});
  674. var bridge:IEventDispatcher = sm.swfBridgeGroup.parentBridge;;
  675. modalRequest.requestor = bridge;
  676. bridge.dispatchEvent(modalRequest);
  677. }
  678. /**
  679. * @private
  680. *
  681. * Update a mask to exclude the area of the exclude parameter from the area
  682. * of the modal window parameter.
  683. *
  684. * @param sm The system manager that hosts the modal window
  685. * @param modalWindow The base area of the mask
  686. * @param exclude The area to exlude from the mask, may be null.
  687. * @param excludeRect An optionally rectangle that is included in the area
  688. * to exclude. The rectangle is in global coordinates.
  689. * @param mask A non-null sprite. The mask is rewritten for each call.
  690. *
  691. */
  692. mx_internal static function updateModalMask(sm:ISystemManager,
  693. modalWindow:DisplayObject,
  694. exclude:IUIComponent,
  695. excludeRect:Rectangle,
  696. mask:Sprite):void
  697. {
  698. var modalBounds:Rectangle = modalWindow.getBounds(DisplayObject(sm));
  699. var excludeBounds:Rectangle;
  700. var pt:Point;
  701. if (exclude is ISWFLoader)
  702. {
  703. excludeBounds = ISWFLoader(exclude).getVisibleApplicationRect();
  704. pt = new Point(excludeBounds.x, excludeBounds.y);
  705. pt = DisplayObject(sm).globalToLocal(pt);
  706. excludeBounds.x = pt.x;
  707. excludeBounds.y = pt.y;
  708. }
  709. else if (!exclude)
  710. excludeBounds = modalBounds.clone(); // don't exclude anything extra
  711. else
  712. excludeBounds = DisplayObject(exclude).getBounds(DisplayObject(sm));
  713. // apply excludeRect to the result
  714. if (excludeRect)
  715. {
  716. pt = new Point(excludeRect.x, excludeRect.y);
  717. pt = DisplayObject(sm).globalToLocal(pt);
  718. var rect:Rectangle = new Rectangle(pt.x, pt.y, excludeRect.width, excludeRect.height);
  719. excludeBounds = excludeBounds.intersection(rect);
  720. }
  721. mask.graphics.clear();
  722. mask.graphics.beginFill(0x000000);
  723. // Fill the mask in three logical rows
  724. // 1. Above the exclude bounds
  725. if (excludeBounds.y > modalBounds.y)
  726. mask.graphics.drawRect(modalBounds.x, modalBounds.y,
  727. modalBounds.width, excludeBounds.y - modalBounds.y);
  728. // 2. Left and right of the exclude bounds
  729. if (modalBounds.x < excludeBounds.x)
  730. mask.graphics.drawRect(modalBounds.x, excludeBounds.y,
  731. excludeBounds.x - modalBounds.x, excludeBounds.height);
  732. if ((modalBounds.x + modalBounds.width) > (excludeBounds.x + excludeBounds.width))
  733. mask.graphics.drawRect(excludeBounds.x + excludeBounds.width,
  734. excludeBounds.y,
  735. modalBounds.x + modalBounds.width - excludeBounds.x - excludeBounds.width,
  736. excludeBounds.height);
  737. // 3. Below the exclude bounds
  738. if ((excludeBounds.y + excludeBounds.height) < (modalBounds.y + modalBounds.height))
  739. mask.graphics.drawRect(modalBounds.x, excludeBounds.y + excludeBounds.height,
  740. modalBounds.width,
  741. modalBounds.y + modalBounds.height - excludeBounds.y - excludeBounds.height);
  742. mask.graphics.endFill();
  743. }
  744. /**
  745. * @private
  746. */
  747. private function endEffects(o:PopUpData):void
  748. {
  749. if (o.fade)
  750. {
  751. o.fade.end();
  752. o.fade = null;
  753. }
  754. if (o.blur)
  755. {
  756. o.blur.end();
  757. o.blur = null;
  758. }
  759. }
  760. private function showModalWindow(o:PopUpData, sm:ISystemManager, sendRequest:Boolean = true):void
  761. {
  762. const popUpStyleClient:IStyleClient = o.owner as IStyleClient;
  763. var duration:Number = 0;
  764. var alpha:Number = 0;
  765. if (!isNaN(o.modalTransparencyDuration))
  766. duration = o.modalTransparencyDuration;
  767. else if (popUpStyleClient)
  768. {
  769. duration = popUpStyleClient.getStyle("modalTransparencyDuration");
  770. o.modalTransparencyDuration = duration;
  771. }
  772. if (!isNaN(o.modalTransparency))
  773. alpha = o.modalTransparency;
  774. else if (popUpStyleClient)
  775. {
  776. alpha = popUpStyleClient.getStyle("modalTransparency");
  777. o.modalTransparency = alpha;
  778. }
  779. o.modalWindow.alpha = alpha;
  780. var blurAmount:Number = 0;
  781. if (!isNaN(o.modalTransparencyBlur))
  782. blurAmount = o.modalTransparencyBlur;
  783. else if (popUpStyleClient)
  784. {
  785. blurAmount = popUpStyleClient.getStyle("modalTransparencyBlur");
  786. o.modalTransparencyBlur = blurAmount;
  787. }
  788. var transparencyColor:Number = 0xFFFFFF;
  789. if (!isNaN(o.modalTransparencyColor))
  790. transparencyColor = o.modalTransparencyColor;
  791. else if (popUpStyleClient)
  792. {
  793. transparencyColor = popUpStyleClient.getStyle("modalTransparencyColor");
  794. o.modalTransparencyColor = transparencyColor;
  795. }
  796. if (sm is SystemManagerProxy)
  797. sm = SystemManagerProxy(sm).systemManager;
  798. var sbRoot:DisplayObject = sm.getSandboxRoot();
  799. showModalWindowInternal(o, duration, alpha, transparencyColor, blurAmount, sm, sbRoot);
  800. if (sendRequest && sm.useSWFBridge())
  801. dispatchModalWindowRequest(SWFBridgeRequest.SHOW_MODAL_WINDOW_REQUEST, sm, sbRoot, o, true);
  802. }
  803. /**
  804. * @private
  805. * Show the modal transparency blocker, playing effects if needed.
  806. */
  807. private function showModalWindowInternal(o:PopUpData,
  808. transparencyDuration:Number,
  809. transparency:Number,
  810. transparencyColor:Number,
  811. transparencyBlur:Number,
  812. sm:ISystemManager,
  813. sbRoot:DisplayObject):void
  814. {
  815. // NO POPUP Data
  816. // End any effects that are currently playing for this popup.
  817. endEffects(o);
  818. if (transparencyDuration)
  819. {
  820. // Fade effect on the modal transparency blocker
  821. const fade:Fade = new Fade(o.modalWindow);
  822. fade.alphaFrom = 0;
  823. fade.alphaTo = transparency;
  824. fade.duration = transparencyDuration;
  825. fade.addEventListener(EffectEvent.EFFECT_END, fadeInEffectEndHandler);
  826. o.modalWindow.alpha = 0;
  827. o.modalWindow.visible = true;
  828. o.fade = fade;
  829. if (o.owner)
  830. IUIComponent(o.owner).setVisible(false, true);
  831. fade.play();
  832. // Blur effect on the application
  833. var blurAmount:Number = transparencyBlur;
  834. if (blurAmount)
  835. {
  836. // Ensure we blur the appropriate top level document.
  837. if (DisplayObject(sm).parent is Stage)
  838. {
  839. // Checking this case first allows WindowedSystemManagers be the blur target.
  840. o.blurTarget = sm.document;
  841. }
  842. else if (sm != sbRoot)
  843. {
  844. // Get the application document of the sandbox root.
  845. // Use a request to get the document so APIs may change
  846. // between Flex versions.
  847. var sbRootApp:Object;
  848. var applicationRequest:InterManagerRequest = new InterManagerRequest(InterManagerRequest.SYSTEM_MANAGER_REQUEST,
  849. false, false,
  850. "application",
  851. sbRootApp);
  852. sbRoot.dispatchEvent(applicationRequest);
  853. o.blurTarget = applicationRequest.value;
  854. }
  855. else
  856. o.blurTarget = ApplicationGlobals.application;
  857. const blur:Blur = new Blur(o.blurTarget);
  858. blur.blurXFrom = blur.blurYFrom = 0;
  859. blur.blurXTo = blur.blurYTo = blurAmount;
  860. blur.duration = transparencyDuration;
  861. blur.addEventListener(EffectEvent.EFFECT_END, effectEndHandler);
  862. o.blur = blur;
  863. blur.play();
  864. }
  865. }
  866. else
  867. {
  868. if (o.owner)
  869. IUIComponent(o.owner).setVisible(true, true);
  870. o.modalWindow.visible = true;
  871. }
  872. }
  873. /**
  874. * @private
  875. * Hide the modal transparency blocker, playing effects if needed.
  876. *
  877. */
  878. private function hideModalWindow(o:PopUpData, destroy:Boolean = false):void
  879. {
  880. if (destroy && o.exclude)
  881. {
  882. o.exclude.removeEventListener(Event.RESIZE, o.resizeHandler);
  883. o.exclude.removeEventListener(MoveEvent.MOVE, o.resizeHandler);
  884. }
  885. const popUpStyleClient:IStyleClient = o.owner as IStyleClient;
  886. var duration:Number = 0;
  887. if (popUpStyleClient)
  888. duration = popUpStyleClient.getStyle("modalTransparencyDuration");
  889. // end any effects that are current playing for this popup
  890. endEffects(o);
  891. if (duration)
  892. {
  893. // Fade effect on the modal transparency blocker
  894. const fade:Fade = new Fade(o.modalWindow);
  895. fade.alphaFrom = o.modalWindow.alpha;
  896. fade.alphaTo = 0;
  897. fade.duration = duration;
  898. fade.addEventListener(EffectEvent.EFFECT_END,
  899. destroy ? fadeOutDestroyEffectEndHandler : fadeOutCloseEffectEndHandler);
  900. o.modalWindow.visible = true;
  901. o.fade = fade;
  902. fade.play();
  903. // Blur effect on the application
  904. const blurAmount:Number = popUpStyleClient.getStyle("modalTransparencyBlur");
  905. if (blurAmount)
  906. {
  907. const blur:Blur = new Blur(o.blurTarget);
  908. blur.blurXFrom = blur.blurYFrom = blurAmount;
  909. blur.blurXTo = blur.blurYTo = 0;
  910. blur.duration = duration;
  911. blur.addEventListener(EffectEvent.EFFECT_END, effectEndHandler);
  912. o.blur = blur;
  913. blur.play();
  914. }
  915. }
  916. else
  917. {
  918. o.modalWindow.visible = false;
  919. }
  920. var sm:ISystemManager = ISystemManager(ApplicationGlobals.application.systemManager);
  921. if (sm.useSWFBridge())
  922. {
  923. var sbRoot:DisplayObject = sm.getSandboxRoot();
  924. // if our first target is a sandbox root that is the top level root,
  925. // then we don't need to send a modal request.
  926. if (!o.isRemoteModalWindow && sm != sbRoot)
  927. {
  928. var request:InterManagerRequest = new InterManagerRequest(InterManagerRequest.SYSTEM_MANAGER_REQUEST, false, false,
  929. "isTopLevelRoot");
  930. sbRoot.dispatchEvent(request);
  931. if (Boolean(request.value))
  932. return;
  933. }
  934. var modalRequest:SWFBridgeRequest = new SWFBridgeRequest(SWFBridgeRequest.HIDE_MODAL_WINDOW_REQUEST, false, false, null,
  935. { skip: !o.isRemoteModalWindow && sm != sbRoot,
  936. show: false,
  937. remove: destroy});
  938. var bridge:IEventDispatcher = sm.swfBridgeGroup.parentBridge;
  939. var target:IEventDispatcher;
  940. modalRequest.requestor = bridge;
  941. bridge.dispatchEvent(modalRequest);
  942. }
  943. }
  944. /**
  945. * @private
  946. * Returns the PopUpData (or null) for a given popupInfo.owner
  947. */
  948. private function findPopupInfoByOwner(owner:Object):PopUpData
  949. {
  950. const n:int = popupInfo.length;
  951. for (var i:int = 0; i < n; i++)
  952. {
  953. var o:PopUpData = popupInfo[i];
  954. if (o.owner == owner)
  955. return o;
  956. }
  957. return null;
  958. }
  959. /**
  960. * @private
  961. * Returns the PopUpData for the highest remote modal window on display.
  962. */
  963. private function findHighestRemoteModalPopupInfo():PopUpData
  964. {
  965. const n:int = popupInfo.length - 1;
  966. for (var i:int = n; i >= 0; i--)
  967. {
  968. var o:PopUpData = popupInfo[i];
  969. if (o.isRemoteModalWindow)
  970. return o;
  971. }
  972. return null;
  973. }
  974. /**
  975. * @private
  976. * Add mouse out listeners for modal and non-modal windows.
  977. */
  978. private function addMouseOutEventListeners(o:PopUpData):void
  979. {
  980. var sbRoot:DisplayObject = o.systemManager.getSandboxRoot();
  981. if (o.modalWindow)
  982. {
  983. o.modalWindow.addEventListener(MouseEvent.MOUSE_DOWN, o.mouseDownOutsideHandler);
  984. o.modalWindow.addEventListener(MouseEvent.MOUSE_WHEEL, o.mouseWheelOutsideHandler, true);
  985. }
  986. else
  987. {
  988. sbRoot.addEventListener(MouseEvent.MOUSE_DOWN, o.mouseDownOutsideHandler);
  989. sbRoot.addEventListener(MouseEvent.MOUSE_WHEEL, o.mouseWheelOutsideHandler, true);
  990. }
  991. sbRoot.addEventListener(SandboxMouseEvent.MOUSE_DOWN_SOMEWHERE, o.marshalMouseOutsideHandler);
  992. sbRoot.addEventListener(SandboxMouseEvent.MOUSE_WHEEL_SOMEWHERE, o.marshalMouseOutsideHandler, true);
  993. }
  994. /**
  995. * @private
  996. * Remove mouse out listeners for modal and non-modal windows.
  997. */
  998. private function removeMouseOutEventListeners(o:PopUpData):void
  999. {
  1000. var sbRoot:DisplayObject = o.systemManager.getSandboxRoot();
  1001. if (o.modalWindow)
  1002. {
  1003. o.modalWindow.removeEventListener(MouseEvent.MOUSE_DOWN, o.mouseDownOutsideHandler);
  1004. o.modalWindow.removeEventListener(MouseEvent.MOUSE_WHEEL, o.mouseWheelOutsideHandler, true);
  1005. }
  1006. else
  1007. {
  1008. sbRoot.removeEventListener(MouseEvent.MOUSE_DOWN, o.mouseDownOutsideHandler);
  1009. sbRoot.removeEventListener(MouseEvent.MOUSE_WHEEL, o.mouseWheelOutsideHandler, true);
  1010. }
  1011. sbRoot.removeEventListener(SandboxMouseEvent.MOUSE_DOWN_SOMEWHERE, o.marshalMouseOutsideHandler);
  1012. sbRoot.removeEventListener(SandboxMouseEvent.MOUSE_WHEEL_SOMEWHERE, o.marshalMouseOutsideHandler, true);
  1013. }
  1014. //--------------------------------------------------------------------------
  1015. //
  1016. // Event handlers
  1017. //
  1018. //--------------------------------------------------------------------------
  1019. /**
  1020. * @private
  1021. * Set by PopUpManager on modal windows so they show when the parent shows.
  1022. */
  1023. private function popupShowHandler(event:FlexEvent):void
  1024. {
  1025. const o:PopUpData = findPopupInfoByOwner(event.target);
  1026. if (o)
  1027. showModalWindow(o, getTopLevelSystemManager(o.parent));
  1028. }
  1029. /**
  1030. * @private
  1031. * Set by PopUpManager on modal windows so they hide when the parent hide
  1032. */
  1033. private function popupHideHandler(event:FlexEvent):void
  1034. {
  1035. const o:PopUpData = findPopupInfoByOwner(event.target);
  1036. if (o)
  1037. hideModalWindow(o);
  1038. }
  1039. /**
  1040. * @private
  1041. */
  1042. private function showOwnerHandler(event:FlexEvent):void
  1043. {
  1044. const o:PopUpData = findPopupInfoByOwner(event.target);
  1045. if (o)
  1046. {
  1047. // add mouse out listeners.
  1048. addMouseOutEventListeners(o);
  1049. }
  1050. }
  1051. /**
  1052. * @private
  1053. */
  1054. private function hideOwnerHandler(event:FlexEvent):void
  1055. {
  1056. const o:PopUpData = findPopupInfoByOwner(event.target);
  1057. if (o)
  1058. {
  1059. // remove mouse out listeners
  1060. removeMouseOutEventListeners(o);
  1061. }
  1062. }
  1063. /**
  1064. * @private
  1065. *
  1066. * Create a modal window and optionally show it.
  1067. */
  1068. private function createModalWindowRequestHandler(event:Event):void
  1069. {
  1070. var request:SWFBridgeRequest;
  1071. if (event is SWFBridgeRequest)
  1072. request = SWFBridgeRequest(event);
  1073. else
  1074. request = SWFBridgeRequest.marshal(event);
  1075. var sm:ISystemManager = getTopLevelSystemManager(DisplayObject(ApplicationGlobals.application));
  1076. var sbRoot:DisplayObject = sm.getSandboxRoot();
  1077. // process the message
  1078. var popUpData:PopUpData = new PopUpData();
  1079. popUpData.isRemoteModalWindow = true;
  1080. popUpData.systemManager = sm;
  1081. popUpData.modalTransparency = request.data.transparency;
  1082. // disable blur because we can mask the application and blur is not
  1083. // working if we blur the modalWindow.
  1084. popUpData.modalTransparencyBlur = 0; //request.transparencyBlur;
  1085. popUpData.modalTransparencyColor = request.data.transparencyColor;
  1086. popUpData.modalTransparencyDuration = request.data.transparencyDuration;
  1087. // Get the SWFLoader to exclude.
  1088. // The requestor may be a real SWFLoader or a sandbox bridge that
  1089. // requires a look up to get the SWFLoader.
  1090. popUpData.exclude = sm.swfBridgeGroup.getChildBridgeProvider(request.requestor) as IUIComponent;
  1091. popUpData.useExclude = request.data.useExclude;
  1092. popUpData.excludeRect = Rectangle(request.data.excludeRect);
  1093. if (!popupInfo)
  1094. popupInfo = [];
  1095. popupInfo.push(popUpData);
  1096. createModalWindow(null, popUpData, sm.popUpChildren, request.data.show, sm, sbRoot);
  1097. }
  1098. /**
  1099. * @private
  1100. *
  1101. * Show a modal window.
  1102. */
  1103. private function showModalWindowRequest(event:Event):void
  1104. {
  1105. var request:SWFBridgeRequest = SWFBridgeRequest.marshal(event);
  1106. if (event is SWFBridgeRequest)
  1107. request = SWFBridgeRequest(event);
  1108. else
  1109. request = SWFBridgeRequest.marshal(event);
  1110. var sm:ISystemManager = getTopLevelSystemManager(DisplayObject(ApplicationGlobals.application));
  1111. var sbRoot:DisplayObject = sm.getSandboxRoot();
  1112. // the highest popUpData in the list is the most recent modal window.
  1113. // sanity check that the popupdata is really a modal window with a null
  1114. // parent and popup window.
  1115. var popUpData:PopUpData = findHighestRemoteModalPopupInfo();
  1116. popUpData.excludeRect = Rectangle(request.data);
  1117. popUpData.modalTransparency = request.data.transparency;
  1118. // disable blur because we can mask the application and blur is not
  1119. // working if we blur the modalWindow.
  1120. popUpData.modalTransparencyBlur = 0; //request.transparencyBlur;
  1121. popUpData.modalTransparencyColor = request.data.transparencyColor;
  1122. popUpData.modalTransparencyDuration = request.data.transparencyDuration;
  1123. if (popUpData.owner || popUpData.parent)
  1124. throw new Error(); // not popUpData for a modal window
  1125. showModalWindow(popUpData, sm);
  1126. }
  1127. /**
  1128. * @private
  1129. *
  1130. * Hide a modal window and optionally remove it.
  1131. */
  1132. private function hideModalWindowRequest(event:Event):void
  1133. {
  1134. var request:SWFBridgeRequest;
  1135. // If the event is redispatched from the SystemManger it will be
  1136. // marshalled. If the PopUpManager dispatches the event using
  1137. // the sandbox root it will come here directly.
  1138. if (event is SWFBridgeRequest)
  1139. request = SWFBridgeRequest(event);
  1140. else
  1141. request = SWFBridgeRequest.marshal(event);
  1142. var sm:ISystemManager = getTopLevelSystemManager(DisplayObject(ApplicationGlobals.application));
  1143. var sbRoot:DisplayObject = sm.getSandboxRoot();
  1144. // the highest popUpData in the list is the most recent modal window.
  1145. // sanity check that the popupdata is really a modal window with a null
  1146. // parent and popup window.
  1147. var popUpData:PopUpData = findHighestRemoteModalPopupInfo();
  1148. if (!popUpData || popUpData.owner || popUpData.parent)
  1149. throw new Error(); // not popUpData for a modal window

Large files files are truncated, but you can click here to view the full file