PageRenderTime 100ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 1ms

/Sample/mx/managers/SystemManager.as

https://github.com/ingydotnet/yaml-oscon2009-talk
ActionScript | 5528 lines | 3054 code | 737 blank | 1737 comment | 672 complexity | 0719829e2997cf363d1a00cbfa8d0c5f 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 2003-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.Loader;
  18. import flash.display.LoaderInfo;
  19. import flash.display.MovieClip;
  20. import flash.display.Sprite;
  21. import flash.display.Stage;
  22. import flash.display.StageAlign;
  23. import flash.display.StageScaleMode;
  24. import flash.events.Event;
  25. import flash.events.EventDispatcher;
  26. import flash.events.EventPhase;
  27. import flash.events.IEventDispatcher;
  28. import flash.events.MouseEvent;
  29. import flash.events.TimerEvent;
  30. import flash.geom.Point;
  31. import flash.geom.Rectangle;
  32. import flash.net.getClassByAlias;
  33. import flash.net.registerClassAlias;
  34. import flash.system.ApplicationDomain;
  35. import flash.system.Capabilities;
  36. import flash.text.Font;
  37. import flash.text.TextFormat;
  38. import flash.utils.ByteArray;
  39. import flash.utils.Dictionary;
  40. import flash.utils.Timer;
  41. import flash.utils.getQualifiedClassName;
  42. import mx.core.EmbeddedFontRegistry;
  43. import mx.core.EventPriority;
  44. import mx.core.FlexSprite;
  45. import mx.core.ISWFLoader;
  46. import mx.core.IChildList;
  47. import mx.core.IFlexDisplayObject;
  48. import mx.core.IFlexModuleFactory;
  49. import mx.core.IInvalidating;
  50. import mx.core.IRawChildrenContainer;
  51. import mx.core.ISWFBridgeGroup;
  52. import mx.core.ISWFBridgeProvider;
  53. import mx.core.IUIComponent;
  54. import mx.core.RSLItem;
  55. import mx.core.Singleton;
  56. import mx.core.SWFBridgeGroup;
  57. import mx.core.TextFieldFactory;
  58. import mx.core.mx_internal;
  59. import mx.events.FlexEvent;
  60. import mx.messaging.config.LoaderConfig;
  61. import mx.preloaders.DownloadProgressBar;
  62. import mx.preloaders.Preloader;
  63. import mx.resources.IResourceManager;
  64. import mx.resources.ResourceBundle;
  65. import mx.resources.ResourceManager;
  66. import mx.styles.ISimpleStyleClient;
  67. import mx.styles.IStyleClient;
  68. import mx.styles.StyleManager;
  69. import mx.events.EventListenerRequest;
  70. import mx.events.FlexChangeEvent;
  71. import mx.events.InvalidateRequestData;
  72. import mx.events.InterManagerRequest;
  73. import mx.events.ResizeEvent;
  74. import mx.events.SandboxMouseEvent;
  75. import mx.events.SWFBridgeRequest;
  76. import mx.events.SWFBridgeEvent;
  77. import mx.managers.systemClasses.RemotePopUp;
  78. import mx.managers.systemClasses.EventProxy;
  79. import mx.managers.systemClasses.StageEventProxy;
  80. import mx.managers.systemClasses.PlaceholderData;
  81. import mx.utils.EventUtil;
  82. import mx.utils.NameUtil;
  83. import mx.utils.LoaderUtil;
  84. import mx.utils.ObjectUtil;
  85. import mx.utils.SecurityUtil;
  86. // NOTE: Minimize the non-Flash classes you import here.
  87. // Any dependencies of SystemManager have to load in frame 1,
  88. // before the preloader, or anything else, can be displayed.
  89. use namespace mx_internal;
  90. //--------------------------------------
  91. // Events
  92. //--------------------------------------
  93. /**
  94. * Dispatched when the application has finished initializing
  95. *
  96. * @eventType mx.events.FlexEvent.APPLICATION_COMPLETE
  97. */
  98. [Event(name="applicationComplete", type="mx.events.FlexEvent")]
  99. /**
  100. * Dispatched every 100 milliseconds when there has been no keyboard
  101. * or mouse activity for 1 second.
  102. *
  103. * @eventType mx.events.FlexEvent.IDLE
  104. */
  105. [Event(name="idle", type="mx.events.FlexEvent")]
  106. /**
  107. * Dispatched when the Stage is resized.
  108. *
  109. * @eventType flash.events.Event.RESIZE
  110. */
  111. [Event(name="resize", type="flash.events.Event")]
  112. /**
  113. * The SystemManager class manages an application window.
  114. * Every application that runs on the desktop or in a browser
  115. * has an area where the visuals of the application are
  116. * displayed.
  117. * It may be a window in the operating system
  118. * or an area within the browser. That area is an application window
  119. * and different from an instance of <code>mx.core.Application</code>, which
  120. * is the main, or top-level, window within an application.
  121. *
  122. * <p>Every application has a SystemManager.
  123. * The SystemManager sends an event if
  124. * the size of the application window changes (you cannot change it from
  125. * within the application, but only through interaction with the operating
  126. * system window or browser). It parents all displayable things within the
  127. * application like the main mx.core.Application instance and all popups,
  128. * tooltips, cursors, and so on. Any object parented by the SystemManager is
  129. * considered to be a top-level window, even tooltips and cursors.</p>
  130. *
  131. * <p>The SystemManager also switches focus between top-level windows if there
  132. * are more than one IFocusManagerContainer displayed and users are interacting
  133. * with components within the IFocusManagerContainers. </p>
  134. *
  135. * <p>All keyboard and mouse activity that is not expressly trapped is seen by
  136. * the SystemManager, making it a good place to monitor activity should you need
  137. * to do so.</p>
  138. *
  139. * <p>If an application is loaded into another application, a SystemManager
  140. * will still be created, but will not manage an application window,
  141. * depending on security and domain rules.
  142. * Instead, it will be the <code>content</code> of the <code>Loader</code>
  143. * that loaded it and simply serve as the parent of the sub-application</p>
  144. *
  145. * <p>The SystemManager maintains multiple lists of children, one each for tooltips, cursors,
  146. * popup windows. This is how it ensures that popup windows "float" above the main
  147. * application windows and that tooltips "float" above that and cursors above that.
  148. * If you simply examine the <code>numChildren</code> property or
  149. * call the <code>getChildAt()</code> method on the SystemManager, you are accessing
  150. * the main application window and any other windows that aren't popped up. To get the list
  151. * of all windows, including popups, tooltips and cursors, use
  152. * the <code>rawChildren</code> property.</p>
  153. *
  154. * <p>The SystemManager is the first display class created within an application.
  155. * It is responsible for creating an <code>mx.preloaders.Preloader</code> that displays and
  156. * <code>mx.preloaders.DownloadProgressBar</code> while the application finishes loading,
  157. * then creates the <code>mx.core.Application</code> instance.</p>
  158. */
  159. public class SystemManager extends MovieClip
  160. implements IChildList, IFlexDisplayObject,
  161. IFlexModuleFactory, ISystemManager, ISWFBridgeProvider
  162. {
  163. include "../core/Version.as";
  164. //--------------------------------------------------------------------------
  165. //
  166. // Class constants
  167. //
  168. //--------------------------------------------------------------------------
  169. /**
  170. * @private
  171. * The number of milliseconds that must pass without any user activity
  172. * before SystemManager starts dispatching 'idle' events.
  173. */
  174. private static const IDLE_THRESHOLD:Number = 1000;
  175. /**
  176. * @private
  177. * The number of milliseconds between each 'idle' event.
  178. */
  179. private static const IDLE_INTERVAL:Number = 100;
  180. //--------------------------------------------------------------------------
  181. //
  182. // Class variables
  183. //
  184. //--------------------------------------------------------------------------
  185. /**
  186. * @private
  187. * An array of SystemManager instances loaded as child app domains
  188. */
  189. mx_internal static var allSystemManagers:Dictionary = new Dictionary(true);
  190. /**
  191. * @private
  192. * The last SystemManager instance loaded as child app domains
  193. */
  194. mx_internal static var lastSystemManager:SystemManager;
  195. //--------------------------------------------------------------------------
  196. //
  197. // Class methods
  198. //
  199. //--------------------------------------------------------------------------
  200. /**
  201. * @private
  202. * If a class wants to be notified when the Application instance
  203. * has been initialized, then it registers a callback here.
  204. * By using a callback mechanism, we avoid adding unwanted
  205. * linker dependencies on classes like HistoryManager and DragManager.
  206. */
  207. mx_internal static function registerInitCallback(initFunction:Function):void
  208. {
  209. if (!allSystemManagers || !lastSystemManager)
  210. {
  211. return;
  212. }
  213. var sm:SystemManager = lastSystemManager;
  214. // If this function is called late (after we're done invoking the
  215. // callback functions for the last time), then just invoke
  216. // the callback function immediately.
  217. if (sm.doneExecutingInitCallbacks)
  218. initFunction(sm);
  219. else
  220. sm.initCallbackFunctions.push(initFunction);
  221. }
  222. //--------------------------------------------------------------------------
  223. //
  224. // Constructor
  225. //
  226. //--------------------------------------------------------------------------
  227. /**
  228. * Constructor.
  229. *
  230. * <p>This is the starting point for all Flex applications.
  231. * This class is set to be the root class of a Flex SWF file.
  232. * Flash Player instantiates an instance of this class,
  233. * causing this constructor to be called.</p>
  234. */
  235. public function SystemManager()
  236. {
  237. super();
  238. // Loaded SWFs don't get a stage right away
  239. // and shouldn't override the main SWF's setting anyway.
  240. if (stage)
  241. {
  242. stage.scaleMode = StageScaleMode.NO_SCALE;
  243. stage.align = StageAlign.TOP_LEFT;
  244. }
  245. // If we don't have a stage then we are not top-level,
  246. // unless there are no other top-level managers, in which
  247. // case we got loaded by a non-Flex shell or are sandboxed.
  248. if (SystemManagerGlobals.topLevelSystemManagers.length > 0 && !stage)
  249. topLevel = false;
  250. if (!stage)
  251. isStageRoot = false;
  252. if (topLevel)
  253. SystemManagerGlobals.topLevelSystemManagers.push(this);
  254. lastSystemManager = this;
  255. var compiledLocales:Array = info()["compiledLocales"];
  256. ResourceBundle.mx_internal::locale =
  257. compiledLocales != null && compiledLocales.length > 0 ?
  258. compiledLocales[0] :
  259. "en_US";
  260. executeCallbacks();
  261. // Make sure to stop the playhead on the current frame.
  262. stop();
  263. // Add safeguard in case bug 129782 shows up again.
  264. if (topLevel && currentFrame != 1)
  265. {
  266. throw new Error("The SystemManager constructor was called when the currentFrame was at " + currentFrame +
  267. " Please add this SWF to bug 129782.");
  268. }
  269. // Listen for the last frame (param is 0-indexed) to be executed.
  270. //addFrameScript(totalFrames - 1, frameEndHandler);
  271. if (root && root.loaderInfo)
  272. root.loaderInfo.addEventListener(Event.INIT, initHandler);
  273. }
  274. /**
  275. * @private
  276. */
  277. private function deferredNextFrame():void
  278. {
  279. if (currentFrame + 1 > totalFrames)
  280. return;
  281. if (currentFrame + 1 <= framesLoaded)
  282. {
  283. nextFrame();
  284. }
  285. else
  286. {
  287. // Next frame isn't baked yet, so we'll check back...
  288. nextFrameTimer = new Timer(100);
  289. nextFrameTimer.addEventListener(TimerEvent.TIMER,
  290. nextFrameTimerHandler);
  291. nextFrameTimer.start();
  292. }
  293. }
  294. //--------------------------------------------------------------------------
  295. //
  296. // Variables
  297. //
  298. //--------------------------------------------------------------------------
  299. /**
  300. * @private
  301. * This flag remembers whether we're going to call executeCallbacks again
  302. */
  303. private var doneExecutingInitCallbacks:Boolean = false;
  304. /**
  305. * @private
  306. * This array stores pointers to all the init callback functions for this
  307. * system manager.
  308. * See registerInitCallback() for more information.
  309. */
  310. private var initCallbackFunctions:Array = [];
  311. /**
  312. * @private
  313. */
  314. private var initialized:Boolean = false;
  315. /**
  316. * @private
  317. * Whether we are in the top-level list or not;
  318. * top-level means we are the highest level SystemManager
  319. * for this stage.
  320. */
  321. mx_internal var topLevel:Boolean = true;
  322. /**
  323. * @private
  324. * Whether we are the stage root or not.
  325. * We are only the stage root if we were the root
  326. * of the first SWF that got loaded by the player.
  327. * Otherwise we could be top level but not stage root
  328. * if we are loaded by some other non-Flex shell
  329. * or are sandboxed.
  330. */
  331. private var isStageRoot:Boolean = true;
  332. /**
  333. * @private
  334. * Whether we are the first SWF loaded into a bootstrap
  335. * and therefore, the topLevelRoot
  336. */
  337. private var isBootstrapRoot:Boolean = false;
  338. /**
  339. * @private
  340. * If we're not top level, then we delegate many things
  341. * to the top level SystemManager.
  342. */
  343. private var _topLevelSystemManager:ISystemManager;
  344. /**
  345. * cached value of the stage.
  346. */
  347. private var _stage:Stage;
  348. /**
  349. * Depth of this object in the containment hierarchy.
  350. * This number is used by the measurement and layout code.
  351. */
  352. mx_internal var nestLevel:int = 0;
  353. /**
  354. * @private
  355. */
  356. private var rslSizes:Array = null;
  357. /**
  358. * @private
  359. * A reference to the preloader.
  360. */
  361. private var preloader:Preloader;
  362. /**
  363. * @private
  364. * The mouseCatcher is the 0th child of the SystemManager,
  365. * behind the application, which is child 1.
  366. * It is the same size as the stage and is filled with
  367. * transparent pixels; i.e., they've been drawn, but with alpha 0.
  368. *
  369. * Its purpose is to make every part of the stage
  370. * able to detect the mouse.
  371. * For example, a Button puts a mouseUp handler on the SystemManager
  372. * in order to capture mouseUp events that occur outside the Button.
  373. * But if the children of the SystemManager don't have "drawn-on"
  374. * pixels everywhere, the player won't dispatch the mouseUp.
  375. * We can't simply fill the SystemManager itself with
  376. * transparent pixels, because the player's pixel detection
  377. * logic doesn't look at pixels drawn into the root DisplayObject.
  378. *
  379. * Here is an example of what would happen without the mouseCatcher:
  380. * Run a fixed-size Application (e.g. width="600" height="600")
  381. * in the standalone player. Make the player window larger
  382. * to reveal part of the stage. Press a Button, drag off it
  383. * into the stage area, and release the mouse button.
  384. * Without the mouseCatcher, the Button wouldn't return to its "up" state.
  385. */
  386. private var mouseCatcher:Sprite;
  387. /**
  388. * @private
  389. * The top level window.
  390. */
  391. mx_internal var topLevelWindow:IUIComponent;
  392. /**
  393. * @private
  394. * List of top level windows.
  395. */
  396. private var forms:Array = [];
  397. /**
  398. * @private
  399. * The current top level window.
  400. *
  401. * Will be of type IFocusManagerContainer if the form
  402. * in the top-level system manager's application domain
  403. * or a child of that application domain. Otherwise the
  404. * form will be of type RemotePopUp.
  405. */
  406. private var form:Object;
  407. /**
  408. * @private
  409. * Number of frames since the last mouse or key activity.
  410. */
  411. mx_internal var idleCounter:int = 0;
  412. /**
  413. * @private
  414. * The Timer used to determine when to dispatch idle events.
  415. */
  416. private var idleTimer:Timer;
  417. /**
  418. * @private
  419. * A timer used when it is necessary to wait before incrementing the frame
  420. */
  421. private var nextFrameTimer:Timer = null;
  422. /**
  423. * @private
  424. * Track which frame was last processed
  425. */
  426. private var lastFrame:int;
  427. //--------------------------------------------------------------------------
  428. //
  429. // Overridden properties: DisplayObject
  430. //
  431. //--------------------------------------------------------------------------
  432. //----------------------------------
  433. // height
  434. //----------------------------------
  435. /**
  436. * @private
  437. */
  438. private var _height:Number;
  439. /**
  440. * The height of this object. For the SystemManager
  441. * this should always be the width of the stage unless the application was loaded
  442. * into another application. If the application was not loaded
  443. * into another application, setting this value has no effect.
  444. */
  445. override public function get height():Number
  446. {
  447. return _height;
  448. }
  449. //----------------------------------
  450. // stage
  451. //----------------------------------
  452. /**
  453. * @private
  454. * get the main stage if we're loaded into another swf in the same sandbox
  455. */
  456. override public function get stage():Stage
  457. {
  458. if (_stage)
  459. return _stage;
  460. var s:Stage = super.stage;
  461. if (s)
  462. {
  463. _stage = s;
  464. return s;
  465. }
  466. if (!topLevel && _topLevelSystemManager)
  467. {
  468. _stage = _topLevelSystemManager.stage;
  469. return _stage;
  470. }
  471. // Case for version skew, we are a top level system manager, but
  472. // a child of the top level root system manager and we have access
  473. // to the stage.
  474. if (!isStageRoot && topLevel)
  475. {
  476. var root:DisplayObject = getTopLevelRoot();
  477. if (root)
  478. {
  479. _stage = root.stage;
  480. return _stage;
  481. }
  482. }
  483. return null;
  484. }
  485. //----------------------------------
  486. // width
  487. //----------------------------------
  488. /**
  489. * @private
  490. */
  491. private var _width:Number;
  492. /**
  493. * The width of this object. For the SystemManager
  494. * this should always be the width of the stage unless the application was loaded
  495. * into another application. If the application was not loaded
  496. * into another application, setting this value will have no effect.
  497. */
  498. override public function get width():Number
  499. {
  500. return _width;
  501. }
  502. //--------------------------------------------------------------------------
  503. //
  504. // Overridden properties: DisplayObjectContainer
  505. //
  506. //--------------------------------------------------------------------------
  507. //----------------------------------
  508. // numChildren
  509. //----------------------------------
  510. /**
  511. * The number of non-floating windows. This is the main application window
  512. * plus any other windows added to the SystemManager that are not popups,
  513. * tooltips or cursors.
  514. */
  515. override public function get numChildren():int
  516. {
  517. return noTopMostIndex - applicationIndex;
  518. }
  519. //--------------------------------------------------------------------------
  520. //
  521. // Properties
  522. //
  523. //--------------------------------------------------------------------------
  524. //----------------------------------
  525. // application
  526. //----------------------------------
  527. /**
  528. * The application parented by this SystemManager.
  529. * SystemManagers create an instance of an Application
  530. * even if they are loaded into another Application.
  531. * Thus, this may not match mx.core.Application.application
  532. * if the SWF has been loaded into another application.
  533. * <p>Note that this property is not typed as mx.core.Application
  534. * because of load-time performance considerations
  535. * but can be coerced into an mx.core.Application.</p>
  536. */
  537. public function get application():IUIComponent
  538. {
  539. return IUIComponent(_document);
  540. }
  541. //----------------------------------
  542. // applicationIndex
  543. //----------------------------------
  544. /**
  545. * @private
  546. * Storage for the applicationIndex property.
  547. */
  548. private var _applicationIndex:int = 1;
  549. /**
  550. * @private
  551. * The index of the main mx.core.Application window, which is
  552. * effectively its z-order.
  553. */
  554. mx_internal function get applicationIndex():int
  555. {
  556. return _applicationIndex;
  557. }
  558. /**
  559. * @private
  560. */
  561. mx_internal function set applicationIndex(value:int):void
  562. {
  563. _applicationIndex = value;
  564. }
  565. //----------------------------------
  566. // bridgeToFocusManager
  567. //----------------------------------
  568. /**
  569. * @private
  570. * Map a bridge to a FocusManager.
  571. * This dictionary contains both the focus managers for this document as
  572. * well as focus managers that are in documents contained inside of pop
  573. * ups, if the system manager in that pop up requires a bridge to
  574. * communicate with this system manager.
  575. *
  576. * The returned object is an object of type IFocusManager.
  577. */
  578. private var _bridgeToFocusManager:Dictionary;
  579. /**
  580. * @private
  581. *
  582. * System Managers in child application domains use their parent's
  583. * bridgeToFocusManager's Dictionary. The swfBridgeGroup property
  584. * is maintained in the same way.
  585. */
  586. mx_internal function get bridgeToFocusManager():Dictionary
  587. {
  588. if (topLevel)
  589. return _bridgeToFocusManager;
  590. else if (topLevelSystemManager)
  591. return SystemManager(topLevelSystemManager).bridgeToFocusManager;
  592. return null;
  593. }
  594. mx_internal function set bridgeToFocusManager(bridgeToFMDictionary:Dictionary):void
  595. {
  596. if (topLevel)
  597. _bridgeToFocusManager = bridgeToFMDictionary;
  598. else if (topLevelSystemManager)
  599. SystemManager(topLevelSystemManager).bridgeToFocusManager = bridgeToFMDictionary;
  600. }
  601. //----------------------------------
  602. // cursorChildren
  603. //----------------------------------
  604. /**
  605. * @private
  606. * Storage for the cursorChildren property.
  607. */
  608. private var _cursorChildren:SystemChildrenList;
  609. /**
  610. * @inheritDoc
  611. */
  612. public function get cursorChildren():IChildList
  613. {
  614. if (!topLevel)
  615. return _topLevelSystemManager.cursorChildren;
  616. if (!_cursorChildren)
  617. {
  618. _cursorChildren = new SystemChildrenList(this,
  619. new QName(mx_internal, "toolTipIndex"),
  620. new QName(mx_internal, "cursorIndex"));
  621. }
  622. return _cursorChildren;
  623. }
  624. //----------------------------------
  625. // cursorIndex
  626. //----------------------------------
  627. /**
  628. * @private
  629. * Storage for the toolTipIndex property.
  630. */
  631. private var _cursorIndex:int = 0;
  632. /**
  633. * @private
  634. * The index of the highest child that is a cursor.
  635. */
  636. mx_internal function get cursorIndex():int
  637. {
  638. return _cursorIndex;
  639. }
  640. /**
  641. * @private
  642. */
  643. mx_internal function set cursorIndex(value:int):void
  644. {
  645. var delta:int = value - _cursorIndex;
  646. _cursorIndex = value;
  647. }
  648. //----------------------------------
  649. // document
  650. //----------------------------------
  651. /**
  652. * @private
  653. * Storage for the document property.
  654. */
  655. private var _document:Object;
  656. /**
  657. * @inheritDoc
  658. */
  659. public function get document():Object
  660. {
  661. return _document;
  662. }
  663. /**
  664. * @private
  665. */
  666. public function set document(value:Object):void
  667. {
  668. _document = value;
  669. }
  670. //----------------------------------
  671. // embeddedFontList
  672. //----------------------------------
  673. /**
  674. * @private
  675. * Storage for the fontList property.
  676. */
  677. private var _fontList:Object = null;
  678. /**
  679. * A table of embedded fonts in this application. The
  680. * object is a table indexed by the font name.
  681. */
  682. public function get embeddedFontList():Object
  683. {
  684. if (_fontList == null)
  685. {
  686. _fontList = {};
  687. var o:Object = info()["fonts"];
  688. var p:String;
  689. for (p in o)
  690. {
  691. _fontList[p] = o[p];
  692. }
  693. // FIXME: font rules across SWF boundaries have not been finalized!
  694. // Top level systemManager may not be defined if SWF is loaded
  695. // as a background image in download progress bar.
  696. if (!topLevel && _topLevelSystemManager)
  697. {
  698. var fl:Object = _topLevelSystemManager.embeddedFontList;
  699. for (p in fl)
  700. {
  701. _fontList[p] = fl[p];
  702. }
  703. }
  704. }
  705. return _fontList;
  706. }
  707. //----------------------------------
  708. // explicitHeight
  709. //----------------------------------
  710. /**
  711. * @private
  712. */
  713. private var _explicitHeight:Number;
  714. /**
  715. * The explicit width of this object. For the SystemManager
  716. * this should always be NaN unless the application was loaded
  717. * into another application. If the application was not loaded
  718. * into another application, setting this value has no effect.
  719. */
  720. public function get explicitHeight():Number
  721. {
  722. return _explicitHeight;
  723. }
  724. /**
  725. * @private
  726. */
  727. public function set explicitHeight(value:Number):void
  728. {
  729. _explicitHeight = value;
  730. }
  731. //----------------------------------
  732. // explicitWidth
  733. //----------------------------------
  734. /**
  735. * @private
  736. */
  737. private var _explicitWidth:Number;
  738. /**
  739. * The explicit width of this object. For the SystemManager
  740. * this should always be NaN unless the application was loaded
  741. * into another application. If the application was not loaded
  742. * into another application, setting this value has no effect.
  743. */
  744. public function get explicitWidth():Number
  745. {
  746. return _explicitWidth;
  747. }
  748. /**
  749. * @private
  750. */
  751. public function set explicitWidth(value:Number):void
  752. {
  753. _explicitWidth = value;
  754. }
  755. //----------------------------------
  756. // focusPane
  757. //----------------------------------
  758. /**
  759. * @private
  760. */
  761. private var _focusPane:Sprite;
  762. /**
  763. * @copy mx.core.UIComponent#focusPane
  764. */
  765. public function get focusPane():Sprite
  766. {
  767. return _focusPane;
  768. }
  769. /**
  770. * @private
  771. */
  772. public function set focusPane(value:Sprite):void
  773. {
  774. if (value)
  775. {
  776. addChild(value);
  777. value.x = 0;
  778. value.y = 0;
  779. value.scrollRect = null;
  780. _focusPane = value;
  781. }
  782. else
  783. {
  784. removeChild(_focusPane);
  785. _focusPane = null;
  786. }
  787. }
  788. //----------------------------------
  789. // info
  790. //----------------------------------
  791. /**
  792. * @private
  793. */
  794. public function info():Object
  795. {
  796. return {};
  797. }
  798. //----------------------------------
  799. // measuredHeight
  800. //----------------------------------
  801. /**
  802. * The measuredHeight is the explicit or measuredHeight of
  803. * the main mx.core.Application window
  804. * or the starting height of the SWF if the main window
  805. * has not yet been created or does not exist.
  806. */
  807. public function get measuredHeight():Number
  808. {
  809. return topLevelWindow ?
  810. topLevelWindow.getExplicitOrMeasuredHeight() :
  811. loaderInfo.height;
  812. }
  813. //----------------------------------
  814. // measuredWidth
  815. //----------------------------------
  816. /**
  817. * The measuredWidth is the explicit or measuredWidth of
  818. * the main mx.core.Application window,
  819. * or the starting width of the SWF if the main window
  820. * has not yet been created or does not exist.
  821. */
  822. public function get measuredWidth():Number
  823. {
  824. return topLevelWindow ?
  825. topLevelWindow.getExplicitOrMeasuredWidth() :
  826. loaderInfo.width;
  827. }
  828. //----------------------------------
  829. // noTopMostIndex
  830. //----------------------------------
  831. /**
  832. * @private
  833. * Storage for the noTopMostIndex property.
  834. */
  835. private var _noTopMostIndex:int = 0;
  836. /**
  837. * @private
  838. * The index of the highest child that isn't a topmost/popup window
  839. */
  840. mx_internal function get noTopMostIndex():int
  841. {
  842. return _noTopMostIndex;
  843. }
  844. /**
  845. * @private
  846. */
  847. mx_internal function set noTopMostIndex(value:int):void
  848. {
  849. var delta:int = value - _noTopMostIndex;
  850. _noTopMostIndex = value;
  851. topMostIndex += delta;
  852. }
  853. //----------------------------------
  854. // $numChildren
  855. //----------------------------------
  856. /**
  857. * @private
  858. * This property allows access to the Player's native implementation
  859. * of the numChildren property, which can be useful since components
  860. * can override numChildren and thereby hide the native implementation.
  861. * Note that this "base property" is final and cannot be overridden,
  862. * so you can count on it to reflect what is happening at the player level.
  863. */
  864. mx_internal final function get $numChildren():int
  865. {
  866. return super.numChildren;
  867. }
  868. //----------------------------------
  869. // numModalWindows
  870. //----------------------------------
  871. /**
  872. * @private
  873. * Storage for the numModalWindows property.
  874. */
  875. private var _numModalWindows:int = 0;
  876. /**
  877. * The number of modal windows. Modal windows don't allow
  878. * clicking in another windows which would normally
  879. * activate the FocusManager in that window. The PopUpManager
  880. * modifies this count as it creates and destroys modal windows.
  881. */
  882. public function get numModalWindows():int
  883. {
  884. return _numModalWindows;
  885. }
  886. /**
  887. * @private
  888. */
  889. public function set numModalWindows(value:int):void
  890. {
  891. _numModalWindows = value;
  892. }
  893. //----------------------------------
  894. // preloaderBackgroundAlpha
  895. //----------------------------------
  896. /**
  897. * The background alpha used by the child of the preloader.
  898. */
  899. public function get preloaderBackgroundAlpha():Number
  900. {
  901. return info()["backgroundAlpha"];
  902. }
  903. //----------------------------------
  904. // preloaderBackgroundColor
  905. //----------------------------------
  906. /**
  907. * The background color used by the child of the preloader.
  908. */
  909. public function get preloaderBackgroundColor():uint
  910. {
  911. var value:* = info()["backgroundColor"];
  912. if (value == undefined)
  913. return StyleManager.NOT_A_COLOR;
  914. else
  915. return StyleManager.getColorName(value);
  916. }
  917. //----------------------------------
  918. // preloaderBackgroundImage
  919. //----------------------------------
  920. /**
  921. * The background color used by the child of the preloader.
  922. */
  923. public function get preloaderBackgroundImage():Object
  924. {
  925. return info()["backgroundImage"];
  926. }
  927. //----------------------------------
  928. // preloaderBackgroundSize
  929. //----------------------------------
  930. /**
  931. * The background size used by the child of the preloader.
  932. */
  933. public function get preloaderBackgroundSize():String
  934. {
  935. return info()["backgroundSize"];
  936. }
  937. //----------------------------------
  938. // popUpChildren
  939. //----------------------------------
  940. /**
  941. * @private
  942. * Storage for the popUpChildren property.
  943. */
  944. private var _popUpChildren:SystemChildrenList;
  945. /**
  946. * @inheritDoc
  947. */
  948. public function get popUpChildren():IChildList
  949. {
  950. if (!topLevel)
  951. return _topLevelSystemManager.popUpChildren;
  952. if (!_popUpChildren)
  953. {
  954. _popUpChildren = new SystemChildrenList(this,
  955. new QName(mx_internal, "noTopMostIndex"),
  956. new QName(mx_internal, "topMostIndex"));
  957. }
  958. return _popUpChildren;
  959. }
  960. //----------------------------------
  961. // rawChildren
  962. //----------------------------------
  963. /**
  964. * @private
  965. * Storage for the rawChildren property.
  966. */
  967. private var _rawChildren:SystemRawChildrenList;
  968. /**
  969. * @inheritDoc
  970. */
  971. public function get rawChildren():IChildList
  972. {
  973. //if (!topLevel)
  974. // return _topLevelSystemManager.rawChildren;
  975. if (!_rawChildren)
  976. _rawChildren = new SystemRawChildrenList(this);
  977. return _rawChildren;
  978. }
  979. //--------------------------------------------------------------------------
  980. // sandbox bridge group
  981. //--------------------------------------------------------------------------
  982. /**
  983. * @private
  984. *
  985. * Represents the related parent and child sandboxs this SystemManager may
  986. * communicate with.
  987. */
  988. private var _swfBridgeGroup:ISWFBridgeGroup;
  989. public function get swfBridgeGroup():ISWFBridgeGroup
  990. {
  991. if (topLevel)
  992. return _swfBridgeGroup;
  993. else if (topLevelSystemManager)
  994. return topLevelSystemManager.swfBridgeGroup;
  995. return null;
  996. }
  997. public function set swfBridgeGroup(bridgeGroup:ISWFBridgeGroup):void
  998. {
  999. if (topLevel)
  1000. _swfBridgeGroup = bridgeGroup;
  1001. else if (topLevelSystemManager)
  1002. SystemManager(topLevelSystemManager).swfBridgeGroup = bridgeGroup;
  1003. }
  1004. //--------------------------------------------------------------------------
  1005. // screen
  1006. //--------------------------------------------------------------------------
  1007. /**
  1008. * @private
  1009. * Storage for the screen property.
  1010. */
  1011. private var _screen:Rectangle;
  1012. /**
  1013. * @inheritDoc
  1014. */
  1015. public function get screen():Rectangle
  1016. {
  1017. if (!_screen)
  1018. Stage_resizeHandler();
  1019. if (!isStageRoot)
  1020. {
  1021. Stage_resizeHandler();
  1022. }
  1023. return _screen;
  1024. }
  1025. //----------------------------------
  1026. // toolTipChildren
  1027. //----------------------------------
  1028. /**
  1029. * @private
  1030. * Storage for the toolTipChildren property.
  1031. */
  1032. private var _toolTipChildren:SystemChildrenList;
  1033. /**
  1034. * @inheritDoc
  1035. */
  1036. public function get toolTipChildren():IChildList
  1037. {
  1038. if (!topLevel)
  1039. return _topLevelSystemManager.toolTipChildren;
  1040. if (!_toolTipChildren)
  1041. {
  1042. _toolTipChildren = new SystemChildrenList(this,
  1043. new QName(mx_internal, "topMostIndex"),
  1044. new QName(mx_internal, "toolTipIndex"));
  1045. }
  1046. return _toolTipChildren;
  1047. }
  1048. //----------------------------------
  1049. // toolTipIndex
  1050. //----------------------------------
  1051. /**
  1052. * @private
  1053. * Storage for the toolTipIndex property.
  1054. */
  1055. private var _toolTipIndex:int = 0;
  1056. /**
  1057. * @private
  1058. * The index of the highest child that is a tooltip
  1059. */
  1060. mx_internal function get toolTipIndex():int
  1061. {
  1062. return _toolTipIndex;
  1063. }
  1064. /**
  1065. * @private
  1066. */
  1067. mx_internal function set toolTipIndex(value:int):void
  1068. {
  1069. var delta:int = value - _toolTipIndex;
  1070. _toolTipIndex = value;
  1071. cursorIndex += delta;
  1072. }
  1073. //----------------------------------
  1074. // topLevelSystemManager
  1075. //----------------------------------
  1076. /**
  1077. * Returns the SystemManager responsible for the application window. This will be
  1078. * the same SystemManager unless this application has been loaded into another
  1079. * application.
  1080. */
  1081. public function get topLevelSystemManager():ISystemManager
  1082. {
  1083. if (topLevel)
  1084. return this;
  1085. return _topLevelSystemManager;
  1086. }
  1087. //----------------------------------
  1088. // topMostIndex
  1089. //----------------------------------
  1090. /**
  1091. * @private
  1092. * Storage for the topMostIndex property.
  1093. */
  1094. private var _topMostIndex:int = 0;
  1095. /**
  1096. * @private
  1097. * The index of the highest child that is a topmost/popup window
  1098. */
  1099. mx_internal function get topMostIndex():int
  1100. {
  1101. return _topMostIndex;
  1102. }
  1103. mx_internal function set topMostIndex(value:int):void
  1104. {
  1105. var delta:int = value - _topMostIndex;
  1106. _topMostIndex = value;
  1107. toolTipIndex += delta;
  1108. }
  1109. //--------------------------------------------------------------------------
  1110. //
  1111. // Properties: ISWFBridgeProvider
  1112. //
  1113. //--------------------------------------------------------------------------
  1114. /**
  1115. * @inheritDoc
  1116. */
  1117. public function get swfBridge():IEventDispatcher
  1118. {
  1119. if (swfBridgeGroup)
  1120. return swfBridgeGroup.parentBridge;
  1121. return null;
  1122. }
  1123. /**
  1124. * @inheritDoc
  1125. */
  1126. public function get childAllowsParent():Boolean
  1127. {
  1128. try
  1129. {
  1130. return loaderInfo.childAllowsParent;
  1131. }
  1132. catch (error:Error)
  1133. {
  1134. //Error #2099: The loading object is not sufficiently loaded to provide this information.
  1135. }
  1136. return false; // assume the worst
  1137. }
  1138. /**
  1139. * @inheritDoc
  1140. */
  1141. public function get parentAllowsChild():Boolean
  1142. {
  1143. try
  1144. {
  1145. return loaderInfo.parentAllowsChild;
  1146. }
  1147. catch (error:Error)
  1148. {
  1149. //Error #2099: The loading object is not sufficiently loaded to provide this information.
  1150. }
  1151. return false; // assume the worst
  1152. }
  1153. /**
  1154. * @private
  1155. *
  1156. * true if redipatching a resize event.
  1157. */
  1158. private var isDispatchingResizeEvent:Boolean;
  1159. /**
  1160. * @private
  1161. *
  1162. * Used to locate untrusted forms. Maps string ids to Objects.
  1163. * The object make be the SystemManagerProxy of a form or it may be
  1164. * the bridge to the child application where the object lives.
  1165. */
  1166. private var idToPlaceholder:Object;
  1167. private var eventProxy:EventProxy;
  1168. private var weakReferenceProxies:Dictionary = new Dictionary(true);
  1169. private var strongReferenceProxies:Dictionary = new Dictionary(false);
  1170. //--------------------------------------------------------------------------
  1171. //
  1172. // Overridden methods: EventDispatcher
  1173. //
  1174. //--------------------------------------------------------------------------
  1175. /**
  1176. * @private
  1177. * Only create idle events if someone is listening.
  1178. */
  1179. override public function addEventListener(type:String, listener:Function,
  1180. useCapture:Boolean = false,
  1181. priority:int = 0,
  1182. useWeakReference:Boolean = false):void
  1183. {
  1184. // These two events will dispatched to applications in sandboxes.
  1185. if (type == FlexEvent.RENDER || type == FlexEvent.ENTER_FRAME)
  1186. {
  1187. if (type == FlexEvent.RENDER)
  1188. type = Event.RENDER;
  1189. else
  1190. type = Event.ENTER_FRAME;
  1191. try
  1192. {
  1193. if (stage)
  1194. stage.addEventListener(type, listener, useCapture, priority, useWeakReference);
  1195. else
  1196. super.addEventListener(type, listener, useCapture, priority, useWeakReference);
  1197. }
  1198. catch (error:SecurityError)
  1199. {
  1200. super.addEventListener(type, listener, useCapture, priority, useWeakReference);
  1201. }
  1202. if (stage && type == Event.RENDER)
  1203. stage.invalidate();
  1204. return;
  1205. }
  1206. if (type == MouseEvent.MOUSE_MOVE || type == MouseEvent.MOUSE_UP || type == MouseEvent.MOUSE_DOWN
  1207. || type == Event.ACTIVATE || type == Event.DEACTIVATE)
  1208. {
  1209. // also listen to stage if allowed
  1210. try
  1211. {
  1212. if (stage)
  1213. {
  1214. var newListener:StageEventProxy = new StageEventProxy(listener);
  1215. stage.addEventListener(type, newListener.stageListener, false, priority, useWeakReference);
  1216. if (useWeakReference)
  1217. weakReferenceProxies[listener] = newListener;
  1218. else
  1219. strongReferenceProxies[listener] = newListener;
  1220. }
  1221. }
  1222. catch (error:SecurityError)
  1223. {
  1224. }
  1225. }
  1226. if (hasSWFBridges() || SystemManagerGlobals.topLevelSystemManagers.length > 1)
  1227. {
  1228. if (!eventProxy)
  1229. {
  1230. eventProxy = new EventProxy(this);
  1231. }
  1232. var actualType:String = EventUtil.sandboxMouseEventMap[type];
  1233. if (actualType)
  1234. {
  1235. if (isTopLevelRoot())
  1236. {
  1237. stage.addEventListener(MouseEvent.MOUSE_MOVE, resetMouseCursorTracking, true, EventPriority.CURSOR_MANAGEMENT + 1, true);
  1238. addEventListenerToSandboxes(SandboxMouseEvent.MOUSE_MOVE_SOMEWHERE, resetMouseCursorTracking, true, EventPriority.CURSOR_MANAGEMENT + 1, true);
  1239. }
  1240. else
  1241. {
  1242. super.addEventListener(MouseEvent.MOUSE_MOVE, resetMouseCursorTracking, true, EventPriority.CURSOR_MANAGEMENT + 1, true);
  1243. }
  1244. addEventListenerToSandboxes(type, sandboxMouseListener, useCapture, priority, useWeakReference);
  1245. if (!SystemManagerGlobals.changingListenersInOtherSystemManagers)
  1246. addEventListenerToOtherSystemManagers(type, otherSystemManagerMouseListener, useCapture, priority, useWeakReference)
  1247. if (getSandboxRoot() == this)
  1248. super.addEventListener(actualType, eventProxy.marshalListener,
  1249. useCapture, priority, useWeakReference);
  1250. // Set useCapture to false because we will never see an event
  1251. // marshalled in the capture phase.
  1252. super.addEventListener(type, listener, false, priority, useWeakReference);
  1253. return;
  1254. }
  1255. }
  1256. // When the first listener registers for 'idle' events,
  1257. // create a Timer that will fire every IDLE_INTERVAL.
  1258. if (type == FlexEvent.IDLE && !idleTimer)
  1259. {
  1260. idleTimer = new Timer(IDLE_INTERVAL);
  1261. idleTimer.addEventListener(TimerEvent.TIMER,
  1262. idleTimer_timerHandler);
  1263. idleTimer.start();
  1264. // Make sure we get all activity
  1265. // in case someone calls stopPropagation().
  1266. addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true);
  1267. addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true);
  1268. }
  1269. super.addEventListener(type, listener, useCapture, priority, useWeakReference);
  1270. }
  1271. /**
  1272. * @private
  1273. *
  1274. * Test if this system manager has any sandbox bridges.
  1275. *
  1276. * @return true if there are sandbox bridges, false otherwise.
  1277. */
  1278. private function hasSWFBridges():Boolean
  1279. {
  1280. if (swfBridgeGroup)
  1281. return true;
  1282. return false;
  1283. }
  1284. /**
  1285. * @private
  1286. */
  1287. override public function removeEventListener(type:String, listener:Function,
  1288. useCapture:Boolean = false):void
  1289. {
  1290. // These two events will dispatched to applications in sandboxes.
  1291. if (type == FlexEvent.RENDER || type == FlexEvent.ENTER_FRAME)
  1292. {
  1293. if (type == FlexEvent.RENDER)
  1294. type = Event.RENDER;
  1295. else
  1296. type = Event.ENTER_FRAME;
  1297. try
  1298. {
  1299. // Remove both listeners in case the system manager was added
  1300. // or removed from the stage after the listener was added.
  1301. if (stage)
  1302. stage.removeEventListener(type, listener, useCapture);
  1303. super.removeEventListener(type, listener, useCapture);
  1304. }
  1305. catch (error:SecurityError)
  1306. {
  1307. super.removeEventListener(type, listener, useCapture);
  1308. }
  1309. return;
  1310. }
  1311. if (type == MouseEvent.MOUSE_MOVE || type == MouseEvent.MOUSE_UP || type == MouseEvent.MOUSE_DOWN
  1312. || type == Event.ACTIVATE || type == Event.DEACTIVATE)
  1313. {
  1314. // also listen to stage if allowed
  1315. try
  1316. {
  1317. if (stage)
  1318. {
  1319. var newListener:StageEventProxy = weakReferenceProxies[listener];
  1320. if (!newListener)
  1321. {
  1322. newListener = strongReferenceProxies[listener];
  1323. if (newListener)
  1324. delete strongReferenceProxies[listener];
  1325. }
  1326. if (newListener)
  1327. stage.removeEventListener(type, newListener.stageListener, false);
  1328. }
  1329. }
  1330. catch (error:SecurityError)
  1331. {
  1332. }
  1333. }
  1334. if (hasSWFBridges() || SystemManagerGlobals.topLevelSystemManagers.length > 1)
  1335. {
  1336. var actualType:String = EventUtil.sandboxMouseEventMap[type];
  1337. if (actualType)
  1338. {
  1339. if (getSandboxRoot() == this && eventProxy)
  1340. super.removeEventListener(actualType, eventProxy.marshalListener,
  1341. useCapture);
  1342. if (!SystemManagerGlobals.changingListenersInOtherSystemManagers)
  1343. removeEventListenerFromOtherSystemManagers(type, otherSystemManagerMouseListener, useCapture);
  1344. removeEventListenerFromSandboxes(type, sandboxMouseListener, useCapture);
  1345. super.removeEventListener(type, listener, false);
  1346. return;
  1347. }
  1348. }
  1349. // When the last listener unregisters for 'idle' events,
  1350. // stop and release the Timer.
  1351. if (type == FlexEvent.IDLE)
  1352. {
  1353. super.removeEventListener(type, listener, useCapture);
  1354. if (!hasEventListener(FlexEvent.IDLE) && idleTimer)
  1355. {
  1356. idleTimer.stop();
  1357. idleTimer = null;
  1358. removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
  1359. removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
  1360. }
  1361. }
  1362. else
  1363. {
  1364. super.removeEventListener(type, listener, useCapture);
  1365. }
  1366. }
  1367. //--------------------------------------------------------------------------
  1368. //
  1369. // Overridden methods: DisplayObjectContainer
  1370. //
  1371. //--------------------------------------------------------------------------
  1372. /**
  1373. * @private
  1374. */
  1375. override public function addChild(child:DisplayObject):DisplayObject
  1376. {
  1377. // Adjust the partition indexes
  1378. // before the "added" event is dispatched.
  1379. noTopMostIndex++;
  1380. return rawChildren_addChildAt(child, noTopMostIndex - 1);
  1381. }
  1382. /**
  1383. * @private
  1384. */
  1385. override public function addChildAt(child:DisplayObject,
  1386. index:int):DisplayObject
  1387. {
  1388. // Adjust the partition indexes
  1389. // before the "added" event is dispatched.
  1390. noTopMostIndex++;
  1391. return rawChildren_addChildAt(child, applicationIndex + index);
  1392. }
  1393. /**
  1394. * @private
  1395. *
  1396. * Used by SystemManagerProxy to add a mouse catcher as a child.
  1397. */
  1398. mx_internal final function $addChildAt(child:DisplayObject,
  1399. index:int):DisplayObject
  1400. {
  1401. return super.addChildAt(child, index);
  1402. }
  1403. /**
  1404. * @private
  1405. *
  1406. * Companion to $addChildAt.
  1407. */
  1408. mx_internal final function $removeChildAt(index:int):DisplayObject
  1409. {
  1410. return super.removeChildAt(index);
  1411. }
  1412. /**
  1413. * @private
  1414. */
  1415. override public function removeChild(child:DisplayObject):DisplayObject
  1416. {
  1417. // Adjust the partition indexes
  1418. // before the "removed" event is dispatched.
  1419. noTopMostIndex--;
  1420. return rawChildren_removeChild(child);
  1421. }
  1422. /**
  1423. * @private
  1424. */
  1425. override public function removeChildAt(index:int):DisplayObject
  1426. {
  1427. // Adjust the partition indexes
  1428. // before the "removed" event is dispatched.
  1429. noTopMostIndex--;
  1430. return rawChildren_removeChildAt(applicationIndex + index);
  1431. }
  1432. /**
  1433. * @private
  1434. */
  1435. override public function getChildAt(index:int):DisplayObject
  1436. {
  1437. return super.getChildAt(applicationIndex + index)
  1438. }
  1439. /**
  1440. * @private
  1441. */
  1442. override public function getChildByName(name:String):DisplayObject
  1443. {
  1444. return super.getChildByName(name);
  1445. }
  1446. /**
  1447. * @private
  1448. */
  1449. override public function getChildIndex(child:DisplayObject):int
  1450. {
  1451. return super.getChildIndex(child) - applicationIndex;
  1452. }
  1453. /**
  1454. * @private
  1455. */
  1456. override public function setChildIndex(child:DisplayObject, newIndex:int):void
  1457. {
  1458. super.setChildIndex(child, applicationIndex + newIndex)
  1459. }
  1460. /**
  1461. * @private
  1462. */
  1463. override public function getObjectsUnderPoint(point:Point):Array
  1464. {
  1465. var children:Array = [];
  1466. // Get all the children that aren't tooltips and cursors.
  1467. var n:int = topMostIndex;
  1468. for (var i:int = 0; i < n; i++)
  1469. {
  1470. var child:DisplayObject = super.getChildAt(i);
  1471. if (child is DisplayObjectContainer)
  1472. {
  1473. var temp:Array =
  1474. DisplayObjectContainer(child).getObjectsUnderPoint(point);
  1475. if (temp)
  1476. children = children.concat(temp);
  1477. }
  1478. }
  1479. return children;
  1480. }
  1481. /**
  1482. * @private
  1483. */
  1484. override public function contains(child:DisplayObject):Boolean
  1485. {
  1486. if (super.contains(child))
  1487. {
  1488. if (child.parent == this)
  1489. {
  1490. var childIndex:int = super.getChildIndex(child);
  1491. if (childIndex < noTopMostIndex)
  1492. return true;
  1493. }
  1494. else
  1495. {
  1496. for (var i:int = 0; i < noTopMostIndex; i++)
  1497. {
  1498. var myChild:DisplayObject = super.getChildAt(i);
  1499. if (myChild is IRawChildrenContainer)
  1500. {
  1501. if (IRawChildrenContainer(myChild).rawChildren.contains(child))
  1502. return true;
  1503. }
  1504. if (myChild is DisplayObjectContainer)
  1505. {
  1506. if (DisplayObjectContainer(myChild).contains(child))
  1507. return true;
  1508. }
  1509. }
  1510. }
  1511. }
  1512. return false;
  1513. }
  1514. //--------------------------------------------------------------------------
  1515. //
  1516. // Methods: Initialization
  1517. //
  1518. //--------------------------------------------------------------------------
  1519. /**
  1520. * A factory method that requests an instance of a
  1521. * definition known to the module.
  1522. *
  1523. * You can provide an optional set of parameters to let building
  1524. * factories change what they create based on the
  1525. * input. Passing null indicates that the default definition
  1526. * is created, if possible.
  1527. *
  1528. * This method is overridden in the autogenerated subclass.
  1529. *
  1530. * @param params An optional list of arguments. You can pass
  1531. * any number of arguments, which are then stored in an Array
  1532. * called <code>parameters</code>.
  1533. *
  1534. * @return An instance of the module, or <code>null</code>.
  1535. */
  1536. public function create(... params):Object
  1537. {
  1538. var mainClassName:String = info()["mainClassName"];
  1539. if (mainClassName == null)
  1540. {
  1541. var url:String = loaderInfo.loaderURL;
  1542. var dot:int = url.lastIndexOf(".");
  1543. var slash:int = url.lastIndexOf("/");
  1544. mainClassName = url.substring(slash + 1, dot);
  1545. }
  1546. var mainClass:Class = Class(getDefinitionByName(mainClassName));
  1547. return mainClass ? new mainClass() : null;
  1548. }
  1549. /**
  1550. * @private
  1551. * Creates an instance of the preloader, adds it as a child, and runs it.
  1552. * This is needed by FlexBuilder. Do not modify this function.
  1553. */
  1554. mx_internal function initialize():void
  1555. {
  1556. if (isStageRoot)
  1557. {
  1558. _width = stage.stageWidth;
  1559. _height = stage.stageHeight;
  1560. }
  1561. else
  1562. {
  1563. _width = loaderInfo.width;
  1564. _height = loaderInfo.height;
  1565. }
  1566. // Create an instance of the preloader and add it to the stage
  1567. preloader = new Preloader();
  1568. // Listen for preloader events
  1569. // Once the preloader dispatches initStart, then create the application instance
  1570. preloader.addEventListener(FlexEvent.INIT_PROGRESS,
  1571. preloader_initProgressHandler);
  1572. preloader.addEventListener(FlexEvent.PRELOADER_DONE,
  1573. preloader_preloaderDoneHandler);
  1574. // Add the preloader as a child. Use backing variable because when loaded
  1575. // we redirect public API to parent systemmanager
  1576. if (!_popUpChildren)
  1577. {
  1578. _popUpChildren = new SystemChildrenList(
  1579. this, new QName(mx_internal, "noTopMostIndex"), new QName(mx_internal, "topMostIndex"));
  1580. }
  1581. _popUpChildren.addChild(preloader);
  1582. var rsls:Array = info()["rsls"];
  1583. var cdRsls:Array = info()["cdRsls"];
  1584. var usePreloader:Boolean = true;
  1585. if (info()["usePreloader"] != undefined)
  1586. usePreloader = info()["usePreloader"];
  1587. var preloaderDisplayClass:Class = info()["preloader"] as Class;
  1588. if (usePreloader && !preloaderDisplayClass)
  1589. preloaderDisplayClass = DownloadProgressBar;
  1590. // Put cross-domain RSL information in the RSL list.
  1591. var rslList:Array = [];
  1592. var n:int;
  1593. var i:int;
  1594. if (cdRsls && cdRsls.length > 0)
  1595. {
  1596. var crossDomainRSLItem:Class = Class(getDefinitionByName("mx.core::CrossDomainRSLItem"));
  1597. n = cdRsls.length;
  1598. for (i = 0; i < n; i++)
  1599. {
  1600. // If crossDomainRSLItem is null, then this is a compiler error. It should not be null.
  1601. var cdNode:Object = new crossDomainRSLItem(cdRsls[i]["rsls"],
  1602. cdRsls[i]["policyFiles"],
  1603. cdRsls[i]["digests"],
  1604. cdRsls[i]["types"],
  1605. cdRsls[i]["isSigned"],
  1606. LoaderUtil.normalizeURL(this.loaderInfo));
  1607. rslList.push(cdNode);
  1608. }
  1609. }
  1610. // Append RSL information in the RSL list.
  1611. if (rsls != null && rsls.length > 0)
  1612. {
  1613. n = rsls.length;
  1614. for (i = 0; i < n; i++)
  1615. {
  1616. var node:RSLItem = new RSLItem(rsls[i].url, LoaderUtil.normalizeURL(this.loaderInfo));
  1617. rslList.push(node);
  1618. }
  1619. }
  1620. // Register the ResourceManager class with Singleton early
  1621. // so that we can use the ResourceManager in frame 1.
  1622. // Same with EmbfeddedFontRegistry and StyleManager
  1623. // The other managers get registered with Singleton later,
  1624. // in frame 2, by docFrameHandler().
  1625. Singleton.registerClass("mx.resources::IResourceManager",
  1626. Class(getDefinitionByName("mx.resources::ResourceManagerImpl")));
  1627. var resourceManager:IResourceManager = ResourceManager.getInstance();
  1628. var fontRegistry:EmbeddedFontRegistry; // link in the EmbeddedFontRegistry Class

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