PageRenderTime 56ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 1ms

/Sample/mx/core/UIComponent.as

https://github.com/ingydotnet/yaml-oscon2009-talk
ActionScript | 9391 lines | 3597 code | 1187 blank | 4607 comment | 722 complexity | 0e45c94c110a3d960aa5a72a5e0131f0 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.core
  12. {
  13. import flash.display.DisplayObject;
  14. import flash.display.DisplayObjectContainer;
  15. import flash.display.GradientType;
  16. import flash.display.Graphics;
  17. import flash.display.InteractiveObject;
  18. import flash.display.Loader;
  19. import flash.display.Sprite;
  20. import flash.display.Stage;
  21. import flash.events.Event;
  22. import flash.events.EventPhase;
  23. import flash.events.FocusEvent;
  24. import flash.events.IEventDispatcher;
  25. import flash.events.KeyboardEvent;
  26. import flash.geom.Matrix;
  27. import flash.geom.Point;
  28. import flash.geom.Rectangle;
  29. import flash.system.ApplicationDomain;
  30. import flash.text.TextLineMetrics;
  31. import flash.utils.getQualifiedClassName;
  32. import flash.utils.getQualifiedSuperclassName;
  33. import mx.automation.IAutomationObject;
  34. import mx.binding.BindingManager;
  35. import mx.controls.IFlexContextMenu;
  36. import mx.effects.EffectManager;
  37. import mx.effects.IEffect;
  38. import mx.effects.IEffectInstance;
  39. import mx.events.ChildExistenceChangedEvent;
  40. import mx.events.DragEvent;
  41. import mx.events.DynamicEvent;
  42. import mx.events.EffectEvent;
  43. import mx.events.FlexEvent;
  44. import mx.events.MoveEvent;
  45. import mx.events.PropertyChangeEvent;
  46. import mx.events.ResizeEvent;
  47. import mx.events.StateChangeEvent;
  48. import mx.events.ToolTipEvent;
  49. import mx.events.ValidationResultEvent;
  50. import mx.graphics.RoundedRectangle;
  51. import mx.managers.CursorManager;
  52. import mx.managers.ICursorManager;
  53. import mx.managers.IFocusManager;
  54. import mx.managers.IFocusManagerComponent;
  55. import mx.managers.IFocusManagerContainer;
  56. import mx.managers.ILayoutManagerClient;
  57. import mx.managers.ISystemManager;
  58. import mx.managers.IToolTipManagerClient;
  59. import mx.managers.SystemManager;
  60. import mx.managers.SystemManagerGlobals;
  61. import mx.managers.SystemManagerProxy;
  62. import mx.managers.ToolTipManager;
  63. import mx.modules.ModuleManager;
  64. import mx.resources.IResourceManager;
  65. import mx.resources.ResourceManager;
  66. import mx.states.State;
  67. import mx.states.Transition;
  68. import mx.styles.CSSStyleDeclaration;
  69. import mx.styles.ISimpleStyleClient;
  70. import mx.styles.IStyleClient;
  71. import mx.styles.StyleManager;
  72. import mx.styles.StyleProtoChain;
  73. import mx.utils.ColorUtil;
  74. import mx.utils.GraphicsUtil;
  75. import mx.utils.StringUtil;
  76. import mx.validators.IValidatorListener;
  77. import mx.validators.ValidationResult;
  78. import flash.system.Security;
  79. use namespace mx_internal;
  80. //--------------------------------------
  81. // Lifecycle events
  82. //--------------------------------------
  83. /**
  84. * Dispatched when the component is added to a container as a content child
  85. * by using the <code>addChild()</code> or <code>addChildAt()</code> method.
  86. * If the component is added to the container as a noncontent child by
  87. * using the <code>rawChildren.addChild()</code> or
  88. * <code>rawChildren.addChildAt()</code> method, the event is not dispatched.
  89. *
  90. * @eventType mx.events.FlexEvent.ADD
  91. */
  92. [Event(name="add", type="mx.events.FlexEvent")]
  93. /**
  94. * Dispatched when the component has finished its construction,
  95. * property processing, measuring, layout, and drawing.
  96. *
  97. * <p>At this point, depending on its <code>visible</code> property,
  98. * the component may not be visible even though it has been drawn.</p>
  99. *
  100. * @eventType mx.events.FlexEvent.CREATION_COMPLETE
  101. */
  102. [Event(name="creationComplete", type="mx.events.FlexEvent")]
  103. /**
  104. * Dispatched when an object has had its <code>commitProperties()</code>,
  105. * <code>measure()</code>, and
  106. * <code>updateDisplayList()</code> methods called (if needed).
  107. *
  108. * <p>This is the last opportunity to alter the component before it is
  109. * displayed. All properties have been committed and the component has
  110. * been measured and layed out.</p>
  111. *
  112. * @eventType mx.events.FlexEvent.UPDATE_COMPLETE
  113. */
  114. [Event(name="updateComplete", type="mx.events.FlexEvent")]
  115. /**
  116. * Dispatched when an object's state changes from visible to invisible.
  117. *
  118. * @eventType mx.events.FlexEvent.HIDE
  119. */
  120. [Event(name="hide", type="mx.events.FlexEvent")]
  121. /**
  122. * Dispatched when the component has finished its construction
  123. * and has all initialization properties set.
  124. *
  125. * <p>After the initialization phase, properties are processed, the component
  126. * is measured, laid out, and drawn, after which the
  127. * <code>creationComplete</code> event is dispatched.</p>
  128. *
  129. * @eventType mx.events.FlexEvent.INITIALIZE
  130. */
  131. [Event(name="initialize", type="mx.events.FlexEvent")]
  132. /**
  133. * Dispatched when the object has moved.
  134. *
  135. * <p>You can move the component by setting the <code>x</code>
  136. * or <code>y</code> properties, by calling the <code>move()</code>
  137. * method, by setting one
  138. * of the following properties either on the component or on other
  139. * components such that the LayoutManager needs to change the
  140. * <code>x</code> or <code>y</code> properties of the component:</p>
  141. *
  142. * <ul>
  143. * <li><code>minWidth</code></li>
  144. * <li><code>minHeight</code></li>
  145. * <li><code>maxWidth</code></li>
  146. * <li><code>maxHeight</code></li>
  147. * <li><code>explicitWidth</code></li>
  148. * <li><code>explicitHeight</code></li>
  149. * </ul>
  150. *
  151. * <p>When you call the <code>move()</code> method, the <code>move</code>
  152. * event is dispatched before the method returns.
  153. * In all other situations, the <code>move</code> event is not dispatched
  154. * until after the property changes.</p>
  155. *
  156. * @eventType mx.events.MoveEvent.MOVE
  157. */
  158. [Event(name="move", type="mx.events.MoveEvent")]
  159. /**
  160. * Dispatched at the beginning of the component initialization sequence.
  161. * The component is in a very raw state when this event is dispatched.
  162. * Many components, such as the Button control, create internal child
  163. * components to implement functionality; for example, the Button control
  164. * creates an internal UITextField component to represent its label text.
  165. * When Flex dispatches the <code>preinitialize</code> event,
  166. * the children, including the internal children, of a component
  167. * have not yet been created.
  168. *
  169. * @eventType mx.events.FlexEvent.PREINITIALIZE
  170. */
  171. [Event(name="preinitialize", type="mx.events.FlexEvent")]
  172. /**
  173. * Dispatched when the component is removed from a container as a content child
  174. * by using the <code>removeChild()</code> or <code>removeChildAt()</code> method.
  175. * If the component is removed from the container as a noncontent child by
  176. * using the <code>rawChildren.removeChild()</code> or
  177. * <code>rawChildren.removeChildAt()</code> method, the event is not dispatched.
  178. *
  179. * @eventType mx.events.FlexEvent.REMOVE
  180. */
  181. [Event(name="remove", type="mx.events.FlexEvent")]
  182. /**
  183. * Dispatched when the component is resized.
  184. *
  185. * <p>You can resize the component by setting the <code>width</code> or
  186. * <code>height</code> property, by calling the <code>setActualSize()</code>
  187. * method, or by setting one of
  188. * the following properties either on the component or on other components
  189. * such that the LayoutManager needs to change the <code>width</code> or
  190. * <code>height</code> properties of the component:</p>
  191. *
  192. * <ul>
  193. * <li><code>minWidth</code></li>
  194. * <li><code>minHeight</code></li>
  195. * <li><code>maxWidth</code></li>
  196. * <li><code>maxHeight</code></li>
  197. * <li><code>explicitWidth</code></li>
  198. * <li><code>explicitHeight</code></li>
  199. * </ul>
  200. *
  201. * <p>The <code>resize</code> event is not
  202. * dispatched until after the property changes.</p>
  203. *
  204. * @eventType mx.events.ResizeEvent.RESIZE
  205. */
  206. [Event(name="resize", type="mx.events.ResizeEvent")]
  207. /**
  208. * Dispatched when an object's state changes from invisible to visible.
  209. *
  210. * @eventType mx.events.FlexEvent.SHOW
  211. */
  212. [Event(name="show", type="mx.events.FlexEvent")]
  213. //--------------------------------------
  214. // Mouse events
  215. //--------------------------------------
  216. /**
  217. * Dispatched from a component opened using the PopUpManager
  218. * when the user clicks outside it.
  219. *
  220. * @eventType mx.events.FlexMouseEvent.MOUSE_DOWN_OUTSIDE
  221. */
  222. [Event(name="mouseDownOutside", type="mx.events.FlexMouseEvent")]
  223. /**
  224. * Dispatched from a component opened using the PopUpManager
  225. * when the user scrolls the mouse wheel outside it.
  226. *
  227. * @eventType mx.events.FlexMouseEvent.MOUSE_WHEEL_OUTSIDE
  228. */
  229. [Event(name="mouseWheelOutside", type="mx.events.FlexMouseEvent")]
  230. //--------------------------------------
  231. // Validation events
  232. //--------------------------------------
  233. /**
  234. * Dispatched when values are changed programmatically
  235. * or by user interaction.
  236. *
  237. * <p>Because a programmatic change triggers this event, make sure
  238. * that any <code>valueCommit</code> event handler does not change
  239. * a value that causes another <code>valueCommit</code> event.
  240. * For example, do not change a control's <code>dataProvider</code>
  241. * property in a <code>valueCommit</code> event handler. </p>
  242. *
  243. * @eventType mx.events.FlexEvent.VALUE_COMMIT
  244. */
  245. [Event(name="valueCommit", type="mx.events.FlexEvent")]
  246. /**
  247. * Dispatched when a component is monitored by a Validator
  248. * and the validation failed.
  249. *
  250. * @eventType mx.events.FlexEvent.INVALID
  251. */
  252. [Event(name="invalid", type="mx.events.FlexEvent")]
  253. /**
  254. * Dispatched when a component is monitored by a Validator
  255. * and the validation succeeded.
  256. *
  257. * @eventType mx.events.FlexEvent.VALID
  258. */
  259. [Event(name="valid", type="mx.events.FlexEvent")]
  260. //--------------------------------------
  261. // Drag-and-drop events
  262. //--------------------------------------
  263. /**
  264. * Dispatched by a component when the user moves the mouse over the component
  265. * during a drag operation.
  266. * In an application running in Flash Player,
  267. * the event is dispatched many times when you move the mouse over any component.
  268. * In an application running in AIR, the event is dispatched only once.
  269. *
  270. * <p>In order to be a valid drop target, you must define a handler
  271. * for this event.
  272. * In the handler, you can change the appearance of the drop target
  273. * to provide visual feedback to the user that the component can accept
  274. * the drag.
  275. * For example, you could draw a border around the drop target,
  276. * or give focus to the drop target.</p>
  277. *
  278. * <p>If you want to accept the drag, you must call the
  279. * <code>DragManager.acceptDragDrop()</code> method. If you don't
  280. * call <code>acceptDragDrop()</code>, you will not get any of the
  281. * other drag events.</p>
  282. *
  283. * <p>In Flash Player, the value of the <code>action</code> property is always
  284. * <code>DragManager.MOVE</code>, even if you are doing a copy.
  285. * This is because the <code>dragEnter</code> event occurs before
  286. * the control recognizes that the Control key is pressed to signal a copy.
  287. * The <code>action</code> property of the event object for the
  288. * <code>dragOver</code> event does contain a value that signifies the type of
  289. * drag operation. You may change the type of drag action by calling the
  290. * <code>DragManager.showFeedback()</code> method.</p>
  291. *
  292. * <p>In AIR, the default value of the <code>action</code> property is
  293. * <code>DragManager.COPY</code>.</p>
  294. *
  295. * <p>Because of the way data to a Tree control is structured,
  296. * the Tree control handles drag and drop differently from the other list-based controls.
  297. * For the Tree control, the event handler for the <code>dragDrop</code> event
  298. * only performs an action when you move or copy data in the same Tree control,
  299. * or copy data to another Tree control.
  300. * If you drag data from one Tree control and drop it onto another Tree control
  301. * to move the data, the event handler for the <code>dragComplete</code> event
  302. * actually performs the work to add the data to the destination Tree control,
  303. * rather than the event handler for the dragDrop event,
  304. * and also removes the data from the source Tree control.
  305. * This is necessary because to reparent the data being moved,
  306. * Flex must remove it first from the source Tree control.</p>
  307. *
  308. * @see mx.managers.DragManager
  309. *
  310. * @eventType mx.events.DragEvent.DRAG_ENTER
  311. */
  312. [Event(name="dragEnter", type="mx.events.DragEvent")]
  313. /**
  314. * Dispatched by a component when the user moves the mouse while over the component
  315. * during a drag operation.
  316. * In Flash Player, the event is dispatched
  317. * when you drag an item over a valid drop target.
  318. * In AIR, the event is dispatched when you drag an item over
  319. * any component, even if the component is not a valid drop target.
  320. *
  321. * <p>In the handler, you can change the appearance of the drop target
  322. * to provide visual feedback to the user that the component can accept
  323. * the drag.
  324. * For example, you could draw a border around the drop target,
  325. * or give focus to the drop target.</p>
  326. *
  327. * <p>You should handle this event to perform additional logic
  328. * before allowing the drop, such as dropping data to various locations
  329. * in the drop target, reading keyboard input to determine if the
  330. * drag-and-drop action is a move or copy of the drag data, or providing
  331. * different types of visual feedback based on the type of drag-and-drop
  332. * action.</p>
  333. *
  334. * <p>You may also change the type of drag action by changing the
  335. * <code>DragManager.showFeedback()</code> method.
  336. * The default value of the <code>action</code> property is
  337. * <code>DragManager.MOVE</code>.</p>
  338. *
  339. * @see mx.managers.DragManager
  340. *
  341. * @eventType mx.events.DragEvent.DRAG_OVER
  342. */
  343. [Event(name="dragOver", type="mx.events.DragEvent")]
  344. /**
  345. * Dispatched by the component when the user drags outside the component,
  346. * but does not drop the data onto the target.
  347. *
  348. * <p>You use this event to restore the drop target to its normal appearance
  349. * if you modified its appearance as part of handling the
  350. * <code>dragEnter</code> or <code>dragOver</code> event.</p>
  351. *
  352. * @eventType mx.events.DragEvent.DRAG_EXIT
  353. */
  354. [Event(name="dragExit", type="mx.events.DragEvent")]
  355. /**
  356. * Dispatched by the drop target when the user releases the mouse over it.
  357. *
  358. * <p>You use this event handler to add the drag data to the drop target.</p>
  359. *
  360. * <p>If you call <code>Event.preventDefault()</code> in the event handler
  361. * for the <code>dragDrop</code> event for
  362. * a Tree control when dragging data from one Tree control to another,
  363. * it prevents the drop.</p>
  364. *
  365. * @eventType mx.events.DragEvent.DRAG_DROP
  366. */
  367. [Event(name="dragDrop", type="mx.events.DragEvent")]
  368. /**
  369. * Dispatched by the drag initiator (the component that is the source
  370. * of the data being dragged) when the drag operation completes,
  371. * either when you drop the dragged data onto a drop target or when you end
  372. * the drag-and-drop operation without performing a drop.
  373. *
  374. * <p>You can use this event to perform any final cleanup
  375. * of the drag-and-drop operation.
  376. * For example, if you drag a List control item from one list to another,
  377. * you can delete the List control item from the source if you no longer
  378. * need it.</p>
  379. *
  380. * <p>If you call <code>Event.preventDefault()</code> in the event handler
  381. * for the <code>dragComplete</code> event for
  382. * a Tree control when dragging data from one Tree control to another,
  383. * it prevents the drop.</p>
  384. *
  385. * @eventType mx.events.DragEvent.DRAG_COMPLETE
  386. */
  387. [Event(name="dragComplete", type="mx.events.DragEvent")]
  388. /**
  389. * Dispatched by the drag initiator when starting a drag operation.
  390. * This event is used internally by the list-based controls;
  391. * you do not handle it when implementing drag and drop.
  392. * If you want to control the start of a drag-and-drop operation,
  393. * use the <code>mouseDown</code> or <code>mouseMove</code> event.
  394. *
  395. * @eventType mx.events.DragEvent.DRAG_START
  396. */
  397. [Event(name="dragStart", type="mx.events.DragEvent")]
  398. //--------------------------------------
  399. // Effect events
  400. //--------------------------------------
  401. /**
  402. * Dispatched just before an effect starts.
  403. *
  404. * <p>The effect does not start changing any visuals
  405. * until after this event is fired.</p>
  406. *
  407. * @eventType mx.events.EffectEvent.EFFECT_START
  408. */
  409. [Event(name="effectStart", type="mx.events.EffectEvent")]
  410. /**
  411. * Dispatched after an effect ends.
  412. *
  413. * <p>The effect will have made the last set of visual changes
  414. * before this event is fired, but those changes will not have
  415. * been rendered on the screen.
  416. * Thus, you might have to use the <code>callLater()</code> method
  417. * to delay any other changes that you want to make until after the
  418. * changes have been rendered onscreen.</p>
  419. *
  420. * @eventType mx.events.EffectEvent.EFFECT_END
  421. */
  422. [Event(name="effectEnd", type="mx.events.EffectEvent")]
  423. //--------------------------------------
  424. // State events
  425. //--------------------------------------
  426. /**
  427. * Dispatched after the <code>currentState</code> property changes,
  428. * but before the view state changes.
  429. *
  430. * @eventType mx.events.StateChangeEvent.CURRENT_STATE_CHANGING
  431. */
  432. [Event(name="currentStateChanging", type="mx.events.StateChangeEvent")]
  433. /**
  434. * Dispatched after the view state has changed.
  435. *
  436. * @eventType mx.events.StateChangeEvent.CURRENT_STATE_CHANGE
  437. */
  438. [Event(name="currentStateChange", type="mx.events.StateChangeEvent")]
  439. /**
  440. * Dispatched after the component has returned to the root view state.
  441. *
  442. * @eventType mx.events.FlexEvent.ENTER_STATE
  443. */
  444. [Event(name="enterState", type="mx.events.FlexEvent")]
  445. /**
  446. * Dispatched before the component exits from the root view state.
  447. *
  448. * @eventType mx.events.FlexEvent.EXIT_STATE
  449. */
  450. [Event(name="exitState", type="mx.events.FlexEvent")]
  451. //--------------------------------------
  452. // Tooltip events
  453. //--------------------------------------
  454. /**
  455. * Dispatched by the component when it is time to create a ToolTip.
  456. *
  457. * <p>If you create your own IToolTip object and place a reference
  458. * to it in the <code>toolTip</code> property of the event object
  459. * that is passed to your <code>toolTipCreate</code> handler,
  460. * the ToolTipManager displays your custom ToolTip.
  461. * Otherwise, the ToolTipManager creates an instance of
  462. * <code>ToolTipManager.toolTipClass</code> to display.</p>
  463. *
  464. * <p>The sequence of ToolTip events is <code>toolTipStart</code>,
  465. * <code>toolTipCreate</code>, <code>toolTipShow</code>,
  466. * <code>toolTipShown</code>, <code>toolTipHide</code>,
  467. * and <code>toolTipEnd</code>.</p>
  468. *
  469. * @eventType mx.events.ToolTipEvent.TOOL_TIP_CREATE
  470. */
  471. [Event(name="toolTipCreate", type="mx.events.ToolTipEvent")]
  472. /**
  473. * Dispatched by the component when its ToolTip has been hidden
  474. * and will be discarded soon.
  475. *
  476. * <p>If you specify an effect using the
  477. * <code>ToolTipManager.hideEffect</code> property,
  478. * this event is dispatched after the effect stops playing.</p>
  479. *
  480. * <p>The sequence of ToolTip events is <code>toolTipStart</code>,
  481. * <code>toolTipCreate</code>, <code>toolTipShow</code>,
  482. * <code>toolTipShown</code>, <code>toolTipHide</code>,
  483. * and <code>toolTipEnd</code>.</p>
  484. *
  485. * @eventType mx.events.ToolTipEvent.TOOL_TIP_END
  486. */
  487. [Event(name="toolTipEnd", type="mx.events.ToolTipEvent")]
  488. /**
  489. * Dispatched by the component when its ToolTip is about to be hidden.
  490. *
  491. * <p>If you specify an effect using the
  492. * <code>ToolTipManager.hideEffect</code> property,
  493. * this event is dispatched before the effect starts playing.</p>
  494. *
  495. * <p>The sequence of ToolTip events is <code>toolTipStart</code>,
  496. * <code>toolTipCreate</code>, <code>toolTipShow</code>,
  497. * <code>toolTipShown</code>, <code>toolTipHide</code>,
  498. * and <code>toolTipEnd</code>.</p>
  499. *
  500. * @eventType mx.events.ToolTipEvent.TOOL_TIP_HIDE
  501. */
  502. [Event(name="toolTipHide", type="mx.events.ToolTipEvent")]
  503. /**
  504. * Dispatched by the component when its ToolTip is about to be shown.
  505. *
  506. * <p>If you specify an effect using the
  507. * <code>ToolTipManager.showEffect</code> property,
  508. * this event is dispatched before the effect starts playing.
  509. * You can use this event to modify the ToolTip before it appears.</p>
  510. *
  511. * <p>The sequence of ToolTip events is <code>toolTipStart</code>,
  512. * <code>toolTipCreate</code>, <code>toolTipShow</code>,
  513. * <code>toolTipShown</code>, <code>toolTipHide</code>,
  514. * and <code>toolTipEnd</code>.</p>
  515. *
  516. * @eventType mx.events.ToolTipEvent.TOOL_TIP_SHOW
  517. */
  518. [Event(name="toolTipShow", type="mx.events.ToolTipEvent")]
  519. /**
  520. * Dispatched by the component when its ToolTip has been shown.
  521. *
  522. * <p>If you specify an effect using the
  523. * <code>ToolTipManager.showEffect</code> property,
  524. * this event is dispatched after the effect stops playing.</p>
  525. *
  526. * <p>The sequence of ToolTip events is <code>toolTipStart</code>,
  527. * <code>toolTipCreate</code>, <code>toolTipShow</code>,
  528. * <code>toolTipShown</code>, <code>toolTipHide</code>,
  529. * and <code>toolTipEnd</code>.</p>
  530. *
  531. * @eventType mx.events.ToolTipEvent.TOOL_TIP_SHOWN
  532. */
  533. [Event(name="toolTipShown", type="mx.events.ToolTipEvent")]
  534. /**
  535. * Dispatched by a component whose <code>toolTip</code> property is set,
  536. * as soon as the user moves the mouse over it.
  537. *
  538. * <p>The sequence of ToolTip events is <code>toolTipStart</code>,
  539. * <code>toolTipCreate</code>, <code>toolTipShow</code>,
  540. * <code>toolTipShown</code>, <code>toolTipHide</code>,
  541. * and <code>toolTipEnd</code>.</p>
  542. *
  543. * @eventType mx.events.ToolTipEvent.TOOL_TIP_START
  544. */
  545. [Event(name="toolTipStart", type="mx.events.ToolTipEvent")]
  546. //--------------------------------------
  547. // Styles
  548. //--------------------------------------
  549. include "../styles/metadata/AnchorStyles.as";
  550. /**
  551. * Color of the component highlight when validation fails.
  552. * Flex also sets the <code>borderColor</code> style of the component to this
  553. * <code>errorColor</code> on a validation failure.
  554. *
  555. * @default 0xFF0000
  556. */
  557. [Style(name="errorColor", type="uint", format="Color", inherit="yes")]
  558. /**
  559. * Blend mode used by the focus rectangle.
  560. * For more information, see the <code>blendMode</code> property
  561. * of the flash.display.DisplayObject class.
  562. *
  563. * @default "normal"
  564. */
  565. [Style(name="focusBlendMode", type="String", inherit="no")]
  566. /**
  567. * Skin used to draw the focus rectangle.
  568. *
  569. * @default mx.skins.halo.HaloFocusRect
  570. */
  571. [Style(name="focusSkin", type="Class", inherit="no")]
  572. /**
  573. * Thickness, in pixels, of the focus rectangle outline.
  574. *
  575. * @default 2
  576. */
  577. [Style(name="focusThickness", type="Number", format="Length", inherit="no")]
  578. /**
  579. * Theme color of a component. This property controls the appearance of highlights,
  580. * appearance when a component is selected, and other similar visual cues, but it
  581. * does not have any effect on the regular borders or background colors of the component.
  582. * The preferred values are <code>haloGreen</code>, <code>haloBlue</code>,
  583. * <code>haloOrange</code>, and <code>haloSilver</code>, although any valid color
  584. * value can be used.
  585. *
  586. * <p>The default values of the <code>rollOverColor</code> and
  587. * <code>selectionColor</code> styles are based on the
  588. * <code>themeColor</code> value.</p>
  589. *
  590. * @default "haloBlue"
  591. */
  592. [Style(name="themeColor", type="uint", format="Color", inherit="yes")]
  593. //--------------------------------------
  594. // Effects
  595. //--------------------------------------
  596. /**
  597. * Played when the component is created.
  598. */
  599. [Effect(name="creationCompleteEffect", event="creationComplete")]
  600. /**
  601. * Played when the component is moved.
  602. */
  603. [Effect(name="moveEffect", event="move")]
  604. /**
  605. * Played when the component is resized.
  606. */
  607. [Effect(name="resizeEffect", event="resize")]
  608. /**
  609. * Played when the component becomes visible.
  610. */
  611. [Effect(name="showEffect", event="show")]
  612. /**
  613. * Played when the component becomes invisible.
  614. */
  615. [Effect(name="hideEffect", event="hide")]
  616. /**
  617. * Played when the user presses the mouse button while over the component.
  618. */
  619. [Effect(name="mouseDownEffect", event="mouseDown")]
  620. /**
  621. * Played when the user releases the mouse button while over the component.
  622. */
  623. [Effect(name="mouseUpEffect", event="mouseUp")]
  624. /**
  625. * Played when the user rolls the mouse over the component.
  626. */
  627. [Effect(name="rollOverEffect", event="rollOver")]
  628. /**
  629. * Played when the user rolls the mouse so it is no longer over the component.
  630. */
  631. [Effect(name="rollOutEffect", event="rollOut")]
  632. /**
  633. * Played when the component gains keyboard focus.
  634. */
  635. [Effect(name="focusInEffect", event="focusIn")]
  636. /**
  637. * Played when the component loses keyboard focus.
  638. */
  639. [Effect(name="focusOutEffect", event="focusOut")]
  640. /**
  641. * Played when the component is added as a child to a Container.
  642. */
  643. [Effect(name="addedEffect", event="added")]
  644. /**
  645. * Played when the component is removed from a Container.
  646. */
  647. [Effect(name="removedEffect", event="removed")]
  648. //--------------------------------------
  649. // Other metadata
  650. //--------------------------------------
  651. [AccessibilityClass(implementation="mx.accessibility.UIComponentAccImpl")]
  652. [ResourceBundle("core")]
  653. // skins resources aren't found because CSS visited by the compiler
  654. [ResourceBundle("skins")]
  655. /**
  656. * The UIComponent class is the base class for all visual components,
  657. * both interactive and noninteractive.
  658. *
  659. * <p>An interactive component can participate in tabbing and other kinds of
  660. * keyboard focus manipulation, accept low-level events like keyboard and
  661. * mouse input, and be disabled so that it does not receive keyboard and
  662. * mouse input.
  663. * This is in contrast to noninteractive components, like Label and
  664. * ProgressBar, which simply display contents and are not manipulated by
  665. * the user.</p>
  666. * <p>The UIComponent class is not used as an MXML tag, but is used as a base
  667. * class for other classes.</p>
  668. *
  669. * @mxml
  670. *
  671. * <p>All user interface components in Flex extend the UIComponent class.
  672. * Flex components inherit the following properties from the UIComponent
  673. * class:</p>
  674. *
  675. * <pre>
  676. * &lt;mx:<i>tagname</i>
  677. * <b>Properties </b>
  678. * automationName="null"
  679. * cachePolicy="auto|on|off"
  680. * currentState="null"
  681. * doubleClickEnabled="false|true"
  682. * enabled="true|false"
  683. * explicitHeight="NaN"
  684. * explicitMaxHeight="NaN"
  685. * explicitMaxWidth="NaN"
  686. * explicitMinHeight="NaN"
  687. * explicitMinWidth="NaN"
  688. * explicitWidth="NaN"
  689. * focusEnabled="true|false"
  690. * height="0"
  691. * id=""
  692. * includeInLayout="true|false"
  693. * maxHeight="10000"
  694. * maxWidth="10000"
  695. * measuredHeight=
  696. * measuredMinHeight=
  697. * measuredMinWidth=
  698. * measuredWidth=
  699. * minHeight="0"
  700. * minWidth="0"
  701. * mouseFocusEnabled="true|false"
  702. * percentHeight="NaN"
  703. * percentWidth="NaN"
  704. * scaleX="1.0"
  705. * scaleY="1.0"
  706. * states="null"
  707. * styleName="undefined"
  708. * toolTip="null"
  709. * transitions=""
  710. * validationSubField
  711. * width="0"
  712. * x="0"
  713. * y="0"
  714. *
  715. * <b>Styles</b>
  716. * bottom="undefined"
  717. * errorColor="0xFF0000"
  718. * focusBlendMode="normal"
  719. * focusSkin="HaloFocusRect""
  720. * focusThickness="2"
  721. * horizontalCenter="undefined"
  722. * left="undefined"
  723. * right="undefined"
  724. * themeColor="haloGreen"
  725. * top="undefined"
  726. * verticalCenter="undefined"
  727. *
  728. * <b>Effects</b>
  729. * addedEffect="<i>No default</i>"
  730. * creationCompleteEffect="<i>No default</i>"
  731. * focusInEffect="<i>No default</i>"
  732. * focusOutEffect="<i>No default</i>"
  733. * hideEffect="<i>No default</i>"
  734. * mouseDownEffect="<i>No default</i>"
  735. * mouseUpEffect="<i>No default</i>"
  736. * moveEffect="<i>No default</i>"
  737. * removedEffect="<i>No default</i>"
  738. * resizeEffect="<i>No default</i>"
  739. * rollOutEffect="<i>No default</i>"
  740. * rollOverEffect="<i>No default</i>"
  741. * showEffect="<i>No default</i>"
  742. *
  743. * <b>Events</b>
  744. * add="<i>No default</i>"
  745. * creationComplete="<i>No default</i>"
  746. * currentStateChange="<i>No default</i>"
  747. * currentStateChanging="<i>No default</i>"
  748. * dragComplete="<i>No default</i>"
  749. * dragDrop="<i>No default</i>"
  750. * dragEnter="<i>No default</i>"
  751. * dragExit="<i>No default</i>"
  752. * dragOver="<i>No default</i>"
  753. * effectEnd="<i>No default</i>"
  754. * effectStart="<i>No default</i>"
  755. * enterState="<i>No default</i>"
  756. * exitState="<i>No default</i>"
  757. * hide="<i>No default</i>"
  758. * initialize="<i>No default</i>"
  759. * invalid="<i>No default</i>"
  760. * mouseDownOutside="<i>No default</i>"
  761. * mouseWheelOutside="<i>No default</i>"
  762. * move="<i>No default</i>"
  763. * preinitialize="<i>No default</i>"
  764. * record="<i>No default</i>"
  765. * remove="<i>No default</i>"
  766. * resize="<i>No default</i>"
  767. * show="<i>No default</i>"
  768. * toolTipCreate="<i>No default</i>"
  769. * toolTipEnd="<i>No default</i>"
  770. * toolTipHide="<i>No default</i>"
  771. * toolTipShow="<i>No default</i>"
  772. * toolTipShown="<i>No default</i>"
  773. * toolTipStart="<i>No default</i>"
  774. * updateComplete="<i>No default</i>"
  775. * valid="<i>No default</i>"
  776. * valueCommit="<i>No default</i>"
  777. * &gt;
  778. * </pre>
  779. *
  780. * @see mx.core.UIComponent
  781. */
  782. public class UIComponent extends FlexSprite
  783. implements IAutomationObject, IChildList,
  784. IDeferredInstantiationUIComponent, IFlexDisplayObject,
  785. IFlexModule,
  786. IInvalidating, ILayoutManagerClient,
  787. IPropertyChangeNotifier, IRepeaterClient,
  788. ISimpleStyleClient, IStyleClient,
  789. IToolTipManagerClient, IUIComponent,
  790. IValidatorListener, IStateClient,
  791. IConstraintClient
  792. {
  793. include "../core/Version.as";
  794. //--------------------------------------------------------------------------
  795. //
  796. // Class constants
  797. //
  798. //--------------------------------------------------------------------------
  799. /**
  800. * The default value for the <code>measuredWidth</code> property.
  801. * Most components calculate a measuredWidth but some are flow-based and
  802. * have to pick a number that looks reasonable.
  803. *
  804. * @default 160
  805. */
  806. public static const DEFAULT_MEASURED_WIDTH:Number = 160;
  807. /**
  808. * The default value for the <code>measuredMinWidth</code> property.
  809. * Most components calculate a measuredMinWidth but some are flow-based and
  810. * have to pick a number that looks reasonable.
  811. *
  812. * @default 40
  813. */
  814. public static const DEFAULT_MEASURED_MIN_WIDTH:Number = 40;
  815. /**
  816. * The default value for the <code>measuredHeight</code> property.
  817. * Most components calculate a measuredHeight but some are flow-based and
  818. * have to pick a number that looks reasonable.
  819. *
  820. * @default 22
  821. */
  822. public static const DEFAULT_MEASURED_HEIGHT:Number = 22;
  823. /**
  824. * The default value for the <code>measuredMinHeight</code> property.
  825. * Most components calculate a measuredMinHeight but some are flow-based and
  826. * have to pick a number that looks reasonable.
  827. *
  828. * @default 22
  829. */
  830. public static const DEFAULT_MEASURED_MIN_HEIGHT:Number = 22;
  831. /**
  832. * The default value for the <code>maxWidth</code> property.
  833. *
  834. * @default 10000
  835. */
  836. public static const DEFAULT_MAX_WIDTH:Number = 10000;
  837. /**
  838. * The default value for the <code>maxHeight</code> property.
  839. *
  840. * @default 10000
  841. */
  842. public static const DEFAULT_MAX_HEIGHT:Number = 10000;
  843. /**
  844. * @private
  845. * The inheritingStyles and nonInheritingStyles properties
  846. * are initialized to this empty Object.
  847. * This allows the getStyle() and getStyle()
  848. * methods to simply access inheritingStyles[] and nonInheritingStyles[]
  849. * without needing to first check whether those objects exist.
  850. * If they were simply initialized to {}, we couldn't determine
  851. * whether the style chain has already been built or not.
  852. */
  853. mx_internal static var STYLE_UNINITIALIZED:Object = {};
  854. //--------------------------------------------------------------------------
  855. //
  856. // Class mixins
  857. //
  858. //--------------------------------------------------------------------------
  859. /**
  860. * @private
  861. * Placeholder for mixin by UIComponentAccImpl.
  862. */
  863. mx_internal static var createAccessibilityImplementation:Function;
  864. //--------------------------------------------------------------------------
  865. //
  866. // Class properties
  867. //
  868. //--------------------------------------------------------------------------
  869. //----------------------------------
  870. // embeddedFontRegistry
  871. //----------------------------------
  872. /**
  873. * @private
  874. * Storage for the _embeddedFontRegistry property.
  875. * Note: This gets initialized on first access,
  876. * not when this class is initialized, in order to ensure
  877. * that the Singleton registry has already been initialized.
  878. */
  879. private static var _embeddedFontRegistry:IEmbeddedFontRegistry;
  880. /**
  881. * @private
  882. * A reference to the embedded font registry.
  883. * Single registry in the system.
  884. * Used to look up the moduleFactory of a font.
  885. */
  886. private static function get embeddedFontRegistry():IEmbeddedFontRegistry
  887. {
  888. if (!_embeddedFontRegistry)
  889. {
  890. _embeddedFontRegistry = IEmbeddedFontRegistry(
  891. Singleton.getInstance("mx.core::IEmbeddedFontRegistry"));
  892. }
  893. return _embeddedFontRegistry;
  894. }
  895. //--------------------------------------------------------------------------
  896. //
  897. // Class methods
  898. //
  899. //--------------------------------------------------------------------------
  900. /**
  901. * Blocks the background processing of methods
  902. * queued by <code>callLater()</code>,
  903. * until <code>resumeBackgroundProcessing()</code> is called.
  904. *
  905. * <p>These methods can be useful when you have time-critical code
  906. * which needs to execute without interruption.
  907. * For example, when you set the <code>suspendBackgroundProcessing</code>
  908. * property of an Effect to <code>true</code>,
  909. * <code>suspendBackgroundProcessing()</code> is automatically called
  910. * when it starts playing, and <code>resumeBackgroundProcessing</code>
  911. * is called when it stops, in order to ensure that the animation
  912. * is smooth.</p>
  913. *
  914. * <p>Since the LayoutManager uses <code>callLater()</code>,
  915. * this means that <code>commitProperties()</code>,
  916. * <code>measure()</code>, and <code>updateDisplayList()</code>
  917. * will not get called in between calls to
  918. * <code>suspendBackgroundProcessing()</code> and
  919. * <code>resumeBackgroundProcessing()</code>.</p>
  920. *
  921. * <p>It is safe for both an outer method and an inner method
  922. * (i.e., one that the outer methods calls) to call
  923. * <code>suspendBackgroundProcessing()</code>
  924. * and <code>resumeBackgroundProcessing()</code>, because these
  925. * methods actually increment and decrement a counter
  926. * which determines whether background processing occurs.</p>
  927. */
  928. public static function suspendBackgroundProcessing():void
  929. {
  930. UIComponentGlobals.callLaterSuspendCount++;
  931. }
  932. /**
  933. * Resumes the background processing of methods
  934. * queued by <code>callLater()</code>, after a call to
  935. * <code>suspendBackgroundProcessing()</code>.
  936. *
  937. * <p>Refer to the description of
  938. * <code>suspendBackgroundProcessing()</code> for more information.</p>
  939. */
  940. public static function resumeBackgroundProcessing():void
  941. {
  942. if (UIComponentGlobals.callLaterSuspendCount > 0)
  943. {
  944. UIComponentGlobals.callLaterSuspendCount--;
  945. // Once the suspend count gets back to 0, we need to
  946. // force a render event to happen
  947. if (UIComponentGlobals.callLaterSuspendCount == 0)
  948. {
  949. var sm:ISystemManager = SystemManagerGlobals.topLevelSystemManagers[0];
  950. if (sm && sm.stage)
  951. sm.stage.invalidate();
  952. }
  953. }
  954. }
  955. //--------------------------------------------------------------------------
  956. //
  957. // Constructor
  958. //
  959. //--------------------------------------------------------------------------
  960. /**
  961. * Constructor.
  962. */
  963. public function UIComponent()
  964. {
  965. super();
  966. // Override variables in superclasses.
  967. focusRect = false; // We do our own focus drawing.
  968. tabEnabled = (this is IFocusManagerComponent);
  969. // We are tab enabled by default if IFocusManagerComponent
  970. tabChildren = false;
  971. // Whether the component can accept user interaction.
  972. // The default is true. If you set enabled to false for a container,
  973. // Flex dims the color of the container and of all of its children,
  974. // and blocks user input to the container and to all of its children.
  975. // We set enabled to true here because some components keep their
  976. // own _enabled flag and may not initialize it to true.
  977. enabled = true;
  978. // Make the component invisible until the initialization sequence
  979. // is complete.
  980. // It will be set visible when the 'initialized' flag is set.
  981. $visible = false;
  982. addEventListener(Event.ADDED, addedHandler);
  983. addEventListener(Event.REMOVED, removedHandler);
  984. // Register for focus and keyboard events.
  985. if (this is IFocusManagerComponent)
  986. {
  987. addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
  988. addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
  989. addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
  990. addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
  991. }
  992. resourcesChanged();
  993. // Register as a weak listener for "change" events from ResourceManager.
  994. // If UIComponents registered as a strong listener,
  995. // they wouldn't get garbage collected.
  996. resourceManager.addEventListener(
  997. Event.CHANGE, resourceManager_changeHandler, false, 0, true);
  998. _width = super.width;
  999. _height = super.height;
  1000. }
  1001. //--------------------------------------------------------------------------
  1002. //
  1003. // Variables
  1004. //
  1005. //--------------------------------------------------------------------------
  1006. /**
  1007. * @private
  1008. * There is a bug (139381) where we occasionally get callLaterDispatcher()
  1009. * even though we didn't expect it.
  1010. * That causes us to do a removeEventListener() twice,
  1011. * which messes up some internal thing in the player so that
  1012. * the next addEventListener() doesn't actually get us the render event.
  1013. */
  1014. private var listeningForRender:Boolean = false;
  1015. /**
  1016. * @private
  1017. * List of methods used by callLater().
  1018. */
  1019. private var methodQueue:Array /* of MethodQueueElement */ = [];
  1020. /**
  1021. * @private
  1022. * Whether or not we "own" the focus graphic
  1023. */
  1024. private var hasFocusRect:Boolean = false;
  1025. //--------------------------------------------------------------------------
  1026. //
  1027. // Variables: Creation
  1028. //
  1029. //--------------------------------------------------------------------------
  1030. //----------------------------------
  1031. // initialized
  1032. //----------------------------------
  1033. /**
  1034. * @private
  1035. * Storage for the initialized property.
  1036. */
  1037. private var _initialized:Boolean = false;
  1038. [Inspectable(environment="none")]
  1039. /**
  1040. * A flag that determines if an object has been through all three phases
  1041. * of layout: commitment, measurement, and layout (provided that any were required).
  1042. */
  1043. public function get initialized():Boolean
  1044. {
  1045. return _initialized;
  1046. }
  1047. /**
  1048. * @private
  1049. */
  1050. public function set initialized(value:Boolean):void
  1051. {
  1052. _initialized = value;
  1053. if (value)
  1054. {
  1055. setVisible(_visible, true);
  1056. dispatchEvent(new FlexEvent(FlexEvent.CREATION_COMPLETE));
  1057. }
  1058. }
  1059. //----------------------------------
  1060. // processedDescriptors
  1061. //----------------------------------
  1062. /**
  1063. * @private
  1064. * Storage for the processedDescriptors property.
  1065. */
  1066. private var _processedDescriptors:Boolean = false;
  1067. [Inspectable(environment="none")]
  1068. /**
  1069. * Set to <code>true</code> after immediate or deferred child creation,
  1070. * depending on which one happens. For a Container object, it is set
  1071. * to <code>true</code> at the end of
  1072. * the <code>createComponentsFromDescriptors()</code> method,
  1073. * meaning after the Container object creates its children from its child descriptors.
  1074. *
  1075. * <p>For example, if an Accordion container uses deferred instantiation,
  1076. * the <code>processedDescriptors</code> property for the second pane of
  1077. * the Accordion container does not become <code>true</code> until after
  1078. * the user navigates to that pane and the pane creates its children.
  1079. * But, if the Accordion had set the <code>creationPolicy</code> property
  1080. * to <code>"all"</code>, the <code>processedDescriptors</code> property
  1081. * for its second pane is set to <code>true</code> during application startup.</p>
  1082. *
  1083. * <p>For classes that are not containers, which do not have descriptors,
  1084. * it is set to <code>true</code> after the <code>createChildren()</code>
  1085. * method creates any internal component children.</p>
  1086. */
  1087. public function get processedDescriptors():Boolean
  1088. {
  1089. return _processedDescriptors;
  1090. }
  1091. /**
  1092. * @private
  1093. */
  1094. public function set processedDescriptors(value:Boolean):void
  1095. {
  1096. _processedDescriptors = value;
  1097. if (value)
  1098. dispatchEvent(new FlexEvent(FlexEvent.INITIALIZE));
  1099. }
  1100. //----------------------------------
  1101. // updateCompletePendingFlag
  1102. //----------------------------------
  1103. /**
  1104. * @private
  1105. * Storage for the updateCompletePendingFlag property.
  1106. */
  1107. private var _updateCompletePendingFlag:Boolean = false;
  1108. [Inspectable(environment="none")]
  1109. /**
  1110. * A flag that determines if an object has been through all three phases
  1111. * of layout validation (provided that any were required).
  1112. */
  1113. public function get updateCompletePendingFlag():Boolean
  1114. {
  1115. return _updateCompletePendingFlag;
  1116. }
  1117. /**
  1118. * @private
  1119. */
  1120. public function set updateCompletePendingFlag(value:Boolean):void
  1121. {
  1122. _updateCompletePendingFlag = value;
  1123. }
  1124. //--------------------------------------------------------------------------
  1125. //
  1126. // Variables: Invalidation
  1127. //
  1128. //--------------------------------------------------------------------------
  1129. /**
  1130. * @private
  1131. * Whether this component needs to have its
  1132. * commitProperties() method called.
  1133. */
  1134. mx_internal var invalidatePropertiesFlag:Boolean = false;
  1135. /**
  1136. * @private
  1137. * Whether this component needs to have its
  1138. * measure() method called.
  1139. */
  1140. mx_internal var invalidateSizeFlag:Boolean = false;
  1141. /**
  1142. * @private
  1143. * Whether this component needs to be have its
  1144. * updateDisplayList() method called.
  1145. */
  1146. mx_internal var invalidateDisplayListFlag:Boolean = false;
  1147. //--------------------------------------------------------------------------
  1148. //
  1149. // Variables: Measurement
  1150. //
  1151. //--------------------------------------------------------------------------
  1152. /**
  1153. * @private
  1154. * Holds the last recorded value of the x property.
  1155. * Used in dispatching a MoveEvent.
  1156. */
  1157. private var oldX:Number = 0;
  1158. /**
  1159. * @private
  1160. * Holds the last recorded value of the y property.
  1161. * Used in dispatching a MoveEvent.
  1162. */
  1163. private var oldY:Number = 0;
  1164. /**
  1165. * @private
  1166. * Holds the last recorded value of the width property.
  1167. * Used in dispatching a ResizeEvent.
  1168. */
  1169. private var oldWidth:Number = 0;
  1170. /**
  1171. * @private
  1172. * Holds the last recorded value of the height property.
  1173. * Used in dispatching a ResizeEvent.
  1174. */
  1175. private var oldHeight:Number = 0;
  1176. /**
  1177. * @private
  1178. * Holds the last recorded value of the minWidth property.
  1179. */
  1180. private var oldMinWidth:Number;
  1181. /**
  1182. * @private
  1183. * Holds the last recorded value of the minHeight property.
  1184. */
  1185. private var oldMinHeight:Number;
  1186. /**
  1187. * @private
  1188. * Holds the last recorded value of the explicitWidth property.
  1189. */
  1190. private var oldExplicitWidth:Number;
  1191. /**
  1192. * @private
  1193. * Holds the last recorded value of the explicitHeight property.
  1194. */
  1195. private var oldExplicitHeight:Number;
  1196. /**
  1197. * @private
  1198. * Holds the last recorded value of the scaleX property.
  1199. */
  1200. private var oldScaleX:Number = 1.0;
  1201. /**
  1202. * @private
  1203. * Holds the last recorded value of the scaleY property.
  1204. */
  1205. private var oldScaleY:Number = 1.0;
  1206. /**
  1207. * @private
  1208. * True if createInFontContext has been called.
  1209. */
  1210. private var hasFontContextBeenSaved:Boolean = false;
  1211. /**
  1212. * @private
  1213. * Holds the last recorded value of the module factory used to create the font.
  1214. */
  1215. private var oldEmbeddedFontContext:IFlexModuleFactory = null;
  1216. /**
  1217. * @private
  1218. *
  1219. * Cache last value of embedded font.
  1220. */
  1221. private var cachedEmbeddedFont:EmbeddedFont = null;
  1222. //--------------------------------------------------------------------------
  1223. //
  1224. // Variables: Styles
  1225. //
  1226. //--------------------------------------------------------------------------
  1227. /**
  1228. * @private
  1229. */
  1230. private var cachedTextFormat:UITextFormat;
  1231. //--------------------------------------------------------------------------
  1232. //
  1233. // Variables: Effects
  1234. //
  1235. //--------------------------------------------------------------------------
  1236. /**
  1237. * @private
  1238. * Sprite used to display an overlay.
  1239. */
  1240. mx_internal var overlay:UIComponent;
  1241. /**
  1242. * @private
  1243. * Color used for overlay.
  1244. */
  1245. mx_internal var overlayColor:uint;
  1246. /**
  1247. * @private
  1248. * Counter to keep track of the number of current users
  1249. * of the overlay.
  1250. */
  1251. mx_internal var overlayReferenceCount:int = 0;
  1252. //--------------------------------------------------------------------------
  1253. //
  1254. // Variables: Validation
  1255. //
  1256. //--------------------------------------------------------------------------
  1257. /**
  1258. * @private
  1259. */
  1260. mx_internal var saveBorderColor:Boolean = true;
  1261. /**
  1262. * @private
  1263. */
  1264. mx_internal var origBorderColor:Number;
  1265. //--------------------------------------------------------------------------
  1266. //
  1267. // Variables: Other
  1268. //
  1269. //--------------------------------------------------------------------------
  1270. /**
  1271. * @private
  1272. * Storage for automatically-created RadioButtonGroups.
  1273. * If a RadioButton's groupName isn't the id of a RadioButtonGroup tag,
  1274. * we automatically create a RadioButtonGroup and store it here as
  1275. * document.automaticRadioButtonGroups[groupName] = theRadioButtonGroup;
  1276. */
  1277. mx_internal var automaticRadioButtonGroups:Object;
  1278. //--------------------------------------------------------------------------
  1279. //
  1280. // Overridden properties
  1281. //
  1282. //--------------------------------------------------------------------------
  1283. //----------------------------------
  1284. // owner
  1285. //----------------------------------
  1286. /**
  1287. * @private
  1288. */
  1289. private var _owner:DisplayObjectContainer;
  1290. /**
  1291. * The owner of this UIComponent. By default, it is the parent of this UIComponent.
  1292. * However, if this UIComponent object is a child component that is
  1293. * popped up by its parent, such as the dropdown list of a ComboBox control,
  1294. * the owner is the component that popped up this UIComponent object.
  1295. *
  1296. * <p>This property is not managed by Flex, but by each component.
  1297. * Therefore, if you use the <code>PopUpManger.createPopUp()</code> or
  1298. * <code>PopUpManger.addPopUp()</code> method to pop up a child component,
  1299. * you should set the <code>owner</code> property of the child component
  1300. * to the component that popped it up.</p>
  1301. *
  1302. * <p>The default value is the value of the <code>parent</code> property.</p>
  1303. */
  1304. public function get owner():DisplayObjectContainer
  1305. {
  1306. return _owner ? _owner : parent;
  1307. }
  1308. public function set owner(value:DisplayObjectContainer):void
  1309. {
  1310. _owner = value;
  1311. }
  1312. //----------------------------------
  1313. // parent
  1314. //----------------------------------
  1315. /**
  1316. * @private
  1317. * Reference to this component's virtual parent container.
  1318. * "Virtual" means that this parent may not be the same
  1319. * as the one that the Player returns as the 'parent'
  1320. * property of a DisplayObject.
  1321. * For example, if a Container has created a contentPane
  1322. * to improve scrolling performance,
  1323. * then its "children" are really its grandchildren
  1324. * and their "parent" is actually their grandparent,
  1325. * because we don't want developers to be concerned with
  1326. * whether a contentPane exists or not.
  1327. */
  1328. mx_internal var _parent:DisplayObjectContainer;
  1329. /**
  1330. * The parent container or component for this component.
  1331. * Only UIComponent objects should have a parent property.
  1332. * Non-UIComponent objects should use another property to reference
  1333. * the object to which they belong.
  1334. * By convention, non-UIComponent objects use an <code>owner</code>
  1335. * property to reference the object to which they b…

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