Guest User

Untitled

a guest
Jul 1st, 2012
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. Flex: How can I pop up a component in the center of the user's viewable area?
  2. <?xml version="1.0" encoding="utf-8"?>
  3. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  4. xmlns:s="library://ns.adobe.com/flex/spark"
  5. xmlns:mx="library://ns.adobe.com/flex/mx"
  6. width="3000" height="2000"
  7. creationComplete="creationCompleteHandler(event)">
  8.  
  9. <fx:Script>
  10. <![CDATA[
  11.  
  12. import mx.managers.PopUpManager;
  13. import spark.components.TitleWindow;
  14.  
  15. public var myWindow:TitleWindow = new TitleWindow;
  16.  
  17. protected function creationCompleteHandler(event:FlexEvent):void
  18. {
  19. myWindow.title = "My Title Window";
  20. PopUpManager.addPopUp(myWindow, DisplayObject(FlexGlobals.topLevelApplication), false);
  21. PopUpManager.centerPopUp(myWindow);
  22. }
  23.  
  24. ]]>
  25. </fx:Script>
  26.  
  27. <s:BorderContainer width="3000" height="2000" backgroundColor="0x000000" />
  28. </s:Application>
  29.  
  30. +==========================+---------------------+
  31. | Viewable Area | |
  32. | | |
  33. | +-------------+ | |
  34. | | I want the | | |
  35. | | popup to | | |
  36. | | go here. | | |
  37. | +-------------+ | |
  38. | | |
  39. | | |
  40. +==========================+ |
  41. | |
  42. | Rest of Application |
  43. | |
  44. | |
  45. | |
  46. | |
  47. +------------------------------------------------+
  48.  
  49. +------------------------------------------------+
  50. | |
  51. | Rest of Application |
  52. | |
  53. | |
  54. | +===========================+ |
  55. | | Viewable Area | |
  56. | | | |
  57. | | +-------------+ | |
  58. | | | I want the | | |
  59. | | | popup to | | |
  60. | | | go here. | | |
  61. | | +-------------+ | |
  62. | | | |
  63. | | | |
  64. | +===========================+ |
  65. | |
  66. +------------------------------------------------+
  67.  
  68. dlg.x = (this.stage.stageWidth / 2) - (dlg.width / 2);
  69. dlg.y = (this.stage.stageHeight / 2) - (dlg.height / 2);
Advertisement
Add Comment
Please, Sign In to add comment