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 12package mx.core 13{ 14import flash.accessibility.Accessibility; 15import flash.accessibility.AccessibilityProperties; 16import flash.display.BlendMode; 17import flash.display.DisplayObject; 18import flash.display.DisplayObjectContainer; 19import flash.display.GradientType; 20import flash.display.Graphics; 21import flash.display.InteractiveObject; 22import flash.display.Loader; 23import flash.display.Shader; 24import flash.display.Sprite; 25import flash.display.Stage; 26import flash.events.Event; 27import flash.events.EventPhase; 28import flash.events.FocusEvent; 29import flash.events.IEventDispatcher; 30import flash.events.KeyboardEvent; 31import flash.geom.ColorTransform; 32import flash.geom.Matrix; 33import flash.geom.Matrix3D; 34import flash.geom.PerspectiveProjection; 35import flash.geom.Point; 36import flash.geom.Rectangle; 37import flash.geom.Transform; 38import flash.geom.Vector3D; 39import flash.system.ApplicationDomain; 40import flash.system.Capabilities; 41import flash.text.TextFormatAlign; 42import flash.text.TextLineMetrics; 43import flash.ui.Keyboard; 44import flash.utils.Dictionary; 45import flash.utils.getQualifiedClassName; 46 47import mx.automation.IAutomationObject; 48import mx.binding.BindingManager; 49import mx.controls.IFlexContextMenu; 50import mx.core.LayoutDirection; 51import mx.effects.EffectManager; 52import mx.effects.IEffect; 53import mx.effects.IEffectInstance; 54import mx.events.ChildExistenceChangedEvent; 55import mx.events.DynamicEvent; 56import mx.events.EffectEvent; 57import mx.events.FlexEvent; 58import mx.events.MoveEvent; 59import mx.events.PropertyChangeEvent; 60import mx.events.ResizeEvent; 61import mx.events.StateChangeEvent; 62import mx.events.ValidationResultEvent; 63import mx.filters.BaseFilter; 64import mx.filters.IBitmapFilter; 65import mx.geom.RoundedRectangle; 66import mx.geom.Transform; 67import mx.geom.TransformOffsets; 68import mx.graphics.shaderClasses.ColorBurnShader; 69import mx.graphics.shaderClasses.ColorDodgeShader; 70import mx.graphics.shaderClasses.ColorShader; 71import mx.graphics.shaderClasses.ExclusionShader; 72import mx.graphics.shaderClasses.HueShader; 73import mx.graphics.shaderClasses.LuminosityShader; 74import mx.graphics.shaderClasses.SaturationShader; 75import mx.graphics.shaderClasses.SoftLightShader; 76import mx.managers.CursorManager; 77import mx.managers.ICursorManager; 78import mx.managers.IFocusManager; 79import mx.managers.IFocusManagerComponent; 80import mx.managers.IFocusManagerContainer; 81import mx.managers.ILayoutManagerClient; 82import mx.managers.ISystemManager; 83import mx.managers.IToolTipManagerClient; 84import mx.managers.SystemManager; 85import mx.managers.SystemManagerGlobals; 86import mx.managers.ToolTipManager; 87import mx.resources.IResourceManager; 88import mx.resources.ResourceManager; 89import mx.states.State; 90import mx.states.Transition; 91import mx.styles.CSSStyleDeclaration; 92import mx.styles.IAdvancedStyleClient; 93import mx.styles.ISimpleStyleClient; 94import mx.styles.IStyleClient; 95import mx.styles.IStyleManager2; 96import mx.styles.StyleManager; 97import mx.styles.StyleProtoChain; 98import mx.utils.ColorUtil; 99import mx.utils.GraphicsUtil; 100import mx.utils.MatrixUtil; 101import mx.utils.NameUtil; 102import mx.utils.StringUtil; 103import mx.utils.TransformUtil; 104import mx.validators.IValidatorListener; 105import mx.validators.ValidationResult; 106 107use namespace mx_internal; 108 109// Excluding the property to enable code hinting for the layoutDirection style 110[Exclude(name="layoutDirection", kind="property")] 111 112//-------------------------------------- 113// Lifecycle events 114//-------------------------------------- 115 116/** 117 * Dispatched when the component is added to a container as a content child 118 * by using the <code>addChild()</code>, <code>addChildAt()</code>, 119 * <code>addElement()</code>, or <code>addElementAt()</code> method. 120 * If the component is added to the container as a noncontent child by 121 * using the <code>rawChildren.addChild()</code> or 122 * <code>rawChildren.addChildAt()</code> method, the event is not dispatched. 123 * 124 * <p>This event is only dispatched when there are one or more relevant listeners 125 * attached to the dispatching object.</p> 126 * 127 * @eventType mx.events.FlexEvent.ADD 128 * 129 * @langversion 3.0 130 * @playerversion Flash 9 131 * @playerversion AIR 1.1 132 * @productversion Flex 3 133 */ 134[Event(name="add", type="mx.events.FlexEvent")] 135 136/** 137 * Dispatched when the component has finished its construction, 138 * property processing, measuring, layout, and drawing. 139 * 140 * <p>At this point, depending on its <code>visible</code> property, 141 * the component is not visible even though it has been drawn.</p> 142 * 143 * @eventType mx.events.FlexEvent.CREATION_COMPLETE 144 * 145 * @langversion 3.0 146 * @playerversion Flash 9 147 * @playerversion AIR 1.1 148 * @productversion Flex 3 149 */ 150[Event(name="creationComplete", type="mx.events.FlexEvent")] 151 152/** 153 * Dispatched when an object has had its <code>commitProperties()</code>, 154 * <code>measure()</code>, and 155 * <code>updateDisplayList()</code> methods called (if needed). 156 * 157 * <p>This is the last opportunity to alter the component before it is 158 * displayed. All properties have been committed and the component has 159 * been measured and layed out.</p> 160 * 161 * <p>This event is only dispatched when there are one or more 162 * relevant listeners attached to the dispatching object.</p> 163 * 164 * @eventType mx.events.FlexEvent.UPDATE_COMPLETE 165 * 166 * @langversion 3.0 167 * @playerversion Flash 9 168 * @playerversion AIR 1.1 169 * @productversion Flex 3 170 */ 171[Event(name="updateComplete", type="mx.events.FlexEvent")] 172 173/** 174 * Dispatched when an object's state changes from visible to invisible. 175 * 176 * <p>This event is only dispatched when there are one or more relevant listeners 177 * attached to the dispatching object.</p> 178 * 179 * @eventType mx.events.FlexEvent.HIDE 180 * 181 * @langversion 3.0 182 * @playerversion Flash 9 183 * @playerversion AIR 1.1 184 * @productversion Flex 3 185 */ 186[Event(name="hide", type="mx.events.FlexEvent")] 187 188/** 189 * Dispatched when the component has finished its construction 190 * and has all initialization properties set. 191 * 192 * <p>After the initialization phase, properties are processed, the component 193 * is measured, laid out, and drawn, after which the 194 * <code>creationComplete</code> event is dispatched.</p> 195 * 196 * @eventType mx.events.FlexEvent.INITIALIZE 197 * 198 * @langversion 3.0 199 * @playerversion Flash 9 200 * @playerversion AIR 1.1 201 * @productversion Flex 3 202 */ 203[Event(name="initialize", type="mx.events.FlexEvent")] 204 205/** 206 * Dispatched when the object has moved. 207 * 208 * <p>You can move the component by setting the <code>x</code> 209 * or <code>y</code> properties, by calling the <code>move()</code> 210 * method, by setting one 211 * of the following properties either on the component or on other 212 * components such that the LayoutManager needs to change the 213 * <code>x</code> or <code>y</code> properties of the component:</p> 214 * 215 * <ul> 216 * <li><code>minWidth</code></li> 217 * <li><code>minHeight</code></li> 218 * <li><code>maxWidth</code></li> 219 * <li><code>maxHeight</code></li> 220 * <li><code>explicitWidth</code></li> 221 * <li><code>explicitHeight</code></li> 222 * </ul> 223 * 224 * <p>When you call the <code>move()</code> method, the <code>move</code> 225 * event is dispatched before the method returns. 226 * In all other situations, the <code>move</code> event is not dispatched 227 * until after the property changes.</p> 228 * 229 * <p>This event only dispatched when there are one or more 230 * relevant listeners attached to the dispatching object.</p> 231 * 232 * @eventType mx.events.MoveEvent.MOVE 233 * 234 * @langversion 3.0 235 * @playerversion Flash 9 236 * @playerversion AIR 1.1 237 * @productversion Flex 3 238 */ 239[Event(name="move", type="mx.events.MoveEvent")] 240 241/** 242 * Dispatched at the beginning of the component initialization sequence. 243 * The component is in a very raw state when this event is dispatched. 244 * Many components, such as the Button control, create internal child 245 * components to implement functionality; for example, the Button control 246 * creates an internal UITextField component to represent its label text. 247 * When Flex dispatches the <code>preinitialize</code> event, 248 * the children, including the internal children, of a component 249 * have not yet been created. 250 * 251 * @eventType mx.events.FlexEvent.PREINITIALIZE 252 * 253 * @langversion 3.0 254 * @playerversion Flash 9 255 * @playerversion AIR 1.1 256 * @productversion Flex 3 257 */ 258[Event(name="preinitialize", type="mx.events.FlexEvent")] 259 260/** 261 * Dispatched when the component is removed from a container as a content child 262 * by using the <code>removeChild()</code>, <code>removeChildAt()</code>, 263 * <code>removeElement()</code>, or <code>removeElementAt()</code> method. 264 * If the component is removed from the container as a noncontent child by 265 * using the <code>rawChildren.removeChild()</code> or 266 * <code>rawChildren.removeChildAt()</code> method, the event is not dispatched. 267 * 268 * <p>This event only dispatched when there are one or more relevant listeners 269 * attached to the dispatching object.</p> 270 * 271 * @eventType mx.events.FlexEvent.REMOVE 272 * 273 * @langversion 3.0 274 * @playerversion Flash 9 275 * @playerversion AIR 1.1 276 * @productversion Flex 3 277 */ 278[Event(name="remove", type="mx.events.FlexEvent")] 279 280/** 281 * Dispatched when the component is resized. 282 * 283 * <p>You can resize the component by setting the <code>width</code> or 284 * <code>height</code> property, by calling the <code>setActualSize()</code> 285 * method, or by setting one of 286 * the following properties either on the component or on other components 287 * such that the LayoutManager needs to change the <code>width</code> or 288 * <code>height</code> properties of the component:</p> 289 * 290 * <ul> 291 * <li><code>minWidth</code></li> 292 * <li><code>minHeight</code></li> 293 * <li><code>maxWidth</code></li> 294 * <li><code>maxHeight</code></li> 295 * <li><code>explicitWidth</code></li> 296 * <li><code>explicitHeight</code></li> 297 * </ul> 298 * 299 * <p>The <code>resize</code> event is not 300 * dispatched until after the property changes.</p> 301 * 302 * <p>This event only dispatched when there are one or more 303 * relevant listeners attached to the dispatching object.</p> 304 * 305 * @eventType mx.events.ResizeEvent.RESIZE 306 * 307 * @langversion 3.0 308 * @playerversion Flash 9 309 * @playerversion AIR 1.1 310 * @productversion Flex 3 311 */ 312[Event(name="resize", type="mx.events.ResizeEvent")] 313 314/** 315 * Dispatched when an object's state changes from invisible to visible. 316 * 317 * <p>This event is only dispatched when there are one or more relevant listeners 318 * attached to the dispatching object.</p> 319 * 320 * @eventType mx.events.FlexEvent.SHOW 321 * 322 * @langversion 3.0 323 * @playerversion Flash 9 324 * @playerversion AIR 1.1 325 * @productversion Flex 3 326 */ 327[Event(name="show", type="mx.events.FlexEvent")] 328 329//-------------------------------------- 330// Mouse events 331//-------------------------------------- 332 333/** 334 * Dispatched from a component opened using the PopUpManager 335 * when the user clicks outside it. 336 * 337 * @eventType mx.events.FlexMouseEvent.MOUSE_DOWN_OUTSIDE 338 * 339 * @langversion 3.0 340 * @playerversion Flash 9 341 * @playerversion AIR 1.1 342 * @productversion Flex 3 343 */ 344[Event(name="mouseDownOutside", type="mx.events.FlexMouseEvent")] 345 346/** 347 * Dispatched from a component opened using the PopUpManager 348 * when the user scrolls the mouse wheel outside it. 349 * 350 * @eventType mx.events.FlexMouseEvent.MOUSE_WHEEL_OUTSIDE 351 * 352 * @langversion 3.0 353 * @playerversion Flash 9 354 * @playerversion AIR 1.1 355 * @productversion Flex 3 356 */ 357[Event(name="mouseWheelOutside", type="mx.events.FlexMouseEvent")] 358 359//-------------------------------------- 360// Validation events 361//-------------------------------------- 362 363/** 364 * Dispatched when values are changed programmatically 365 * or by user interaction. 366 * 367 * <p>Because a programmatic change triggers this event, make sure 368 * that any <code>valueCommit</code> event handler does not change 369 * a value that causes another <code>valueCommit</code> event. 370 * For example, do not change a control's <code>dataProvider</code> 371 * property in a <code>valueCommit</code> event handler. </p> 372 * 373 * @eventType mx.events.FlexEvent.VALUE_COMMIT 374 * 375 * @langversion 3.0 376 * @playerversion Flash 9 377 * @playerversion AIR 1.1 378 * @productversion Flex 3 379 */ 380[Event(name="valueCommit", type="mx.events.FlexEvent")] 381 382/** 383 * Dispatched when a component is monitored by a Validator 384 * and the validation failed. 385 * 386 * @eventType mx.events.FlexEvent.INVALID 387 * 388 * @langversion 3.0 389 * @playerversion Flash 9 390 * @playerversion AIR 1.1 391 * @productversion Flex 3 392 */ 393[Event(name="invalid", type="mx.events.FlexEvent")] 394 395/** 396 * Dispatched when a component is monitored by a Validator 397 * and the validation succeeded. 398 * 399 * @eventType mx.events.FlexEvent.VALID 400 * 401 * @langversion 3.0 402 * @playerversion Flash 9 403 * @playerversion AIR 1.1 404 * @productversion Flex 3 405 */ 406[Event(name="valid", type="mx.events.FlexEvent")] 407 408//-------------------------------------- 409// Drag-and-drop events 410//-------------------------------------- 411 412/** 413 * Dispatched by a component when the user moves the mouse over the component 414 * during a drag operation. 415 * In an application running in Flash Player, 416 * the event is dispatched many times when you move the mouse over any component. 417 * In an application running in AIR, the event is dispatched only once. 418 * 419 * <p>In order to be a valid drop target, you must define a handler 420 * for this event. 421 * In the handler, you can change the appearance of the drop target 422 * to provide visual feedback to the user that the component can accept 423 * the drag. 424 * For example, you could draw a border around the drop target, 425 * or give focus to the drop target.</p> 426 * 427 * <p>If you want to accept the drag, you must call the 428 * <code>DragManager.acceptDragDrop()</code> method. If you don't 429 * call <code>acceptDragDrop()</code>, you do not get any of the 430 * other drag events.</p> 431 * 432 * <p>In Flash Player, the value of the <code>action</code> property is always 433 * <code>DragManager.MOVE</code>, even if you are doing a copy. 434 * This is because the <code>dragEnter</code> event occurs before 435 * the control recognizes that the Control key is pressed to signal a copy. 436 * The <code>action</code> property of the event object for the 437 * <code>dragOver</code> event does contain a value that signifies the type of 438 * drag operation. You can change the type of drag action by calling the 439 * <code>DragManager.showFeedback()</code> method.</p> 440 * 441 * <p>In AIR, the default value of the <code>action</code> property is 442 * <code>DragManager.COPY</code>.</p> 443 * 444 * <p>Because of the way data to a Tree control is structured, 445 * the Tree control handles drag and drop differently from the other list-based controls. 446 * For the Tree control, the event handler for the <code>dragDrop</code> event 447 * only performs an action when you move or copy data in the same Tree control, 448 * or copy data to another Tree control. 449 * If you drag data from one Tree control and drop it onto another Tree control 450 * to move the data, the event handler for the <code>dragComplete</code> event 451 * actually performs the work to add the data to the destination Tree control, 452 * rather than the event handler for the dragDrop event, 453 * and also removes the data from the source Tree control. 454 * This is necessary because to reparent the data being moved, 455 * Flex must remove it first from the source Tree control.</p> 456 * 457 * @see mx.managers.DragManager 458 * 459 * @eventType mx.events.DragEvent.DRAG_ENTER 460 * 461 * @langversion 3.0 462 * @playerversion Flash 9 463 * @playerversion AIR 1.1 464 * @productversion Flex 3 465 */ 466[Event(name="dragEnter", type="mx.events.DragEvent")] 467 468/** 469 * Dispatched by a component when the user moves the mouse while over the component 470 * during a drag operation. 471 * In Flash Player, the event is dispatched 472 * when you drag an item over a valid drop target. 473 * In AIR, the event is dispatched when you drag an item over 474 * any component, even if the component is not a valid drop target. 475 * 476 * <p>In the handler, you can change the appearance of the drop target 477 * to provide visual feedback to the user that the component can accept 478 * the drag. 479 * For example, you could draw a border around the drop target, 480 * or give focus to the drop target.</p> 481 * 482 * <p>Handle this event to perform additional logic 483 * before allowing the drop, such as dropping data to various locations 484 * in the drop target, reading keyboard input to determine if the 485 * drag-and-drop action is a move or copy of the drag data, or providing 486 * different types of visual feedback based on the type of drag-and-drop 487 * action.</p> 488 * 489 * <p>You can also change the type of drag action by changing the 490 * <code>DragManager.showFeedback()</code> method. 491 * The default value of the <code>action</code> property is 492 * <code>DragManager.MOVE</code>.</p> 493 * 494 * @see mx.managers.DragManager 495 * 496 * @eventType mx.events.DragEvent.DRAG_OVER 497 * 498 * @langversion 3.0 499 * @playerversion Flash 9 500 * @playerversion AIR 1.1 501 * @productversion Flex 3 502 */ 503[Event(name="dragOver", type="mx.events.DragEvent")] 504 505/** 506 * Dispatched by the component when the user drags outside the component, 507 * but does not drop the data onto the target. 508 * 509 * <p>You use this event to restore the drop target to its normal appearance 510 * if you modified its appearance as part of handling the 511 * <code>dragEnter</code> or <code>dragOver</code> event.</p> 512 * 513 * @eventType mx.events.DragEvent.DRAG_EXIT 514 * 515 * @langversion 3.0 516 * @playerversion Flash 9 517 * @playerversion AIR 1.1 518 * @productversion Flex 3 519 */ 520[Event(name="dragExit", type="mx.events.DragEvent")] 521 522/** 523 * Dispatched by the drop target when the user releases the mouse over it. 524 * 525 * <p>You use this event handler to add the drag data to the drop target.</p> 526 * 527 * <p>If you call <code>Event.preventDefault()</code> in the event handler 528 * for the <code>dragDrop</code> event for 529 * a Tree control when dragging data from one Tree control to another, 530 * it prevents the drop.</p> 531 * 532 * @eventType mx.events.DragEvent.DRAG_DROP 533 * 534 * @langversion 3.0 535 * @playerversion Flash 9 536 * @playerversion AIR 1.1 537 * @productversion Flex 3 538 */ 539[Event(name="dragDrop", type="mx.events.DragEvent")] 540 541/** 542 * Dispatched by the drag initiator (the component that is the source 543 * of the data being dragged) when the drag operation completes, 544 * either when you drop the dragged data onto a drop target or when you end 545 * the drag-and-drop operation without performing a drop. 546 * 547 * <p>You can use this event to perform any final cleanup 548 * of the drag-and-drop operation. 549 * For example, if you drag a List control item from one list to another, 550 * you can delete the List control item from the source if you no longer 551 * need it.</p> 552 * 553 * <p>If you call <code>Event.preventDefault()</code> in the event handler 554 * for the <code>dragComplete</code> event for 555 * a Tree control when dragging data from one Tree control to another, 556 * it prevents the drop.</p> 557 * 558 * @eventType mx.events.DragEvent.DRAG_COMPLETE 559 * 560 * @langversion 3.0 561 * @playerversion Flash 9 562 * @playerversion AIR 1.1 563 * @productversion Flex 3 564 */ 565[Event(name="dragComplete", type="mx.events.DragEvent")] 566 567/** 568 * Dispatched by the drag initiator when starting a drag operation. 569 * This event is used internally by the list-based controls; 570 * you do not handle it when implementing drag and drop. 571 * If you want to control the start of a drag-and-drop operation, 572 * use the <code>mouseDown</code> or <code>mouseMove</code> event. 573 * 574 * @eventType mx.events.DragEvent.DRAG_START 575 * 576 * @langversion 3.0 577 * @playerversion Flash 9 578 * @playerversion AIR 1.1 579 * @productversion Flex 3 580 */ 581[Event(name="dragStart", type="mx.events.DragEvent")] 582 583//-------------------------------------- 584// Effect events 585//-------------------------------------- 586 587/** 588 * Dispatched just before an effect starts. 589 * 590 * <p>The effect does not start changing any visuals 591 * until after this event is fired.</p> 592 * 593 * @eventType mx.events.EffectEvent.EFFECT_START 594 * 595 * @langversion 3.0 596 * @playerversion Flash 9 597 * @playerversion AIR 1.1 598 * @productversion Flex 3 599 */ 600[Event(name="effectStart", type="mx.events.EffectEvent")] 601 602/** 603 * Dispatched after an effect is stopped, which happens 604 * only by a call to <code>stop()</code> on the effect. 605 * 606 * <p>The effect then dispatches the EFFECT_END event 607 * as the effect finishes. The purpose of the EFFECT_STOP 608 * event is to let listeners know that the effect came to 609 * a premature end, rather than ending naturally or as a 610 * result of a call to <code>end()</code>.</p> 611 * 612 * @eventType mx.events.EffectEvent.EFFECT_STOP 613 * 614 * @langversion 3.0 615 * @playerversion Flash 9 616 * @playerversion AIR 1.1 617 * @productversion Flex 3 618 */ 619[Event(name="effectStop", type="mx.events.EffectEvent")] 620 621/** 622 * Dispatched after an effect ends. 623 * 624 * <p>The effect makes the last set of visual changes 625 * before this event is fired, but those changes are not 626 * rendered on the screen. 627 * Thus, you might have to use the <code>callLater()</code> method 628 * to delay any other changes that you want to make until after the 629 * changes have been rendered onscreen.</p> 630 * 631 * @eventType mx.events.EffectEvent.EFFECT_END 632 * 633 * @langversion 3.0 634 * @playerversion Flash 9 635 * @playerversion AIR 1.1 636 * @productversion Flex 3 637 */ 638[Event(name="effectEnd", type="mx.events.EffectEvent")] 639 640 641//-------------------------------------- 642// State events 643//-------------------------------------- 644 645/** 646 * Dispatched after the <code>currentState</code> property changes, 647 * but before the view state changes. 648 * 649 * <p>This event is only dispatched when there are one or more 650 * relevant listeners attached to the dispatching object.</p> 651 * 652 * @eventType mx.events.StateChangeEvent.CURRENT_STATE_CHANGING 653 * 654 * @langversion 3.0 655 * @playerversion Flash 9 656 * @playerversion AIR 1.1 657 * @productversion Flex 3 658 */ 659[Event(name="currentStateChanging", type="mx.events.StateChangeEvent")] 660 661/** 662 * Dispatched after the view state has changed. 663 * 664 * <p>This event is only dispatched when there are one or more 665 * relevant listeners attached to the dispatching object.</p> 666 * 667 * @eventType mx.events.StateChangeEvent.CURRENT_STATE_CHANGE 668 * 669 * @langversion 3.0 670 * @playerversion Flash 9 671 * @playerversion AIR 1.1 672 * @productversion Flex 3 673 */ 674[Event(name="currentStateChange", type="mx.events.StateChangeEvent")] 675 676/** 677 * Dispatched after the component has entered a view state. 678 * 679 * <p>This event is only dispatched when there are one or more 680 * relevant listeners attached to the dispatching object.</p> 681 * 682 * @eventType mx.events.FlexEvent.ENTER_STATE 683 * 684 * @langversion 3.0 685 * @playerversion Flash 9 686 * @playerversion AIR 1.1 687 * @productversion Flex 3 688 */ 689[Event(name="enterState", type="mx.events.FlexEvent")] 690 691/** 692 * Dispatched just before the component exits a view state. 693 * 694 * <p>This event is only dispatched when there are one or more 695 * relevant listeners attached to the dispatching object.</p> 696 * 697 * @eventType mx.events.FlexEvent.EXIT_STATE 698 * 699 * @langversion 3.0 700 * @playerversion Flash 9 701 * @playerversion AIR 1.1 702 * @productversion Flex 3 703 */ 704[Event(name="exitState", type="mx.events.FlexEvent")] 705 706/** 707 * Dispatched after the component has entered a new state and 708 * any state transition animation to that state has finished playing. 709 * 710 * The event is dispatched immediately if there's no transition playing 711 * between the states. 712 * 713 * If the component switches to a different state while the transition is 714 * underway, this event will be dispatched after the component completes the 715 * transition to that new state. 716 * 717 * <p>This event is only dispatched when there are one or more 718 * relevant listeners attached to the dispatching object.</p> 719 * 720 * @eventType mx.events.FlexEvent.STATE_CHANGE_COMPLETE 721 * 722 * @langversion 3.0 723 * @playerversion Flash 10 724 * @playerversion AIR 2.5 725 * @productversion Flex 4.5 726 */ 727[Event(name="stateChangeComplete", type="mx.events.FlexEvent")] 728 729/** 730 * Dispatched when a component interrupts a transition to its current 731 * state in order to switch to a new state. 732 * 733 * <p>This event is only dispatched when there are one or more 734 * relevant listeners attached to the dispatching object.</p> 735 * 736 * @eventType mx.events.FlexEvent.STATE_CHANGE_INTERRUPTED 737 * 738 * @langversion 3.0 739 * @playerversion Flash 10 740 * @playerversion AIR 2.5 741 * @productversion Flex 4.5 742 */ 743[Event(name="stateChangeInterrupted", type="mx.events.FlexEvent")] 744 745 746//-------------------------------------- 747// TouchInteraction events 748//-------------------------------------- 749 750/** 751 * A cancellable event, dispatched by a component in an attempt to 752 * respond to a touch interaction user gesture. 753 * 754 * <p>The event is a bubbling event dispatched on the 755 * DisplayObject that the touch interaction 756 * started (where the mouseDown/touchBegin occurred).</p> 757 * 758 * <p>Components responding to touch interactions should listen for 759 * touch interaction events to coordinate with other components around 760 * what type of touch interaction the user intended to make and which component 761 * is responding to that touch interaction.</p> 762 * 763 * <p>A Scroller component will dispatch a touchInteractionStarting event 764 * to alert other components that may be responding to the same user's 765 * touch interaction that it would like to take control of this touch interaction. 766 * This is an opportunity for other components to cancel the Scroller's 767 * action and to maintain control over this touch interaction.</p> 768 * 769 * @eventType mx.events.TouchInteractionEvent.TOUCH_INTERACTION_STARTING 770 * 771 * @langversion 3.0 772 * @playerversion Flash 10 773 * @playerversion AIR 2.5 774 * @productversion Flex 4.5 775 */ 776[Event(name="touchInteractionStarting", type="mx.events.TouchInteractionEvent")] 777 778/** 779 * A non-cancellable event, dispatched by a component when it starts 780 * responding to a touch interaction user gesture. 781 * 782 * <p>The event is a bubbling event dispatched on the 783 * DisplayObject that the touch interaction 784 * started (where the mouseDown/touchBegin occurred).</p> 785 * 786 * <p>Components responding to touch interactions should listen for 787 * touch interaction events to coordinate with other components around 788 * what type of touch interaction the user intended to make and which component 789 * is responding to that touch interaction.</p> 790 * 791 * <p>A Scroller component will dispatch a touchInteractionStart event 792 * to alert other components that may be responding to the same user's 793 * touch interaction that it is taking control of this touch interaction. 794 * When they see this event, other components should stop responding 795 * to the touch interaction, remove any visual indications that it is 796 * responding to the touch interaction, and perform other clean up.</p> 797 * 798 * @eventType mx.events.TouchInteractionEvent.TOUCH_INTERACTION_START 799 * 800 * @langversion 3.0 801 * @playerversion Flash 10 802 * @playerversion AIR 2.5 803 * @productversion Flex 4.5 804 */ 805[Event(name="touchInteractionStart", type="mx.events.TouchInteractionEvent")] 806 807/** 808 * A non-cancellable event, dispatched by a component when it is done 809 * responding to a touch interaction user gesture. 810 * 811 * <p>The event is a bubbling event dispatched on the 812 * DisplayObject that the touch interaction 813 * started (where the mouseDown/touchBegin occurred).</p> 814 * 815 * <p>Components responding to touch interactions should listen for 816 * touch interaction events to coordinate with other components around 817 * what type of touch interaction the user intended to make and which component 818 * is responding to that touch interaction.</p> 819 * 820 * <p>A Scroller component will dispatch a touchInteractionEnd event 821 * to alert other components that it is done responding to the user's 822 * touch interaction.</p> 823 * 824 * @eventType mx.events.TouchInteractionEvent.TOUCH_INTERACTION_END 825 * 826 * @langversion 3.0 827 * @playerversion Flash 10 828 * @playerversion AIR 2.5 829 * @productversion Flex 4.5 830 */ 831[Event(name="touchInteractionEnd", type="mx.events.TouchInteractionEvent")] 832 833//-------------------------------------- 834// Tooltip events 835//-------------------------------------- 836 837/** 838 * Dispatched by the component when it is time to create a ToolTip. 839 * 840 * <p>If you create your own IToolTip object and place a reference 841 * to it in the <code>toolTip</code> property of the event object 842 * that is passed to your <code>toolTipCreate</code> handler, 843 * the ToolTipManager displays your custom ToolTip. 844 * Otherwise, the ToolTipManager creates an instance of 845 * <code>ToolTipManager.toolTipClass</code> to display.</p> 846 * 847 * <p>The sequence of ToolTip events is <code>toolTipStart</code>, 848 * <code>toolTipCreate</code>, <code>toolTipShow</code>, 849 * <code>toolTipShown</code>, <code>toolTipHide</code>, 850 * and <code>toolTipEnd</code>.</p> 851 * 852 * @eventType mx.events.ToolTipEvent.TOOL_TIP_CREATE 853 * 854 * @langversion 3.0 855 * @playerversion Flash 9 856 * @playerversion AIR 1.1 857 * @productversion Flex 3 858 */ 859[Event(name="toolTipCreate", type="mx.events.ToolTipEvent")] 860 861/** 862 * Dispatched by the component when its ToolTip has been hidden 863 * and is to be discarded soon. 864 * 865 * <p>If you specify an effect using the 866 * <code>ToolTipManager.hideEffect</code> property, 867 * this event is dispatched after the effect stops playing.</p> 868 * 869 * <p>The sequence of ToolTip events is <code>toolTipStart</code>, 870 * <code>toolTipCreate</code>, <code>toolTipShow</code>, 871 * <code>toolTipShown</code>, <code>toolTipHide</code>, 872 * and <code>toolTipEnd</code>.</p> 873 * 874 * @eventType mx.events.ToolTipEvent.TOOL_TIP_END 875 * 876 * @langversion 3.0 877 * @playerversion Flash 9 878 * @playerversion AIR 1.1 879 * @productversion Flex 3 880 */ 881[Event(name="toolTipEnd", type="mx.events.ToolTipEvent")] 882 883/** 884 * Dispatched by the component when its ToolTip is about to be hidden. 885 * 886 * <p>If you specify an effect using the 887 * <code>ToolTipManager.hideEffect</code> property, 888 * this event is dispatched before the effect starts playing.</p> 889 * 890 * <p>The sequence of ToolTip events is <code>toolTipStart</code>, 891 * <code>toolTipCreate</code>, <code>toolTipShow</code>, 892 * <code>toolTipShown</code>, <code>toolTipHide</code>, 893 * and <code>toolTipEnd</code>.</p> 894 * 895 * @eventType mx.events.ToolTipEvent.TOOL_TIP_HIDE 896 * 897 * @langversion 3.0 898 * @playerversion Flash 9 899 * @playerversion AIR 1.1 900 * @productversion Flex 3 901 */ 902[Event(name="toolTipHide", type="mx.events.ToolTipEvent")] 903 904/** 905 * Dispatched by the component when its ToolTip is about to be shown. 906 * 907 * <p>If you specify an effect using the 908 * <code>ToolTipManager.showEffect</code> property, 909 * this event is dispatched before the effect starts playing. 910 * You can use this event to modify the ToolTip before it appears.</p> 911 * 912 * <p>The sequence of ToolTip events is <code>toolTipStart</code>, 913 * <code>toolTipCreate</code>, <code>toolTipShow</code>, 914 * <code>toolTipShown</code>, <code>toolTipHide</code>, 915 * and <code>toolTipEnd</code>.</p> 916 * 917 * @eventType mx.events.ToolTipEvent.TOOL_TIP_SHOW 918 * 919 * @langversion 3.0 920 * @playerversion Flash 9 921 * @playerversion AIR 1.1 922 * @productversion Flex 3 923 */ 924[Event(name="toolTipShow", type="mx.events.ToolTipEvent")] 925 926/** 927 * Dispatched by the component when its ToolTip has been shown. 928 * 929 * <p>If you specify an effect using the 930 * <code>ToolTipManager.showEffect</code> property, 931 * this event is dispatched after the effect stops playing.</p> 932 * 933 * <p>The sequence of ToolTip events is <code>toolTipStart</code>, 934 * <code>toolTipCreate</code>, <code>toolTipShow</code>, 935 * <code>toolTipShown</code>, <code>toolTipHide</code>, 936 * and <code>toolTipEnd</code>.</p> 937 * 938 * @eventType mx.events.ToolTipEvent.TOOL_TIP_SHOWN 939 * 940 * @langversion 3.0 941 * @playerversion Flash 9 942 * @playerversion AIR 1.1 943 * @productversion Flex 3 944 */ 945[Event(name="toolTipShown", type="mx.events.ToolTipEvent")] 946 947/** 948 * Dispatched by a component whose <code>toolTip</code> property is set, 949 * as soon as the user moves the mouse over it. 950 * 951 * <p>The sequence of ToolTip events is <code>toolTipStart</code>, 952 * <code>toolTipCreate</code>, <code>toolTipShow</code>, 953 * <code>toolTipShown</code>, <code>toolTipHide</code>, 954 * and <code>toolTipEnd</code>.</p> 955 * 956 * @eventType mx.events.ToolTipEvent.TOOL_TIP_START 957 * 958 * @langversion 3.0 959 * @playerversion Flash 9 960 * @playerversion AIR 1.1 961 * @productversion Flex 3 962 */ 963[Event(name="toolTipStart", type="mx.events.ToolTipEvent")] 964 965//-------------------------------------- 966// Styles 967//-------------------------------------- 968 969include "../styles/metadata/AnchorStyles.as"; 970 971/** 972 * The main color for a component. 973 * 974 * @langversion 3.0 975 * @playerversion Flash 10 976 * @playerversion AIR 1.5 977 * @productversion Flex 4 978 */ 979[Style(name="chromeColor", type="uint", format="Color", inherit="yes", theme="spark")] 980 981/** 982 * Color of the component highlight when validation fails. 983 * Flex also sets the <code>borderColor</code> style of the component to this 984 * <code>errorColor</code> on a validation failure. 985 * 986 * The default value for the Halo theme is <code>0xFF0000</code>. 987 * The default value for the Spark theme is <code>0xFE0000</code>. 988 * 989 * @langversion 3.0 990 * @playerversion Flash 9 991 * @playerversion AIR 1.1 992 * @productversion Flex 3 993 */ 994[Style(name="errorColor", type="uint", format="Color", inherit="yes")] 995 996/** 997 * The primary interaction mode for this component. The acceptable values are: 998 * <code>mouse</code> and <code>touch</code>. 999 * 1000 * The default value for the Halo theme is <code>mouse</code>. 1001 * The default value for the Spark theme is <code>mouse</code>. 1002 * The default value for the Mobile theme is <code>touch</code>. 1003 * 1004 * @see mx.core.InteractionMode#MOUSE 1005 * @see mx.core.InteractionMode#TOUCH 1006 * 1007 * @langversion 3.0 1008 * @playerversion Flash 10 1009 * @playerversion AIR 2.5 1010 * @productversion Flex 4.5 1011 */ 1012[Style(name="interactionMode", type="String", enumeration="mouse,touch", inherit="yes")] 1013 1014/** 1015 * Blend mode used by the focus rectangle. 1016 * For more information, see the <code>blendMode</code> property 1017 * of the flash.display.DisplayObject class. 1018 * 1019 * @default "normal" 1020 * 1021 * @langversion 3.0 1022 * @playerversion Flash 9 1023 * @playerversion AIR 1.1 1024 * @productversion Flex 3 1025 */ 1026[Style(name="focusBlendMode", type="String", inherit="no")] 1027 1028/** 1029 * Skin used to draw the focus rectangle. 1030 * 1031 * The default value for Halo components is mx.skins.halo.HaloFocusRect. 1032 * The default value for Spark components is spark.skins.spark.FocusSkin. 1033 * 1034 * @langversion 3.0 1035 * @playerversion Flash 9 1036 * @playerversion AIR 1.1 1037 * @productversion Flex 3 1038 */ 1039[Style(name="focusSkin", type="Class", inherit="no")] 1040 1041/** 1042 * Thickness, in pixels, of the focus rectangle outline. 1043 * 1044 * @default 2 1045 * 1046 * @langversion 3.0 1047 * @playerversion Flash 9 1048 * @playerversion AIR 1.1 1049 * @productversion Flex 3 1050 */ 1051[Style(name="focusThickness", type="Number", format="Length", inherit="no", minValue="0.0")] 1052 1053/** 1054 * Specifies the desired layout direction of a component. The allowed values 1055 * are <code>"ltr"</code> for left-to-right layout, used for 1056 * components using Latin-style scripts, and <code>"rtl"</code> for 1057 * right-to-left layout, used for components using scripts such 1058 * as Arabic and Hebrew. 1059 * 1060 * <p>In ActionScript you can set the layoutDirection using the values 1061 * <code>mx.core.LayoutDirection.LTR</code>, 1062 * <code>mx.core.LayoutDirection.RTL</code> or 1063 * <code>undefined</code>, to inherit the layoutDirection from the parent.</p> 1064 * 1065 * <p>The layoutDirection should typically be set on the 1066 * <code>Application</code> rather than on individual components. If the 1067 * layoutDirection is <code>"rtl"</code>, most visual elements, except text 1068 * and images, will be mirrored. The directionality of text is determined 1069 * by the <code>direction</code> style.</p> 1070 * 1071 * <p>Components which handle Keyboard.LEFT and Keyboard.RIGHT events 1072 * typically swap the key’s meaning when layoutDirection is 1073 * <code>“rtl”</code>. In other words, left always means move left and 1074 * right always means move right, regardless of the 1075 * <code>layoutDirection</code></p> 1076 * 1077 * <p>Note: This style applies to all Spark components and MX components that 1078 * specify UIFTETextField as their textFieldClass.</p> 1079 * 1080 * @default "ltr" 1081 * 1082 * @see MXFTEText.css 1083 * @see mx.core.ILayoutDirectionElement 1084 * @see mx.core.LayoutDirection 1085 * 1086 * @langversion 3.0 1087 * @playerversion Flash 10 1088 * @playerversion AIR 1.5 1089 * @productversion Flex 4.1 1090 */ 1091[Style(name="layoutDirection", type="String", enumeration="ltr,rtl", inherit="yes")] 1092 1093/** 1094 * Show the error border or skin when this component is invalid 1095 * 1096 * @default true 1097 * 1098 * @langversion 3.0 1099 * @playerversion Flash 10 1100 * @playerversion AIR 1.5 1101 * @productversion Flex 4.5 1102 */ 1103[Style(name="showErrorSkin", type="Boolean", inherit="yes")] 1104 1105/** 1106 * Show the error tip when this component is invalid and the user 1107 * rolls over it 1108 * 1109 * @default true 1110 * 1111 * @langversion 3.0 1112 * @playerversion Flash 10 1113 * @playerversion AIR 1.5 1114 * @productversion Flex 4.5 1115 */ 1116[Style(name="showErrorTip", type="Boolean", inherit="yes")] 1117 1118/** 1119 * Theme color of a component. This property controls the appearance of highlights, 1120 * appearance when a component is selected, and other similar visual cues, but it 1121 * does not have any effect on the regular borders or background colors of the component. 1122 * The preferred values are <code>haloGreen</code>, <code>haloBlue</code>, 1123 * <code>haloOrange</code>, and <code>haloSilver</code>, although any valid color 1124 * value can be used. 1125 * 1126 * <p>The default values of the <code>rollOverColor</code> and 1127 * <code>selectionColor</code> styles are based on the 1128 * <code>themeColor</code> value.</p> 1129 * 1130 * @default "haloBlue" 1131 * 1132 * @langversion 3.0 1133 * @playerversion Flash 9 1134 * @playerversion AIR 1.1 1135 * @productversion Flex 3 1136 */ 1137[Style(name="themeColor", type="uint", format="Color", inherit="yes", theme="halo")] 1138 1139//-------------------------------------- 1140// Effects 1141//-------------------------------------- 1142 1143/** 1144 * Played when the component is created. 1145 * 1146 * @langversion 3.0 1147 * @playerversion Flash 9 1148 * @playerversion AIR 1.1 1149 * @productversion Flex 3 1150 */ 1151[Effect(name="creationCompleteEffect", event="creationComplete")] 1152 1153/** 1154 * Played when the component is moved. 1155 * 1156 * @langversion 3.0 1157 * @playerversion Flash 9 1158 * @playerversion AIR 1.1 1159 * @productversion Flex 3 1160 */ 1161[Effect(name="moveEffect", event="move")] 1162 1163/** 1164 * Played when the component is resized. 1165 * 1166 * @langversion 3.0 1167 * @playerversion Flash 9 1168 * @playerversion AIR 1.1 1169 * @productversion Flex 3 1170 */ 1171[Effect(name="resizeEffect", event="resize")] 1172 1173/** 1174 * Played when the component becomes visible. 1175 * 1176 * @langversion 3.0 1177 * @playerversion Flash 9 1178 * @playerversion AIR 1.1 1179 * @productversion Flex 3 1180 */ 1181[Effect(name="showEffect", event="show")] 1182 1183/** 1184 * Played when the component becomes invisible. 1185 * 1186 * @langversion 3.0 1187 * @playerversion Flash 9 1188 * @playerversion AIR 1.1 1189 * @productversion Flex 3 1190 */ 1191[Effect(name="hideEffect", event="hide")] 1192 1193/** 1194 * Played when the user presses the mouse button while over the component. 1195 * 1196 * @langversion 3.0 1197 * @playerversion Flash 9 1198 * @playerversion AIR 1.1 1199 * @productversion Flex 3 1200 */ 1201[Effect(name="mouseDownEffect", event="mouseDown")] 1202 1203/** 1204 * Played when the user releases the mouse button while over the component. 1205 * 1206 * @langversion 3.0 1207 * @playerversion Flash 9 1208 * @playerversion AIR 1.1 1209 * @productversion Flex 3 1210 */ 1211[Effect(name="mouseUpEffect", event="mouseUp")] 1212 1213/** 1214 * Played when the user rolls the mouse over the component. 1215 * 1216 * @langversion 3.0 1217 * @playerversion Flash 9 1218 * @playerversion AIR 1.1 1219 * @productversion Flex 3 1220 */ 1221[Effect(name="rollOverEffect", event="rollOver")] 1222 1223/** 1224 * Played when the user rolls the mouse so it is no longer over the component. 1225 * 1226 * @langversion 3.0 1227 * @playerversion Flash 9 1228 * @playerversion AIR 1.1 1229 * @productversion Flex 3 1230 */ 1231[Effect(name="rollOutEffect", event="rollOut")] 1232 1233/** 1234 * Played when the component gains keyboard focus. 1235 * 1236 * @langversion 3.0 1237 * @playerversion Flash 9 1238 * @playerversion AIR 1.1 1239 * @productversion Flex 3 1240 */ 1241[Effect(name="focusInEffect", event="focusIn")] 1242 1243/** 1244 * Played when the component loses keyboard focus. 1245 * 1246 * @langversion 3.0 1247 * @playerversion Flash 9 1248 * @playerversion AIR 1.1 1249 * @productversion Flex 3 1250 */ 1251[Effect(name="focusOutEffect", event="focusOut")] 1252 1253/** 1254 * Played when the component is added as a child to a Container. 1255 * 1256 * @langversion 3.0 1257 * @playerversion Flash 9 1258 * @playerversion AIR 1.1 1259 * @productversion Flex 3 1260 */ 1261[Effect(name="addedEffect", event="added")] 1262 1263/** 1264 * Played when the component is removed from a Container. 1265 * 1266 * @langversion 3.0 1267 * @playerversion Flash 9 1268 * @playerversion AIR 1.1 1269 * @productversion Flex 3 1270 */ 1271[Effect(name="removedEffect", event="removed")] 1272 1273//-------------------------------------- 1274// Other metadata 1275//-------------------------------------- 1276 1277[AccessibilityClass(implementation="mx.accessibility.UIComponentAccProps")] 1278 1279[ResourceBundle("core")] 1280 1281// skins resources aren't found because CSS visited by the compiler 1282[ResourceBundle("skins")] 1283 1284/** 1285 * The UIComponent class is the base class for all visual components, 1286 * both interactive and noninteractive. 1287 * 1288 * <p>An interactive component can participate in tabbing and other kinds of 1289 * keyboard focus manipulation, accept low-level events like keyboard and 1290 * mouse input, and be disabled so that it does not receive keyboard and 1291 * mouse input. 1292 * This is in contrast to noninteractive components, like Label and 1293 * ProgressBar, which simply display contents and are not manipulated by 1294 * the user.</p> 1295 * <p>The UIComponent class is not used as an MXML tag, but is used as a base 1296 * class for other classes.</p> 1297 * 1298 * @mxml 1299 * 1300 * <p>All user interface components in Flex extend the UIComponent class. 1301 * Flex components inherit the following properties from the UIComponent 1302 * class:</p> 1303 * 1304 * <pre> 1305 * <mx:<i>tagname</i> 1306 * <b>Properties </b> 1307 * accessibilityDescription="null" 1308 * accessibilityName="null" 1309 * accessibilityShortcut="null" 1310 * accessibilitySilent="true|false" 1311 * automationName="null" 1312 * cachePolicy="auto|on|off" 1313 * currentState="null" 1314 * doubleClickEnabled="false|true" 1315 * enabled="true|false" 1316 * explicitHeight="NaN" 1317 * explicitMaxHeight="NaN" 1318 * explicitMaxWidth="NaN" 1319 * explicitMinHeight="NaN" 1320 * explicitMinWidth="NaN" 1321 * explicitWidth="NaN" 1322 * focusEnabled="true|false" 1323 * hasFocusableChildren="false|true" 1324 * height="0" 1325 * id="" 1326 * includeInLayout="true|false" 1327 * maxHeight="10000" 1328 * maxWidth="10000" 1329 * measuredHeight= 1330 * measuredMinHeight= 1331 * measuredMinWidth= 1332 * measuredWidth= 1333 * minHeight="0" 1334 * minWidth="0" 1335 * mouseFocusEnabled="true|false" 1336 * percentHeight="NaN" 1337 * percentWidth="NaN" 1338 * scaleX="1.0" 1339 * scaleY="1.0" 1340 * states="null" 1341 * styleName="undefined" 1342 * toolTip="null" 1343 * transitions="" 1344 * validationSubField 1345 * width="0" 1346 * x="0" 1347 * y="0" 1348 * 1349 * <b>Styles</b> 1350 * bottom="undefined" 1351 * errorColor="0xFF0000" 1352 * focusBlendMode="normal" 1353 * focusSkin="HaloFocusRect"" 1354 * focusThickness="2" 1355 * horizontalCenter="undefined" 1356 * layoutDirection="ltr" 1357 * left="undefined" 1358 * right="undefined" 1359 * themeColor="haloGreen" 1360 * top="undefined" 1361 * verticalCenter="undefined" 1362 * 1363 * <b>Effects</b> 1364 * addedEffect="<i>No default</i>" 1365 * creationCompleteEffect="<i>No default</i>" 1366 * focusInEffect="<i>No default</i>" 1367 * focusOutEffect="<i>No default</i>" 1368 * hideEffect="<i>No default</i>" 1369 * mouseDownEffect="<i>No default</i>" 1370 * mouseUpEffect="<i>No default</i>" 1371 * moveEffect="<i>No default</i>" 1372 * removedEffect="<i>No default</i>" 1373 * resizeEffect="<i>No default</i>" 1374 * rollOutEffect="<i>No default</i>" 1375 * rollOverEffect="<i>No default</i>" 1376 * showEffect="<i>No default</i>" 1377 * 1378 * <b>Events</b> 1379 * add="<i>No default</i>" 1380 * creationComplete="<i>No default</i>" 1381 * currentStateChange="<i>No default</i>" 1382 * currentStateChanging="<i>No default</i>" 1383 * dragComplete="<i>No default</i>" 1384 * dragDrop="<i>No default</i>" 1385 * dragEnter="<i>No default</i>" 1386 * dragExit="<i>No default</i>" 1387 * dragOver="<i>No default</i>" 1388 * effectEnd="<i>No default</i>" 1389 * effectStart="<i>No default</i>" 1390 * enterState="<i>No default</i>" 1391 * exitState="<i>No default</i>" 1392 * hide="<i>No default</i>" 1393 * initialize="<i>No default</i>" 1394 * invalid="<i>No default</i>" 1395 * mouseDownOutside="<i>No default</i>" 1396 * mouseWheelOutside="<i>No default</i>" 1397 * move="<i>No default</i>" 1398 * preinitialize="<i>No default</i>" 1399 * remove="<i>No default</i>" 1400 * resize="<i>No default</i>" 1401 * show="<i>No default</i>" 1402 * toolTipCreate="<i>No default</i>" 1403 * toolTipEnd="<i>No default</i>" 1404 * toolTipHide="<i>No default</i>" 1405 * toolTipShow="<i>No default</i>" 1406 * toolTipShown="<i>No default</i>" 1407 * toolTipStart="<i>No default</i>" 1408 * updateComplete="<i>No default</i>" 1409 * valid="<i>No default</i>" 1410 * valueCommit="<i>No default</i>" 1411 * > 1412 * </pre> 1413 * 1414 * @see mx.core.UIComponent 1415 * 1416 * @langversion 3.0 1417 * @playerversion Flash 9 1418 * @playerversion AIR 1.1 1419 * @productversion Flex 3 1420 */ 1421public class UIComponent extends FlexSprite 1422 implements IAutomationObject, IChildList, IConstraintClient, 1423 IDeferredInstantiationUIComponent, IFlexDisplayObject, IFlexModule, 1424 IInvalidating, ILayoutManagerClient, IPropertyChangeNotifier, 1425 IRepeaterClient, IStateClient, IAdvancedStyleClient, IToolTipManagerClient, 1426 IUIComponent, IValidatorListener, IVisualElement 1427{ 1428 include "../core/Version.as"; 1429 1430 //-------------------------------------------------------------------------- 1431 // 1432 // Class constants 1433 // 1434 //-------------------------------------------------------------------------- 1435 1436 /** 1437 * The default value for the <code>measuredWidth</code> property. 1438 * Most components calculate a measuredWidth but some are flow-based and 1439 * have to pick a number that looks reasonable. 1440 * 1441 * @default 160 1442 * 1443 * @langversion 3.0 1444 * @playerversion Flash 9 1445 * @playerversion AIR 1.1 1446 * @productversion Flex 3 1447 */ 1448 public static const DEFAULT_MEASURED_WIDTH:Number = 160; 1449 1450 /** 1451 * The default value for the <code>measuredMinWidth</code> property. 1452 * Most components calculate a measuredMinWidth but some are flow-based and 1453 * have to pick a number that looks reasonable. 1454 * 1455 * @default 40 1456 * 1457 * @langversion 3.0 1458 * @playerversion Flash 9 1459 * @playerversion AIR 1.1 1460 * @productversion Flex 3 1461 */ 1462 public static const DEFAULT_MEASURED_MIN_WIDTH:Number = 40; 1463 1464 /** 1465 * The default value for the <code>measuredHeight</code> property. 1466 * Most components calculate a measuredHeight but some are flow-based and 1467 * have to pick a number that looks reasonable. 1468 * 1469 * @default 22 1470 * 1471 * @langversion 3.0 1472 * @playerversion Flash 9 1473 * @playerversion AIR 1.1 1474 * @productversion Flex 3 1475 */ 1476 public static const DEFAULT_MEASURED_HEIGHT:Number = 22; 1477 1478 /** 1479 * The default value for the <code>measuredMinHeight</code> property. 1480 * Most components calculate a measuredMinHeight but some are flow-based and 1481 * have to pick a number that looks reasonable. 1482 * 1483 * @default 22 1484 * 1485 * @langversion 3.0 1486 * @playerversion Flash 9 1487 * @playerversion AIR 1.1 1488 * @productversion Flex 3 1489 */ 1490 public static const DEFAULT_MEASURED_MIN_HEIGHT:Number = 22; 1491 1492 /** 1493 * The default value for the <code>maxWidth</code> property. 1494 * 1495 * @default 10000 1496 * 1497 * @langversion 3.0 1498 * @playerversion Flash 9 1499 * @playerversion AIR 1.1 1500 * @productversion Flex 3 1501 */ 1502 public static const DEFAULT_MAX_WIDTH:Number = 10000; 1503 // When changing this constant, make sure you change 1504 // the constant with the same name in LayoutElementUIComponentUtils 1505 1506 /** 1507 * The default value for the <code>maxHeight</code> property. 1508 * 1509 * @default 10000 1510 * 1511 * @langversion 3.0 1512 * @playerversion Flash 9 1513 * @playerversion AIR 1.1 1514 * @productversion Flex 3 1515 */ 1516 public static const DEFAULT_MAX_HEIGHT:Number = 10000; 1517 // When changing this constant, make sure you change 1518 // the constant with the same name in LayoutElementUIComponentUtils 1519 1520 /** 1521 * @private 1522 * Static constant representing no cached layout direction style value. 1523 */ 1524 private static const LAYOUT_DIRECTION_CACHE_UNSET:String = "layoutDirectionCacheUnset"; 1525 1526 1527 //-------------------------------------------------------------------------- 1528 // 1529 // Class mixins 1530 // 1531 //-------------------------------------------------------------------------- 1532 1533 /** 1534 * @private 1535 * Placeholder for mixin by UIComponentAccProps. 1536 */ 1537 mx_internal static var createAccessibilityImplementation:Function; 1538 1539 //-------------------------------------------------------------------------- 1540 // 1541 // Class properties 1542 // 1543 //-------------------------------------------------------------------------- 1544 1545 //---------------------------------- 1546 // embeddedFontRegistry 1547 //---------------------------------- 1548 1549 private static var noEmbeddedFonts:Boolean; 1550 1551 /** 1552 * @private 1553 * Storage for the _embeddedFontRegistry property. 1554 * Note: This gets initialized on first access, 1555 * not when this class is initialized, in order to ensure 1556 * that the Singleton registry has already been initialized. 1557 */ 1558 private static var _embeddedFontRegistry:IEmbeddedFontRegistry; 1559 1560 /** 1561 * @private 1562 * A reference to the embedded font registry. 1563 * Single registry in the system. 1564 * Used to look up the moduleFactory of a font. 1565 */ 1566 mx_internal static function get embeddedFontRegistry():IEmbeddedFontRegistry 1567 { 1568 if (!_embeddedFontRegistry && !noEmbeddedFonts) 1569 { 1570 try 1571 { 1572 _embeddedFontRegistry = IEmbeddedFontRegistry( 1573 Singleton.getInstance("mx.core::IEmbeddedFontRegistry")); 1574 } 1575 catch (e:Error) 1576 { 1577 noEmbeddedFonts = true; 1578 } 1579 } 1580 1581 return _embeddedFontRegistry; 1582 } 1583 1584 //-------------------------------------------------------------------------- 1585 // 1586 // Class methods 1587 // 1588 //-------------------------------------------------------------------------- 1589 1590 /** 1591 * Blocks the background processing of methods 1592 * queued by <code>callLater()</code>, 1593 * until <code>resumeBackgroundProcessing()</code> is called. 1594 * 1595 * <p>These methods can be useful when you have time-critical code 1596 * which needs to execute without interruption. 1597 * For example, when you set the <code>suspendBackgroundProcessing</code> 1598 * property of an Effect to <code>true</code>, 1599 * <code>suspendBackgroundProcessing()</code> is automatically called 1600 * when it starts playing, and <code>resumeBackgroundProcessing</code> 1601 * is called when it stops, in order to ensure that the animation 1602 * is smooth.</p> 1603 * 1604 * <p>Since the LayoutManager uses <code>callLater()</code>, 1605 * this means that <code>commitProperties()</code>, 1606 * <code>measure()</code>, and <code>updateDisplayList()</code> 1607 * is not called in between calls to 1608 * <code>suspendBackgroundProcessing()</code> and 1609 * <code>resumeBackgroundProcessing()</code>.</p> 1610 * 1611 * <p>It is safe for both an outer method and an inner method 1612 * (i.e., one that the outer methods calls) to call 1613 * <code>suspendBackgroundProcessing()</code> 1614 * and <code>resumeBackgroundProcessing()</code>, because these 1615 * methods actually increment and decrement a counter 1616 * which determines whether background processing occurs.</p> 1617 * 1618 * @langversion 3.0 1619 * @playerversion Flash 9 1620 * @playerversion AIR 1.1 1621 * @productversion Flex 3 1622 */ 1623 public static function suspendBackgroundProcessing():void 1624 { 1625 UIComponentGlobals.callLaterSuspendCount++; 1626 } 1627 1628 /** 1629 * Resumes the background processing of methods 1630 * queued by <code>callLater()</code>, after a call to 1631 * <code>suspendBackgroundProcessing()</code>. 1632 * 1633 * <p>Refer to the description of 1634 * <code>suspendBackgroundProcessing()</code> for more information.</p> 1635 * 1636 * @langversion 3.0 1637 * @playerversion Flash 9 1638 * @playerversion AIR 1.1 1639 * @productversion Flex 3 1640 */ 1641 public static function resumeBackgroundProcessing():void 1642 { 1643 if (UIComponentGlobals.callLaterSuspendCount > 0) 1644 { 1645 UIComponentGlobals.callLaterSuspendCount--; 1646 1647 // Once the suspend count gets back to 0, we need to 1648 // force a render event to happen 1649 if (UIComponentGlobals.callLaterSuspendCount == 0) 1650 { 1651 var sm:ISystemManager = SystemManagerGlobals.topLevelSystemManagers[0]; 1652 if (sm && sm.stage) 1653 sm.stage.invalidate(); 1654 } 1655 } 1656 } 1657 1658 //-------------------------------------------------------------------------- 1659 // 1660 // Constructor 1661 // 1662 //-------------------------------------------------------------------------- 1663 1664 /** 1665 * Constructor. 1666 * 1667 * @langversion 3.0 1668 * @playerversion Flash 9 1669 * @playerversion AIR 1.1 1670 * @productversion Flex 3 1671 */ 1672 public function UIComponent() 1673 { 1674 super(); 1675 1676 // Override variables in superclasses. 1677 focusRect = false; // We do our own focus drawing. 1678 // We are tab enabled by default if IFocusManagerComponent 1679 tabEnabled = (this is IFocusManagerComponent); 1680 tabFocusEnabled = (this is IFocusManagerComponent); 1681 1682 // Whether the component can accept user interaction. 1683 // The default is true. If you set enabled to false for a container, 1684 // Flex dims the color of the container and of all of its children, 1685 // and blocks user input to the container and to all of its children. 1686 // We set enabled to true here because some components keep their 1687 // own _enabled flag and may not initialize it to true. 1688 enabled = true; 1689 1690 // Make the component invisible until the initialization sequence 1691 // is complete. 1692 // It will be set visible when the 'initialized' flag is set. 1693 $visible = false; 1694 1695 addEventListener(Event.ADDED, addedHandler); 1696 addEventListener(Event.REMOVED, removedHandler); 1697 addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler); 1698 1699 // Register for focus and keyboard events. 1700 if (this is IFocusManagerComponent) 1701 { 1702 addEventListener(FocusEvent.FOCUS_IN, focusInHandler); 1703 addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler); 1704 addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler); 1705 addEventListener(KeyboardEvent.KEY_UP, keyUpHandler); 1706 } 1707 1708 resourcesChanged(); 1709 1710 // Register as a weak listener for "change" events from ResourceManager. 1711 // If UIComponents registered as a strong listener, 1712 // they wouldn't get garbage collected. 1713 resourceManager.addEventListener( 1714 Event.CHANGE, resourceManager_changeHandler, false, 0, true); 1715 1716 _width = super.width; 1717 _height = super.height; 1718 } 1719 1720 //-------------------------------------------------------------------------- 1721 // 1722 // Variables 1723 // 1724 //-------------------------------------------------------------------------- 1725 1726 /** 1727 * @private 1728 * Temporarily stores the values of styles specified with setStyle() until 1729 * moduleFactory is set. 1730 */ 1731 private var deferredSetStyles:Object; 1732 1733 /** 1734 * @private 1735 * There is a bug (139381) where we occasionally get callLaterDispatcher() 1736 * even though we didn't expect it. 1737 * That causes us to do a removeEventListener() twice, 1738 * which messes up some internal thing in the player so that 1739 * the next addEventListener() doesn't actually get us the render event. 1740 */ 1741 private var listeningForRender:Boolean = false; 1742 1743 /** 1744 * @private 1745 * List of methods used by callLater(). 1746 */ 1747 private var methodQueue:Array /* of MethodQueueElement */ = []; 1748 1749 /** 1750 * @private 1751 * Whether or not we "own" the focus graphic 1752 */ 1753 private var hasFocusRect:Boolean = false; 1754 1755 /** 1756 * @private 1757 * These variables cache the transition state from/to information for 1758 * the transition currently running. This information is used when 1759 * determining what to do with a new transition that interrupts the 1760 * running transition. 1761 */ 1762 private var transitionFromState:String; 1763 private var transitionToState:String; 1764 1765 /** 1766 * @private 1767 */ 1768 private var parentChangedFlag:Boolean = false; 1769 1770 /** 1771 * @private 1772 * Cached layout direction style 1773 */ 1774 private var layoutDirectionCachedValue:String = LAYOUT_DIRECTION_CACHE_UNSET; 1775 1776 //-------------------------------------------------------------------------- 1777 // 1778 // Variables: Creation 1779 // 1780 //-------------------------------------------------------------------------- 1781 1782 //---------------------------------- 1783 // initialized 1784 //---------------------------------- 1785 1786 /** 1787 * @private 1788 * Storage for the initialized property. 1789 */ 1790 private var _initialized:Boolean = false; 1791 1792 [Inspectable(environment="none")] 1793 1794 /** 1795 * A flag that determines if an object has been through all three phases 1796 * of layout: commitment, measurement, and layout (provided that any were required). 1797 * 1798 * @langversion 3.0 1799 * @playerversion Flash 9 1800 * @playerversion AIR 1.1 1801 * @productversion Flex 3 1802 */ 1803 public function get initialized():Boolean 1804 { 1805 return _initialized; 1806 } 1807 1808 /** 1809 * @private 1810 */ 1811 public function set initialized(value:Boolean):void 1812 { 1813 _initialized = value; 1814 1815 if (value) 1816 { 1817 setVisible(_visible, true); 1818 dispatchEvent(new FlexEvent(FlexEvent.CREATION_COMPLETE)); 1819 } 1820 } 1821 1822 //---------------------------------- 1823 // processedDescriptors 1824 //---------------------------------- 1825 1826 /** 1827 * @private 1828 * Storage for the processedDescriptors property. 1829 */ 1830 private var _processedDescriptors:Boolean = false; 1831 1832 [Inspectable(environment="none")] 1833 1834 /** 1835 * Set to <code>true</code> after immediate or deferred child creation, 1836 * depending on which one happens. For a Container object, it is set 1837 * to <code>true</code> at the end of 1838 * the <code>createComponentsFromDescriptors()</code> method, 1839 * meaning after the Container object creates its children from its child descriptors. 1840 * 1841 * <p>For example, if an Accordion container uses deferred instantiation, 1842 * the <code>processedDescriptors</code> property for the second pane of 1843 * the Accordion container does not become <code>true</code> until after 1844 * the user navigates to that pane and the pane creates its children. 1845 * But, if the Accordion had set the <code>creationPolicy</code> property 1846 * to <code>"all"</code>, the <code>processedDescriptors</code> property 1847 * for its second pane is set to <code>true</code> during application startup.</p> 1848 * 1849 * <p>For classes that are not containers, which do not have descriptors, 1850 * it is set to <code>true</code> after the <code>createChildren()</code> 1851 * method creates any internal component children.</p> 1852 * 1853 * @langversion 3.0 1854 * @playerversion Flash 9 1855 * @playerversion AIR 1.1 1856 * @productversion Flex 3 1857 */ 1858 public function get processedDescriptors():Boolean 1859 { 1860 return _processedDescriptors; 1861 } 1862 1863 /** 1864 * @private 1865 */ 1866 public function set processedDescriptors(value:Boolean):void 1867 { 1868 _processedDescriptors = value; 1869 1870 if (value) 1871 dispatchEvent(new FlexEvent(FlexEvent.INITIALIZE)); 1872 } 1873 1874 //---------------------------------- 1875 // updateCompletePendingFlag 1876 //---------------------------------- 1877 1878 /** 1879 * @private 1880 * Storage for the updateCompletePendingFlag property. 1881 */ 1882 private var _updateCompletePendingFlag:Boolean = false; 1883 1884 [Inspectable(environment="none")] 1885 1886 /** 1887 * A flag that determines if an object has been through all three phases 1888 * of layout validation (provided that any were required). 1889 * 1890 * @langversion 3.0 1891 * @playerversion Flash 9 1892 * @playerversion AIR 1.1 1893 * @productversion Flex 3 1894 */ 1895 public function get updateCompletePendingFlag():Boolean 1896 { 1897 return _updateCompletePendingFlag; 1898 } 1899 1900 /** 1901 * @private 1902 */ 1903 public function set updateCompletePendingFlag(value:Boolean):void 1904 { 1905 _updateCompletePendingFlag = value; 1906 } 1907 1908 //------------------------------------------------------------------------ 1909 // 1910 // Properties: Accessibility 1911 // 1912 //------------------------------------------------------------------------ 1913 1914 /** 1915 * A convenience accessor for the <code>silent</code> property 1916 * in this UIComponent's <code>accessibilityProperties</code> object. 1917 * 1918 * <p>Note that <code>accessibilityEnabled</code> has the opposite sense from silent; 1919 * <code>accessibilityEnabled</code> is <code>true</code> 1920 * when <code>silent</code> is <code>false</code>.</p> 1921 * 1922 * <p>The getter simply returns <code>accessibilityProperties.silent</code>, 1923 * or <code>true</code> if <code>accessibilityProperties</code> is null. 1924 * The setter first checks whether <code>accessibilityProperties</code> is null, 1925 * and if it is, sets it to a new AccessibilityProperties instance. 1926 * Then it sets <code>accessibilityProperties.silent</code>.</p> 1927 * 1928 * @langversion 3.0 1929 * @playerversion Flash 9 1930 * @playerversion AIR 1.1 1931 * @productversion Flex 3 1932 */ 1933 public function get accessibilityEnabled():Boolean 1934 { 1935 return accessibilityProperties ? !accessibilityProperties.silent : true; 1936 } 1937 1938 public function set accessibilityEnabled(value:Boolean):void 1939 { 1940 if (!Capabilities.hasAccessibility) 1941 return; 1942 1943 if (!accessibilityProperties) 1944 accessibilityProperties = new AccessibilityProperties(); 1945 1946 accessibilityProperties.silent = !value; 1947 Accessibility.updateProperties(); 1948 } 1949 1950 /** 1951 * A convenience accessor for the <code>name</code> property 1952 * in this UIComponent's <code>accessibilityProperties</code> object. 1953 * 1954 * <p>The getter simply returns <code>accessibilityProperties.name</code>, 1955 * or "" if accessibilityProperties is null. 1956 * The setter first checks whether <code>accessibilityProperties</code> is null, 1957 * and if it is, sets it to a new AccessibilityProperties instance. 1958 * Then it sets <code>accessibilityProperties.name</code>.</p> 1959 * 1960 * @langversion 3.0 1961 * @playerversion Flash 9 1962 * @playerversion AIR 1.1 1963 * @productversion Flex 3 1964 */ 1965 public function get accessibilityName():String 1966 { 1967 return accessibilityProperties ? accessibilityProperties.name : ""; 1968 } 1969 1970 public function set accessibilityName(value:String):void 1971 { 1972 if (!Capabilities.hasAccessibility) 1973 return; 1974 1975 if (!accessibilityProperties) 1976 accessibilityProperties = new AccessibilityProperties(); 1977 1978 accessibilityProperties.name = value; 1979 Accessibility.updateProperties(); 1980 } 1981 1982 /** 1983 * A convenience accessor for the <code>description</code> property 1984 * in this UIComponent's <code>accessibilityProperties</code> object. 1985 * 1986 * <p>The getter simply returns <code>accessibilityProperties.description</code>, 1987 * or "" if <code>accessibilityProperties</code> is null. 1988 * The setter first checks whether <code>accessibilityProperties</code> is null, 1989 * and if it is, sets it to a new AccessibilityProperties instance. 1990 * Then it sets <code>accessibilityProperties.description</code>.</p> 1991 * 1992 * @langversion 3.0 1993 * @playerversion Flash 9 1994 * @playerversion AIR 1.1 1995 * @productversion Flex 3 1996 */ 1997 public function get accessibilityDescription():String 1998 { 1999 return accessibilityProperties ? accessibilityProperties.description : ""; 2000 } 2001 2002 public function set accessibilityDescription(value:String):void 2003 { 2004 if (!Capabilities.hasAccessibility) 2005 return; 2006 2007 if (!accessibilityProperties) 2008 accessibilityProperties = new AccessibilityProperties(); 2009 2010 accessibilityProperties.description = value; 2011 Accessibility.updateProperties(); 2012 } 2013 2014 /** 2015 * A convenience accessor for the <code>shortcut</code> property 2016 * in this UIComponent's <code>accessibilityProperties</code> object. 2017 * 2018 * <p>The getter simply returns <code>accessibilityProperties.shortcut</code>, 2019 * or "" if <code>accessibilityProperties</code> is null. 2020 * The setter first checks whether <code>accessibilityProperties</code> is null, 2021 * and if it is, sets it to a new AccessibilityProperties instance. 2022 * Then it sets <code>accessibilityProperties.shortcut</code>.</p> 2023 * 2024 * @langversion 3.0 2025 * @playerversion Flash 9 2026 * @playerversion AIR 1.1 2027 * @productversion Flex 3 2028 */ 2029 public function get accessibilityShortcut():String 2030 { 2031 return accessibilityProperties ? accessibilityProperties.shortcut : ""; 2032 } 2033 2034 public function set accessibilityShortcut(value:String):void 2035 { 2036 if (!Capabilities.hasAccessibility) 2037 return; 2038 2039 if (!accessibilityProperties) 2040 accessibilityProperties = new AccessibilityProperties(); 2041 2042 accessibilityProperties.shortcut = value; 2043 Accessibility.updateProperties(); 2044 } 2045 2046 //-------------------------------------------------------------------------- 2047 // 2048 // Variables: Invalidation 2049 // 2050 //-------------------------------------------------------------------------- 2051 2052 /** 2053 * @private 2054 * Whether this component needs to have its 2055 * commitProperties() method called. 2056 */ 2057 mx_internal var invalidatePropertiesFlag:Boolean = false; 2058 2059 /** 2060 * @private 2061 * Whether this component needs to have its 2062 * measure() method called. 2063 */ 2064 mx_internal var invalidateSizeFlag:Boolean = false; 2065 2066 /** 2067 * @private 2068 * Whether this component needs to be have its 2069 * updateDisplayList() method called. 2070 */ 2071 mx_internal var invalidateDisplayListFlag:Boolean = false; 2072 2073 /** 2074 * @private 2075 * Whether setActualSize() has been called on this component 2076 * at least once. This is used in validateBaselinePosition() 2077 * to resize the component to explicit or measured 2078 * size if baselinePosition getter is called before the 2079 * component has been resized by the layout. 2080 */ 2081 mx_internal var setActualSizeCalled:Boolean = false; 2082 2083 //-------------------------------------------------------------------------- 2084 // 2085 // Variables: Measurement 2086 // 2087 //-------------------------------------------------------------------------- 2088 2089 /** 2090 * @private 2091 * Holds the last recorded value of the x property. 2092 * Used in dispatching a MoveEvent. 2093 */ 2094 private var oldX:Number = 0; 2095 2096 /** 2097 * @private 2098 * Holds the last recorded value of the y property. 2099 * Used in dispatching a MoveEvent. 2100 */ 2101 private var oldY:Number = 0; 2102 2103 /** 2104 * @private 2105 * Holds the last recorded value of the width property. 2106 * Used in dispatching a ResizeEvent. 2107 */ 2108 private var oldWidth:Number = 0; 2109 2110 /** 2111 * @private 2112 * Holds the last recorded value of the height property. 2113 * Used in dispatching a ResizeEvent. 2114 */ 2115 private var oldHeight:Number = 0; 2116 2117 /** 2118 * @private 2119 * Holds the last recorded value of the minWidth property. 2120 */ 2121 private var oldMinWidth:Number; 2122 2123 /** 2124 * @private 2125 * Holds the last recorded value of the minHeight property. 2126 */ 2127 private var oldMinHeight:Number; 2128 2129 /** 2130 * @private 2131 * Holds the last recorded value of the explicitWidth property. 2132 */ 2133 private var oldExplicitWidth:Number; 2134 2135 /** 2136 * @private 2137 * Holds the last recorded value of the explicitHeight property. 2138 */ 2139 private var oldExplicitHeight:Number; 2140 2141 /** 2142 * @private 2143 * Holds the last recorded value of the scaleX property. 2144 */ 2145 private var oldScaleX:Number = 1.0; 2146 2147 /** 2148 * @private 2149 * Holds the last recorded value of the scaleY property. 2150 */ 2151 private var oldScaleY:Number = 1.0; 2152 2153 /** 2154 * @private 2155 * True if createInFontContext has been called. 2156 */ 2157 private var hasFontContextBeenSaved:Boolean = false; 2158 2159 /** 2160 * @private 2161 * Holds the last recorded value of the module factory used to create the font. 2162 */ 2163 private var oldEmbeddedFontContext:IFlexModuleFactory = null; 2164 2165 /** 2166 * @private 2167 * 2168 * storage for advanced layout and transform properties. 2169 */ 2170 mx_internal var _layoutFeatures:AdvancedLayoutFeatures; 2171 2172 /** 2173 * @private 2174 * 2175 * storage for the modified Transform object that can dispatch change events correctly. 2176 */ 2177 private var _transform:flash.geom.Transform; 2178 //-------------------------------------------------------------------------- 2179 // 2180 // Variables: Styles 2181 // 2182 //-------------------------------------------------------------------------- 2183 2184 /** 2185 * @private 2186 */ 2187 private var cachedTextFormat:UITextFormat; 2188 2189 //-------------------------------------------------------------------------- 2190 // 2191 // Variables: Effects 2192 // 2193 //-------------------------------------------------------------------------- 2194 2195 /** 2196 * @private 2197 * Sprite used to display an overlay. 2198 */ 2199 mx_internal var effectOverlay:UIComponent; 2200 2201 /** 2202 * @private 2203 * Color used for overlay. 2204 */ 2205 mx_internal var effectOverlayColor:uint; 2206 2207 /** 2208 * @private 2209 * Counter to keep track of the number of current users 2210 * of the overlay. 2211 */ 2212 mx_internal var effectOverlayReferenceCount:int = 0; 2213 2214 //-------------------------------------------------------------------------- 2215 // 2216 // Variables: Validation 2217 // 2218 //-------------------------------------------------------------------------- 2219 2220 /** 2221 * @private 2222 */ 2223 mx_internal var saveBorderColor:Boolean = true; 2224 2225 /** 2226 * @private 2227 */ 2228 mx_internal var origBorderColor:Number; 2229 2230 //-------------------------------------------------------------------------- 2231 // 2232 // Variables: Other 2233 // 2234 //-------------------------------------------------------------------------- 2235 2236 /** 2237 * @private 2238 * Storage for automatically-created RadioButtonGroups. 2239 * If a RadioButton's groupName isn't the id of a RadioButtonGroup tag, 2240 * we automatically create a RadioButtonGroup and store it here as 2241 * document.automaticRadioButtonGroups[groupName] = theRadioButtonGroup; 2242 */ 2243 mx_internal var automaticRadioButtonGroups:Object; 2244 2245 private var _usingBridge:int = -1; 2246 2247 /** 2248 * @private 2249 */ 2250 private function get usingBridge():Boolean 2251 { 2252 if (_usingBridge == 0) return false; 2253 if (_usingBridge == 1) return true; 2254 2255 if (!_systemManager) return false; 2256 2257 // no types so no dependencies 2258 var mp:Object = _systemManager.getImplementation("mx.managers::IMarshalSystemManager"); 2259 if (!mp) 2260 { 2261 _usingBridge = 0; 2262 return false; 2263 } 2264 if (mp.useSWFBridge()) 2265 { 2266 _usingBridge = 1; 2267 return true; 2268 } 2269 _usingBridge = 0; 2270 return false; 2271 } 2272 2273 //-------------------------------------------------------------------------- 2274 // 2275 // Overridden properties 2276 // 2277 //-------------------------------------------------------------------------- 2278 2279 //---------------------------------- 2280 // owner 2281 //---------------------------------- 2282 2283 /** 2284 * @private 2285 */ 2286 mx_internal var _owner:DisplayObjectContainer; 2287 2288 /** 2289 * @copy mx.core.IVisualElement#owner 2290 * 2291 * @langversion 3.0 2292 * @playerversion Flash 9 2293 * @playerversion AIR 1.1 2294 * @productversion Flex 3 2295 */ 2296 public function get owner():DisplayObjectContainer 2297 { 2298 return _owner ? _owner : parent; 2299 } 2300 2301 public function set owner(value:DisplayObjectContainer):void 2302 { 2303 _owner = value; 2304 } 2305 2306 //---------------------------------- 2307 // parent 2308 //---------------------------------- 2309 2310 /** 2311 * @private 2312 * Reference to this component's virtual parent container. 2313 * "Virtual" means that this parent may not be the same 2314 * as the one that the Player returns as the 'parent' 2315 * property of a DisplayObject. 2316 * For example, if a Container has created a contentPane 2317 * to improve scrolling performance, 2318 * then its "children" are really its grandchildren 2319 * and their "parent" is actually their grandparent, 2320 * because we don't want developers to be concerned with 2321 * whether a contentPane exists or not. 2322 */ 2323 mx_internal var _parent:DisplayObjectContainer; 2324 2325 /** 2326 * @copy mx.core.IVisualElement#parent 2327 * 2328 * @langversion 3.0 2329 * @playerversion Flash 9 2330 * @playerversion AIR 1.1 2331 * @productversion Flex 3 2332 */ 2333 override public function get parent():DisplayObjectContainer 2334 { 2335 // Flash PlaceObject tags can have super.parent set 2336 // before we get to setting the _parent property. 2337 try 2338 { 2339 return _parent ? _parent : super.parent; 2340 } 2341 catch (e:SecurityError) 2342 { 2343 // trace("UIComponent.get parent(): " + e); 2344 } 2345 2346 return null; 2347 } 2348 2349 //---------------------------------- 2350 // x 2351 //---------------------------------- 2352 2353 [Bindable("xChanged")] 2354 [Inspectable(category="General")] 2355 2356 /** 2357 * Number that specifies the component's horizontal position, 2358 * in pixels, within its parent container. 2359 * 2360 * <p>Setting this property directly or calling <code>move()</code> 2361 * has no effect -- or only a temporary effect -- if the 2362 * component is parented by a layout container such as HBox, Grid, 2363 * or Form, because the layout calculations of those containers 2364 * set the <code>x</code> position to the results of the calculation. 2365 * However, the <code>x</code> property must almost always be set 2366 * when the parent is a Canvas or other absolute-positioning 2367 * container because the default value is 0.</p> 2368 * 2369 * @default 0 2370 * 2371 * @langversion 3.0 2372 * @playerversion Flash 9 2373 * @playerversion AIR 1.1 2374 * @productversion Flex 3 2375 */ 2376 override public function get x():Number 2377 { 2378 return (_layoutFeatures == null) ? super.x : _layoutFeatures.layoutX; 2379 } 2380 2381 /** 2382 * @private 2383 */ 2384 override public function set x(value:Number):void 2385 { 2386 if (x == value) 2387 return; 2388 2389 if (_layoutFeatures == null) 2390 { 2391 super.x = value; 2392 } 2393 else 2394 { 2395 _layoutFeatures.layoutX = value; 2396 invalidateTransform(); 2397 } 2398 2399 invalidateProperties(); 2400 2401 if (parent && parent is UIComponent) 2402 UIComponent(parent).childXYChanged(); 2403 2404 if (hasEventListener("xChanged")) 2405 dispatchEvent(new Event("xChanged")); 2406 } 2407 2408 [Bindable("zChanged")] 2409 [Inspectable(category="General")] 2410 2411 /** 2412 * @inheritDoc 2413 * 2414 * @langversion 3.0 2415 * @playerversion Flash 10 2416 * @playerversion AIR 1.5 2417 * @productversion Flex 3 2418 */ 2419 override public function get z():Number 2420 { 2421 return (_layoutFeatures == null) ? super.z : _layoutFeatures.layoutZ; 2422 } 2423 2424 /** 2425 * @private 2426 */ 2427 override public function set z(value:Number):void 2428 { 2429 if (z == value) 2430 return; 2431 2432 // validateMatrix when switching between 2D/3D, works around player bug 2433 // see sdk-23421 2434 var was3D:Boolean = is3D; 2435 if (_layoutFeatures == null) 2436 initAdvancedLayoutFeatures(); 2437 2438 _layoutFeatures.layoutZ = value; 2439 invalidateTransform(); 2440 invalidateProperties(); 2441 if (was3D != is3D) 2442 validateMatrix(); 2443 2444 if (hasEventListener("zChanged")) 2445 dispatchEvent(new Event("zChanged")); 2446 } 2447 2448 /** 2449 * Sets the x coordinate for the transform center of the component. 2450 * 2451 * <p>When this component is the target of a Spark transform effect, 2452 * you can override this property by setting 2453 * the <code>AnimateTransform.autoCenterTransform</code> property. 2454 * If <code>autoCenterTransform</code> is <code>false</code>, the transform 2455 * center is determined by the <code>transformX</code>, 2456 * <code>transformY</code>, and <code>transformZ</code> properties 2457 * of the effect target. 2458 * If <code>autoCenterTransform</code> is <code>true</code>, 2459 * the effect occurs around the center of the target, 2460 * <code>(width/2, height/2)</code>.</p> 2461 * 2462 * <p>Setting this property on the Spark effect class 2463 * overrides the setting on the target component.</p> 2464 * 2465 * @see spark.effects.AnimateTransform#autoCenterTransform 2466 * @see spark.effects.AnimateTransform#transformX 2467 * 2468 * @langversion 3.0 2469 * @playerversion Flash 9 2470 * @playerversion AIR 1.1 2471 * @productversion Flex 3 2472 */ 2473 public function get transformX():Number 2474 { 2475 return (_layoutFeatures == null) ? 0 : _layoutFeatures.transformX; 2476 } 2477 2478 /** 2479 * @private 2480 */ 2481 public function set transformX(value:Number):void 2482 { 2483 if (transformX == value) 2484 return; 2485 if (_layoutFeatures == null) 2486 initAdvancedLayoutFeatures(); 2487 _layoutFeatures.transformX = value; 2488 invalidateTransform(); 2489 invalidateProperties(); 2490 invalidateParentSizeAndDisplayList(); 2491 } 2492 2493 /** 2494 * Sets the y coordinate for the transform center of the component. 2495 * 2496 * <p>When this component is the target of a Spark transform effect, 2497 * you can override this property by setting 2498 * the <code>AnimateTransform.autoCenterTransform</code> property. 2499 * If <code>autoCenterTransform</code> is <code>false</code>, the transform 2500 * center is determined by the <code>transformX</code>, 2501 * <code>transformY</code>, and <code>transformZ</code> properties 2502 * of the effect target. 2503 * If <code>autoCenterTransform</code> is <code>true</code>, 2504 * the effect occurs around the center of the target, 2505 * <code>(width/2, height/2)</code>.</p> 2506 * 2507 * <p>Seeting this property on the Spark effect class 2508 * overrides the setting on the target component.</p> 2509 * 2510 * @see spark.effects.AnimateTransform#autoCenterTransform 2511 * @see spark.effects.AnimateTransform#transformY 2512 * 2513 * @langversion 3.0 2514 * @playerversion Flash 9 2515 * @playerversion AIR 1.1 2516 * @productversion Flex 3 2517 */ 2518 public function get transformY():Number 2519 { 2520 return (_layoutFeatures == null) ? 0 : _layoutFeatures.transformY; 2521 } 2522 2523 /** 2524 * @private 2525 */ 2526 public function set transformY(value:Number):void 2527 { 2528 if (transformY == value) 2529 return; 2530 if (_layoutFeatures == null) 2531 initAdvancedLayoutFeatures(); 2532 _layoutFeatures.transformY = value; 2533 invalidateTransform(); 2534 invalidateProperties(); 2535 invalidateParentSizeAndDisplayList(); 2536 } 2537 2538 /** 2539 * Sets the z coordinate for the transform center of the component. 2540 * 2541 * <p>When this component is the target of a Spark transform effect, 2542 * you can override this property by setting 2543 * the <code>AnimateTransform.autoCenterTransform</code> property. 2544 * If <code>autoCenterTransform</code> is <code>false</code>, the transform 2545 * center is determined by the <code>transformX</code>, 2546 * <code>transformY</code>, and <code>transformZ</code> properties 2547 * of the effect target. 2548 * If <code>autoCenterTransform</code> is <code>true</code>, 2549 * the effect occurs around the center of the target, 2550 * <code>(width/2, height/2)</code>.</p> 2551 * 2552 * <p>Seeting this property on the Spark effect class 2553 * overrides the setting on the target component.</p> 2554 * 2555 * @see spark.effects.AnimateTransform#autoCenterTransform 2556 * @see spark.effects.AnimateTransform#transformZ 2557 * 2558 * @langversion 3.0 2559 * @playerversion Flash 9 2560 * @playerversion AIR 1.1 2561 * @productversion Flex 3 2562 */ 2563 public function get transformZ():Number 2564 { 2565 return (_layoutFeatures == null) ? 0 : _layoutFeatures.transformZ; 2566 } 2567 /** 2568 * @private 2569 */ 2570 public function set transformZ(value:Number):void 2571 { 2572 if (transformZ == value) 2573 return; 2574 if (_layoutFeatures == null) 2575 initAdvancedLayoutFeatures(); 2576 2577 _layoutFeatures.transformZ = value; 2578 invalidateTransform(); 2579 invalidateProperties(); 2580 invalidateParentSizeAndDisplayList(); 2581 } 2582 2583 /** 2584 * @copy mx.core.IFlexDisplayObject#rotation 2585 * 2586 * @langversion 3.0 2587 * @playerversion Flash 9 2588 * @playerversion AIR 1.1 2589 * @productversion Flex 3 2590 */ 2591 override public function get rotation():Number 2592 { 2593 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 2594 return super.rotation; 2595 return (_layoutFeatures == null) ? super.rotation : _layoutFeatures.layoutRotationZ; 2596 } 2597 2598 /** 2599 * @private 2600 */ 2601 override public function set rotation(value:Number):void 2602 { 2603 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 2604 { 2605 super.rotation = value; 2606 return; 2607 } 2608 2609 if (rotation == value) 2610 return; 2611 2612 _hasComplexLayoutMatrix = true; 2613 if (_layoutFeatures == null) 2614 { 2615 // clamp the rotation value between -180 and 180. This is what 2616 // the Flash player does and what we mimic in CompoundTransform; 2617 // however, the Flash player doesn't handle values larger than 2618 // 2^15 - 1 (FP-749), so we need to clamp even when we're 2619 // just setting super.rotation. 2620 super.rotation = MatrixUtil.clampRotation(value); 2621 } 2622 else 2623 { 2624 _layoutFeatures.layoutRotationZ = value; 2625 } 2626 2627 invalidateTransform(); 2628 invalidateProperties(); 2629 invalidateParentSizeAndDisplayList(); 2630 } 2631 2632 /** 2633 * @inheritDoc 2634 * 2635 * @langversion 3.0 2636 * @playerversion Flash 9 2637 * @playerversion AIR 1.1 2638 * @productversion Flex 3 2639 */ 2640 override public function get rotationZ():Number 2641 { 2642 return rotation; 2643 } 2644 /** 2645 * @private 2646 */ 2647 override public function set rotationZ(value:Number):void 2648 { 2649 rotation = value; 2650 } 2651 2652 /** 2653 * Indicates the x-axis rotation of the DisplayObject instance, in degrees, from its original orientation 2654 * relative to the 3D parent container. Values from 0 to 180 represent clockwise rotation; values 2655 * from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted from 2656 * 360 to obtain a value within the range. 2657 * 2658 * This property is ignored during calculation by any of Flex's 2D layouts. 2659 * 2660 * @langversion 3.0 2661 * @playerversion Flash 10 2662 * @playerversion AIR 1.5 2663 * @productversion Flex 3 2664 */ 2665 override public function get rotationX():Number 2666 { 2667 return (_layoutFeatures == null) ? super.rotationX : _layoutFeatures.layoutRotationX; 2668 } 2669 2670 /** 2671 * @private 2672 */ 2673 override public function set rotationX(value:Number):void 2674 { 2675 if (rotationX == value) 2676 return; 2677 2678 // validateMatrix when switching between 2D/3D, works around player bug 2679 // see sdk-23421 2680 var was3D:Boolean = is3D; 2681 if (_layoutFeatures == null) 2682 initAdvancedLayoutFeatures(); 2683 _layoutFeatures.layoutRotationX = value; 2684 invalidateTransform(); 2685 invalidateProperties(); 2686 invalidateParentSizeAndDisplayList(); 2687 if (was3D != is3D) 2688 validateMatrix(); 2689 } 2690 2691 /** 2692 * Indicates the y-axis rotation of the DisplayObject instance, in degrees, from its original orientation 2693 * relative to the 3D parent container. Values from 0 to 180 represent clockwise rotation; values 2694 * from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted from 2695 * 360 to obtain a value within the range. 2696 * 2697 * This property is ignored during calculation by any of Flex's 2D layouts. 2698 * 2699 * @langversion 3.0 2700 * @playerversion Flash 9 2701 * @playerversion AIR 1.1 2702 * @productversion Flex 3 2703 */ 2704 override public function get rotationY():Number 2705 { 2706 return (_layoutFeatures == null) ? super.rotationY : _layoutFeatures.layoutRotationY; 2707 } 2708 2709 /** 2710 * @private 2711 */ 2712 override public function set rotationY(value:Number):void 2713 { 2714 if (rotationY == value) 2715 return; 2716 2717 // validateMatrix when switching between 2D/3D, works around player bug 2718 // see sdk-23421 2719 var was3D:Boolean = is3D; 2720 if (_layoutFeatures == null) 2721 initAdvancedLayoutFeatures(); 2722 _layoutFeatures.layoutRotationY = value; 2723 invalidateTransform(); 2724 invalidateProperties(); 2725 invalidateParentSizeAndDisplayList(); 2726 if (was3D != is3D) 2727 validateMatrix(); 2728 } 2729 2730 //---------------------------------- 2731 // y 2732 //---------------------------------- 2733 2734 [Bindable("yChanged")] 2735 [Inspectable(category="General")] 2736 2737 /** 2738 * Number that specifies the component's vertical position, 2739 * in pixels, within its parent container. 2740 * 2741 * <p>Setting this property directly or calling <code>move()</code> 2742 * has no effect -- or only a temporary effect -- if the 2743 * component is parented by a layout container such as HBox, Grid, 2744 * or Form, because the layout calculations of those containers 2745 * set the <code>x</code> position to the results of the calculation. 2746 * However, the <code>x</code> property must almost always be set 2747 * when the parent is a Canvas or other absolute-positioning 2748 * container because the default value is 0.</p> 2749 * 2750 * @default 0 2751 * 2752 * @langversion 3.0 2753 * @playerversion Flash 9 2754 * @playerversion AIR 1.1 2755 * @productversion Flex 3 2756 */ 2757 override public function get y():Number 2758 { 2759 return (_layoutFeatures == null) ? super.y : _layoutFeatures.layoutY; 2760 } 2761 2762 /** 2763 * @private 2764 */ 2765 override public function set y(value:Number):void 2766 { 2767 if (y == value) 2768 return; 2769 2770 if (_layoutFeatures == null) 2771 { 2772 super.y = value; 2773 } 2774 else 2775 { 2776 _layoutFeatures.layoutY = value; 2777 invalidateTransform(); 2778 } 2779 invalidateProperties(); 2780 2781 if (parent && parent is UIComponent) 2782 UIComponent(parent).childXYChanged(); 2783 2784 if (hasEventListener("yChanged")) 2785 dispatchEvent(new Event("yChanged")); 2786 } 2787 2788 //---------------------------------- 2789 // width 2790 //---------------------------------- 2791 2792 /** 2793 * @private 2794 * Storage for the width property. This should not be used to set the 2795 * width because it bypasses the mirroring transform in the setter. 2796 */ 2797 mx_internal var _width:Number; 2798 2799 [Bindable("widthChanged")] 2800 [Inspectable(category="General")] 2801 [PercentProxy("percentWidth")] 2802 2803 /** 2804 * Number that specifies the width of the component, in pixels, 2805 * in the parent's coordinates. 2806 * The default value is 0, but this property contains the actual component 2807 * width after Flex completes sizing the components in your application. 2808 * 2809 * <p>Note: You can specify a percentage value in the MXML 2810 * <code>width</code> attribute, such as <code>width="100%"</code>, 2811 * but you cannot use a percentage value in the <code>width</code> 2812 * property in ActionScript. 2813 * Use the <code>percentWidth</code> property instead.</p> 2814 * 2815 * <p>Setting this property causes a <code>resize</code> event to 2816 * be dispatched. 2817 * See the <code>resize</code> event for details on when 2818 * this event is dispatched.</p> 2819 * 2820 * @see #percentWidth 2821 * 2822 * @langversion 3.0 2823 * @playerversion Flash 9 2824 * @playerversion AIR 1.1 2825 * @productversion Flex 3 2826 */ 2827 override public function get width():Number 2828 { 2829 return _width; 2830 } 2831 2832 /** 2833 * @private 2834 */ 2835 override public function set width(value:Number):void 2836 { 2837 if (explicitWidth != value) 2838 { 2839 explicitWidth = value; 2840 2841 // We invalidate size because locking in width 2842 // may change the measured height in flow-based components. 2843 invalidateSize(); 2844 } 2845 2846 if (_width != value) 2847 { 2848 invalidateProperties(); 2849 invalidateDisplayList(); 2850 invalidateParentSizeAndDisplayList(); 2851 2852 _width = value; 2853 2854 // The width is needed for the _layoutFeatures' mirror transform. 2855 if (_layoutFeatures) 2856 { 2857 _layoutFeatures.layoutWidth = _width; 2858 invalidateTransform(); 2859 } 2860 2861 if (hasEventListener("widthChanged")) 2862 dispatchEvent(new Event("widthChanged")); 2863 } 2864 } 2865 2866 //---------------------------------- 2867 // height 2868 //---------------------------------- 2869 2870 /** 2871 * @private 2872 * Storage for the height property. 2873 */ 2874 mx_internal var _height:Number; 2875 2876 [Bindable("heightChanged")] 2877 [Inspectable(category="General")] 2878 [PercentProxy("percentHeight")] 2879 2880 /** 2881 * Number that specifies the height of the component, in pixels, 2882 * in the parent's coordinates. 2883 * The default value is 0, but this property contains the actual component 2884 * height after Flex completes sizing the components in your application. 2885 * 2886 * <p>Note: You can specify a percentage value in the MXML 2887 * <code>height</code> attribute, such as <code>height="100%"</code>, 2888 * but you cannot use a percentage value for the <code>height</code> 2889 * property in ActionScript; 2890 * use the <code>percentHeight</code> property instead.</p> 2891 * 2892 * <p>Setting this property causes a <code>resize</code> event to be dispatched. 2893 * See the <code>resize</code> event for details on when 2894 * this event is dispatched.</p> 2895 * 2896 * @see #percentHeight 2897 * 2898 * @langversion 3.0 2899 * @playerversion Flash 9 2900 * @playerversion AIR 1.1 2901 * @productversion Flex 3 2902 */ 2903 override public function get height():Number 2904 { 2905 return _height; 2906 } 2907 2908 /** 2909 * @private 2910 */ 2911 override public function set height(value:Number):void 2912 { 2913 if (explicitHeight != value) 2914 { 2915 explicitHeight = value; 2916 2917 // We invalidate size because locking in width 2918 // may change the measured height in flow-based components. 2919 invalidateSize(); 2920 } 2921 2922 if (_height != value) 2923 { 2924 invalidateProperties(); 2925 invalidateDisplayList(); 2926 invalidateParentSizeAndDisplayList(); 2927 2928 _height = value; 2929 2930 if (hasEventListener("heightChanged")) 2931 dispatchEvent(new Event("heightChanged")); 2932 } 2933 } 2934 2935 //---------------------------------- 2936 // scaleX 2937 //--------------------------------- 2938 [Bindable("scaleXChanged")] 2939 [Inspectable(category="Size", defaultValue="1.0")] 2940 2941 /** 2942 * Number that specifies the horizontal scaling factor. 2943 * 2944 * <p>The default value is 1.0, which means that the object 2945 * is not scaled. 2946 * A <code>scaleX</code> of 2.0 means the object has been 2947 * magnified by a factor of 2, and a <code>scaleX</code> of 0.5 2948 * means the object has been reduced by a factor of 2.</p> 2949 * 2950 * <p>A value of 0.0 is an invalid value. 2951 * Rather than setting it to 0.0, set it to a small value, or set 2952 * the <code>visible</code> property to <code>false</code> to hide the component.</p> 2953 * 2954 * @default 1.0 2955 * 2956 * @langversion 3.0 2957 * @playerversion Flash 9 2958 * @playerversion AIR 1.1 2959 * @productversion Flex 3 2960 */ 2961 2962 override public function get scaleX():Number 2963 { 2964 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 2965 return _scaleX; 2966 else 2967 return (_layoutFeatures == null) ? super.scaleX : _layoutFeatures.layoutScaleX; 2968 } 2969 2970 /** 2971 * @private 2972 * Storage for the scaleX property. 2973 */ 2974 private var _scaleX:Number = 1.0; 2975 2976 override public function set scaleX(value:Number):void 2977 { 2978 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 2979 { 2980 if (_scaleX == value) 2981 return; 2982 2983 _scaleX = value; 2984 2985 invalidateProperties(); 2986 invalidateSize(); 2987 } 2988 else 2989 { 2990 var prevValue:Number = (_layoutFeatures == null) ? scaleX : _layoutFeatures.layoutScaleX; 2991 if (prevValue == value) 2992 return; 2993 2994 _hasComplexLayoutMatrix = true; 2995 2996 // trace("set scaleX:" + this + "value = " + value); 2997 if (_layoutFeatures == null) 2998 super.scaleX = value; 2999 else 3000 { 3001 _layoutFeatures.layoutScaleX = value; 3002 } 3003 invalidateTransform(); 3004 invalidateProperties(); 3005 3006 // If we're not compatible with Flex3 (measuredWidth is pre-scale always) 3007 // and scaleX is changing we need to invalidate parent size and display list 3008 // since we are not going to detect a change in measured sizes during measure. 3009 invalidateParentSizeAndDisplayList(); 3010 3011 } 3012 dispatchEvent(new Event("scaleXChanged")); 3013 } 3014 3015 //---------------------------------- 3016 // scaleY 3017 //---------------------------------- 3018 3019 [Bindable("scaleYChanged")] 3020 [Inspectable(category="Size", defaultValue="1.0")] 3021 3022 /** 3023 * Number that specifies the vertical scaling factor. 3024 * 3025 * <p>The default value is 1.0, which means that the object 3026 * is not scaled. 3027 * A <code>scaleY</code> of 2.0 means the object has been 3028 * magnified by a factor of 2, and a <code>scaleY</code> of 0.5 3029 * means the object has been reduced by a factor of 2.</p> 3030 * 3031 * <p>A value of 0.0 is an invalid value. 3032 * Rather than setting it to 0.0, set it to a small value, or set 3033 * the <code>visible</code> property to <code>false</code> to hide the component.</p> 3034 * 3035 * @default 1.0 3036 * 3037 * @langversion 3.0 3038 * @playerversion Flash 9 3039 * @playerversion AIR 1.1 3040 * @productversion Flex 3 3041 */ 3042 override public function get scaleY():Number 3043 { 3044 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 3045 { 3046 return _scaleY; 3047 } 3048 else 3049 return (_layoutFeatures == null) ? super.scaleY : _layoutFeatures.layoutScaleY; 3050 } 3051 3052 /** 3053 * @private 3054 * Storage for the scaleY property. 3055 */ 3056 private var _scaleY:Number = 1.0; 3057 3058 3059 override public function set scaleY(value:Number):void 3060 { 3061 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 3062 { 3063 if (_scaleY == value) 3064 return; 3065 3066 _scaleY = value; 3067 3068 invalidateProperties(); 3069 invalidateSize(); 3070 } 3071 else 3072 { 3073 var prevValue:Number = (_layoutFeatures == null) ? scaleY : _layoutFeatures.layoutScaleY; 3074 if (prevValue == value) 3075 return; 3076 3077 _hasComplexLayoutMatrix = true; 3078 3079 if (_layoutFeatures == null) 3080 super.scaleY = value; 3081 else 3082 { 3083 _layoutFeatures.layoutScaleY = value; 3084 } 3085 invalidateTransform(); 3086 invalidateProperties(); 3087 3088 // If we're not compatible with Flex3 (measuredWidth is pre-scale always) 3089 // and scaleX is changing we need to invalidate parent size and display list 3090 // since we are not going to detect a change in measured sizes during measure. 3091 invalidateParentSizeAndDisplayList(); 3092 } 3093 3094 dispatchEvent(new Event("scaleYChanged")); 3095 } 3096 3097 //---------------------------------- 3098 // scaleZ 3099 //---------------------------------- 3100 3101 [Bindable("scaleZChanged")] 3102 [Inspectable(category="Size", defaultValue="1.0")] 3103 /** 3104 * Number that specifies the scaling factor along the z axis. 3105 * 3106 * <p>A scaling along the z axis does not affect a typical component, which lies flat 3107 * in the z=0 plane. components with children that have 3D transforms applied, or 3108 * components with a non-zero transformZ, is affected.</p> 3109 * 3110 * <p>The default value is 1.0, which means that the object 3111 * is not scaled.</p> 3112 * 3113 * <p>This property is ignored during calculation by any of Flex's 2D layouts. </p> 3114 * 3115 * @default 1.0 3116 * 3117 * @langversion 3.0 3118 * @playerversion Flash 9 3119 * @playerversion AIR 1.1 3120 * @productversion Flex 3 3121 */ 3122 override public function get scaleZ():Number 3123 { 3124 return (_layoutFeatures == null) ? super.scaleZ : _layoutFeatures.layoutScaleZ; 3125 } 3126 3127 /** 3128 * @private 3129 */ 3130 override public function set scaleZ(value:Number):void 3131 { 3132 if (scaleZ == value) 3133 return; 3134 3135 // validateMatrix when switching between 2D/3D, works around player bug 3136 // see sdk-23421 3137 var was3D:Boolean = is3D; 3138 if (_layoutFeatures == null) 3139 initAdvancedLayoutFeatures(); 3140 3141 _hasComplexLayoutMatrix = true; 3142 _layoutFeatures.layoutScaleZ = value; 3143 invalidateTransform(); 3144 invalidateProperties(); 3145 invalidateParentSizeAndDisplayList(); 3146 if (was3D != is3D) 3147 validateMatrix(); 3148 dispatchEvent(new Event("scaleZChanged")); 3149 } 3150 3151 /** 3152 * This property allows access to the Player's native implementation 3153 * of the <code>scaleX</code> property, which can be useful since components 3154 * can override <code>scaleX</code> and thereby hide the native implementation. 3155 * Note that this "base property" is final and cannot be overridden, 3156 * so you can count on it to reflect what is happening at the player level. 3157 * 3158 * @langversion 3.0 3159 * @playerversion Flash 9 3160 * @playerversion AIR 1.1 3161 * @productversion Flex 3 3162 */ 3163 mx_internal final function get $scaleX():Number 3164 { 3165 return super.scaleX; 3166 } 3167 3168 mx_internal final function set $scaleX(value:Number):void 3169 { 3170 super.scaleX = value; 3171 } 3172 3173 /** 3174 * This property allows access to the Player's native implementation 3175 * of the <code>scaleY</code> property, which can be useful since components 3176 * can override <code>scaleY</code> and thereby hide the native implementation. 3177 * Note that this "base property" is final and cannot be overridden, 3178 * so you can count on it to reflect what is happening at the player level. 3179 * 3180 * @langversion 3.0 3181 * @playerversion Flash 9 3182 * @playerversion AIR 1.1 3183 * @productversion Flex 3 3184 */ 3185 mx_internal final function get $scaleY():Number 3186 { 3187 return super.scaleY; 3188 } 3189 3190 mx_internal final function set $scaleY(value:Number):void 3191 { 3192 super.scaleY = value; 3193 } 3194 3195 //---------------------------------- 3196 // visible 3197 //---------------------------------- 3198 3199 /** 3200 * @private 3201 * Storage for the visible property. 3202 */ 3203 private var _visible:Boolean = true; 3204 3205 [Bindable("hide")] 3206 [Bindable("show")] 3207 [Inspectable(category="General", defaultValue="true")] 3208 3209 /** 3210 * Whether or not the display object is visible. 3211 * Display objects that are not visible are disabled. 3212 * For example, if <code>visible=false</code> for an InteractiveObject instance, 3213 * it cannot be clicked. 3214 * 3215 * <p>When setting to <code>true</code>, the object dispatches 3216 * a <code>show</code> event. 3217 * When setting to <code>false</code>, the object dispatches 3218 * a <code>hide</code> event. 3219 * In either case the children of the object does not emit a 3220 * <code>show</code> or <code>hide</code> event unless the object 3221 * has specifically written an implementation to do so.</p> 3222 * 3223 * @langversion 3.0 3224 * @playerversion Flash 9 3225 * @playerversion AIR 1.1 3226 * @productversion Flex 3 3227 */ 3228 override public function get visible():Boolean 3229 { 3230 return _visible; 3231 } 3232 3233 /** 3234 * @private 3235 */ 3236 override public function set visible(value:Boolean):void 3237 { 3238 setVisible(value); 3239 } 3240 3241 /** 3242 * Called when the <code>visible</code> property changes. 3243 * Set the <code>visible</code> property to show or hide 3244 * a component instead of calling this method directly. 3245 * 3246 * @param value The new value of the <code>visible</code> property. 3247 * Specify <code>true</code> to show the component, and <code>false</code> to hide it. 3248 * 3249 * @param noEvent If <code>true</code>, do not dispatch an event. 3250 * If <code>false</code>, dispatch a <code>show</code> event when 3251 * the component becomes visible, and a <code>hide</code> event when 3252 * the component becomes invisible. 3253 * 3254 * @langversion 3.0 3255 * @playerversion Flash 9 3256 * @playerversion AIR 1.1 3257 * @productversion Flex 3 3258 */ 3259 public function setVisible(value:Boolean, 3260 noEvent:Boolean = false):void 3261 { 3262 _visible = value; 3263 3264 if (!initialized) 3265 return; 3266 3267 if (designLayer && !designLayer.effectiveVisibility) 3268 value = false; 3269 3270 if ($visible == value) 3271 return; 3272 3273 $visible = value; 3274 3275 if (!noEvent) 3276 { 3277 var eventType:String = value ? FlexEvent.SHOW :FlexEvent.HIDE; 3278 3279 if (hasEventListener(eventType)) 3280 dispatchEvent(new FlexEvent(eventType)); 3281 } 3282 } 3283 3284 //---------------------------------- 3285 // alpha 3286 //---------------------------------- 3287 3288 /** 3289 * @private 3290 * Storage for the alpha property. 3291 */ 3292 private var _alpha:Number = 1.0; 3293 3294 [Bindable("alphaChanged")] 3295 [Inspectable(defaultValue="1.0", category="General", verbose="1", minValue="0.0", maxValue="1.0")] 3296 3297 /** 3298 * @private 3299 */ 3300 override public function get alpha():Number 3301 { 3302 // Here we roundtrip alpha in the same manner as the 3303 // player (purposely introducing a rounding error). 3304 return int(_alpha * 256.0) / 256.0; 3305 } 3306 3307 /** 3308 * @private 3309 */ 3310 override public function set alpha(value:Number):void 3311 { 3312 if (_alpha != value) 3313 { 3314 _alpha = value; 3315 3316 if (designLayer) 3317 value = value * designLayer.effectiveAlpha; 3318 3319 $alpha = value; 3320 3321 dispatchEvent(new Event("alphaChanged")); 3322 } 3323 } 3324 3325 //---------------------------------- 3326 // blendMode 3327 //---------------------------------- 3328 3329 /** 3330 * @private 3331 * Storage for the blendMode property. 3332 */ 3333 private var _blendMode:String = BlendMode.NORMAL; 3334 private var blendShaderChanged:Boolean; 3335 private var blendModeChanged:Boolean; 3336 3337 [Inspectable(category="General", enumeration="add,alpha,darken,difference,erase,hardlight,invert,layer,lighten,multiply,normal,subtract,screen,overlay,colordodge,colorburn,exclusion,softlight,hue,saturation,color,luminosity", defaultValue="normal")] 3338 3339 /** 3340 * @private 3341 */ 3342 override public function get blendMode():String 3343 { 3344 return _blendMode; 3345 } 3346 3347 /** 3348 * @private 3349 */ 3350 override public function set blendMode(value:String):void 3351 { 3352 if (_blendMode != value) 3353 { 3354 _blendMode = value; 3355 blendModeChanged = true; 3356 3357 // If one of the non-native Flash blendModes is set, 3358 // record the new value and set the appropriate 3359 // blendShader on the display object. 3360 if (value == "colordodge" || 3361 value =="colorburn" || value =="exclusion" || 3362 value =="softlight" || value =="hue" || 3363 value =="saturation" || value =="color" || 3364 value =="luminosity") 3365 { 3366 blendShaderChanged = true; 3367 } 3368 invalidateProperties(); 3369 } 3370 } 3371 3372 //---------------------------------- 3373 // doubleClickEnabled 3374 //---------------------------------- 3375 3376 [Inspectable(enumeration="true,false", defaultValue="true")] 3377 3378 /** 3379 * Specifies whether the UIComponent object receives <code>doubleClick</code> events. 3380 * The default value is <code>false</code>, which means that the UIComponent object 3381 * does not receive <code>doubleClick</code> events. 3382 * 3383 * <p>The <code>mouseEnabled</code> property must also be set to <code>true</code>, 3384 * its default value, for the object to receive <code>doubleClick</code> events.</p> 3385 * 3386 * @default false 3387 * 3388 * @langversion 3.0 3389 * @playerversion Flash 9 3390 * @playerversion AIR 1.1 3391 * @productversion Flex 3 3392 */ 3393 override public function get doubleClickEnabled():Boolean 3394 { 3395 return super.doubleClickEnabled; 3396 } 3397 3398 /** 3399 * @private 3400 * Propagate to children. 3401 */ 3402 override public function set doubleClickEnabled(value:Boolean):void 3403 { 3404 super.doubleClickEnabled = value; 3405 3406 var childList:IChildList; 3407 3408 if (this is IRawChildrenContainer) 3409 childList = IRawChildrenContainer(this).rawChildren; 3410 else 3411 childList = IChildList(this); 3412 3413 for (var i:int = 0; i < childList.numChildren; i++) 3414 { 3415 var child:InteractiveObject = childList.getChildAt(i) as InteractiveObject; 3416 if (child) 3417 child.doubleClickEnabled = value; 3418 } 3419 } 3420 3421 //---------------------------------- 3422 // enabled 3423 //---------------------------------- 3424 3425 /** 3426 * @private 3427 */ 3428 private var _enabled:Boolean = false; 3429 3430 [Inspectable(category="General", enumeration="true,false", defaultValue="true")] 3431 [Bindable("enabledChanged")] 3432 3433 /** 3434 * @copy mx.core.IUIComponent#enabled 3435 * 3436 * @langversion 3.0 3437 * @playerversion Flash 9 3438 * @playerversion AIR 1.1 3439 * @productversion Flex 3 3440 */ 3441 public function get enabled():Boolean 3442 { 3443 return _enabled; 3444 } 3445 3446 /** 3447 * @private 3448 */ 3449 public function set enabled(value:Boolean):void 3450 { 3451 _enabled = value; 3452 3453 // Need to flush the cached TextFormat 3454 // so it recalcs with the disabled color, 3455 cachedTextFormat = null; 3456 3457 invalidateDisplayList(); 3458 3459 dispatchEvent(new Event("enabledChanged")); 3460 } 3461 3462 //---------------------------------- 3463 // cacheAsBitmap 3464 //---------------------------------- 3465 3466 /** 3467 * @private 3468 */ 3469 override public function set cacheAsBitmap(value:Boolean):void 3470 { 3471 super.cacheAsBitmap = value; 3472 3473 // If cacheAsBitmap is set directly, 3474 // reset the value of cacheAsBitmapCount. 3475 cacheAsBitmapCount = value ? 1 : 0; 3476 } 3477 3478 //---------------------------------- 3479 // filters 3480 //---------------------------------- 3481 3482 /** 3483 * @private 3484 * Storage for the filters property. 3485 */ 3486 private var _filters:Array; 3487 3488 /** 3489 * @private 3490 */ 3491 override public function get filters():Array 3492 { 3493 return _filters ? _filters : super.filters; 3494 } 3495 3496 /** 3497 * @private 3498 */ 3499 override public function set filters(value:Array):void 3500 { 3501 var n:int; 3502 var i:int; 3503 var e:IEventDispatcher; 3504 3505 if (_filters) 3506 { 3507 n = _filters.length; 3508 for (i = 0; i < n; i++) 3509 { 3510 e = _filters[i] as IEventDispatcher; 3511 if (e) 3512 e.removeEventListener(BaseFilter.CHANGE, filterChangeHandler); 3513 } 3514 } 3515 3516 _filters = value; 3517 3518 var clonedFilters:Array = []; 3519 if (_filters) 3520 { 3521 n = _filters.length; 3522 for (i = 0; i < n; i++) 3523 { 3524 if (_filters[i] is IBitmapFilter) 3525 { 3526 e = _filters[i] as IEventDispatcher; 3527 if (e) 3528 e.addEventListener(BaseFilter.CHANGE, filterChangeHandler); 3529 clonedFilters.push(IBitmapFilter(_filters[i]).clone()); 3530 } 3531 else 3532 { 3533 clonedFilters.push(_filters[i]); 3534 } 3535 } 3536 } 3537 3538 super.filters = clonedFilters; 3539 } 3540 3541 //---------------------------------- 3542 // layer 3543 //---------------------------------- 3544 3545 /** 3546 * @private 3547 * Storage for the layer property. 3548 */ 3549 private var _designLayer:DesignLayer; 3550 3551 [Inspectable (environment='none')] 3552 3553 /** 3554 * @copy mx.core.IVisualElement#designLayer 3555 * 3556 * @langversion 3.0 3557 * @playerversion Flash 10 3558 * @playerversion AIR 1.5 3559 * @productversion Flex 4 3560 */ 3561 public function get designLayer():DesignLayer 3562 { 3563 return _designLayer; 3564 } 3565 3566 /** 3567 * @private 3568 */ 3569 public function set designLayer(value:DesignLayer):void 3570 { 3571 if (_designLayer) 3572 _designLayer.removeEventListener("layerPropertyChange", layer_PropertyChange, false); 3573 3574 _designLayer = value; 3575 3576 if (_designLayer) 3577 _designLayer.addEventListener("layerPropertyChange", layer_PropertyChange, false, 0, true); 3578 3579 $alpha = _designLayer ? _alpha * _designLayer.effectiveAlpha : _alpha; 3580 $visible = designLayer ? _visible && _designLayer.effectiveVisibility : _visible; 3581 } 3582 3583 //-------------------------------------------------------------------------- 3584 // 3585 // Properties: Display 3586 // 3587 //-------------------------------------------------------------------------- 3588 3589 //---------------------------------- 3590 // $alpha 3591 //---------------------------------- 3592 3593 /** 3594 * @private 3595 * This property allows access to the Player's native implementation 3596 * of the 'alpha' property, which can be useful since components 3597 * can override 'alpha' and thereby hide the native implementation. 3598 * Note that this "base property" is final and cannot be overridden, 3599 * so you can count on it to reflect what is happening at the player level. 3600 */ 3601 mx_internal final function get $alpha():Number 3602 { 3603 return super.alpha; 3604 } 3605 3606 /** 3607 * @private 3608 */ 3609 mx_internal final function set $alpha(value:Number):void 3610 { 3611 super.alpha = value; 3612 } 3613 3614 //---------------------------------- 3615 // $blendMode 3616 //---------------------------------- 3617 3618 /** 3619 * @private 3620 * This property allows access to the Player's native implementation 3621 * of the 'blendMode' property, which can be useful since components 3622 * can override 'alpha' and thereby hide the native implementation. 3623 * Note that this "base property" is final and cannot be overridden, 3624 * so you can count on it to reflect what is happening at the player level. 3625 */ 3626 mx_internal final function get $blendMode():String 3627 { 3628 return super.blendMode; 3629 } 3630 3631 /** 3632 * @private 3633 */ 3634 mx_internal final function set $blendMode(value:String):void 3635 { 3636 super.blendMode = value; 3637 } 3638 3639 //---------------------------------- 3640 // $blendShader 3641 //---------------------------------- 3642 3643 /** 3644 * @private 3645 */ 3646 mx_internal final function set $blendShader(value:Shader):void 3647 { 3648 super.blendShader = value; 3649 } 3650 3651 //---------------------------------- 3652 // $parent 3653 //---------------------------------- 3654 3655 /** 3656 * @private 3657 * This property allows access to the Player's native implementation 3658 * of the 'parent' property, which can be useful since components 3659 * can override 'parent' and thereby hide the native implementation. 3660 * Note that this "base property" is final and cannot be overridden, 3661 * so you can count on it to reflect what is happening at the player level. 3662 */ 3663 mx_internal final function get $parent():DisplayObjectContainer 3664 { 3665 return super.parent; 3666 } 3667 3668 //---------------------------------- 3669 // $x 3670 //---------------------------------- 3671 3672 /** 3673 * @private 3674 * This property allows access to the Player's native implementation 3675 * of the 'x' property, which can be useful since components 3676 * can override 'x' and thereby hide the native implementation. 3677 * Note that this "base property" is final and cannot be overridden, 3678 * so you can count on it to reflect what is happening at the player level. 3679 */ 3680 mx_internal final function get $x():Number 3681 { 3682 return super.x; 3683 } 3684 3685 /** 3686 * @private 3687 */ 3688 mx_internal final function set $x(value:Number):void 3689 { 3690 super.x = value; 3691 } 3692 3693 //---------------------------------- 3694 // $y 3695 //---------------------------------- 3696 3697 /** 3698 * @private 3699 * This property allows access to the Player's native implementation 3700 * of the 'y' property, which can be useful since components 3701 * can override 'y' and thereby hide the native implementation. 3702 * Note that this "base property" is final and cannot be overridden, 3703 * so you can count on it to reflect what is happening at the player level. 3704 */ 3705 mx_internal final function get $y():Number 3706 { 3707 return super.y; 3708 } 3709 3710 /** 3711 * @private 3712 */ 3713 mx_internal final function set $y(value:Number):void 3714 { 3715 super.y = value; 3716 } 3717 3718 //---------------------------------- 3719 // $width 3720 //---------------------------------- 3721 3722 /** 3723 * @private 3724 * This property allows access to the Player's native implementation 3725 * of the 'width' property, which can be useful since components 3726 * can override 'width' and thereby hide the native implementation. 3727 * Note that this "base property" is final and cannot be overridden, 3728 * so you can count on it to reflect what is happening at the player level. 3729 */ 3730 mx_internal final function get $width():Number 3731 { 3732 return super.width; 3733 } 3734 3735 /** 3736 * @private 3737 */ 3738 mx_internal final function set $width(value:Number):void 3739 { 3740 super.width = value; 3741 } 3742 3743 //---------------------------------- 3744 // $height 3745 //---------------------------------- 3746 3747 /** 3748 * @private 3749 * This property allows access to the Player's native implementation 3750 * of the 'height' property, which can be useful since components 3751 * can override 'height' and thereby hide the native implementation. 3752 * Note that this "base property" is final and cannot be overridden, 3753 * so you can count on it to reflect what is happening at the player level. 3754 */ 3755 mx_internal final function get $height():Number 3756 { 3757 return super.height; 3758 } 3759 3760 /** 3761 * @private 3762 */ 3763 mx_internal final function set $height(value:Number):void 3764 { 3765 super.height = value; 3766 } 3767 3768 //---------------------------------- 3769 // $visible 3770 //---------------------------------- 3771 3772 /** 3773 * @private 3774 * This property allows access to the Player's native implementation 3775 * of the 'visible' property, which can be useful since components 3776 * can override 'visible' and thereby hide the native implementation. 3777 * Note that this "base property" is final and cannot be overridden, 3778 * so you can count on it to reflect what is happening at the player level. 3779 */ 3780 mx_internal final function get $visible():Boolean 3781 { 3782 return super.visible; 3783 } 3784 3785 /** 3786 * @private 3787 */ 3788 mx_internal final function set $visible(value:Boolean):void 3789 { 3790 super.visible = value; 3791 } 3792 3793 //---------------------------------- 3794 // contentMouseX 3795 //---------------------------------- 3796 3797 /** 3798 * Returns the <i>x</i> position of the mouse, in the content coordinate system. 3799 * Content coordinates specify a pixel position relative to the upper left 3800 * corner of the component's content, and include all of the component's 3801 * content area, including any regions that are currently clipped and must 3802 * be accessed by scrolling the component. 3803 * 3804 * @langversion 3.0 3805 * @playerversion Flash 9 3806 * @playerversion AIR 1.1 3807 * @productversion Flex 3 3808 */ 3809 public function get contentMouseX():Number 3810 { 3811 return mouseX; 3812 } 3813 3814 //---------------------------------- 3815 // contentMouseY 3816 //---------------------------------- 3817 3818 /** 3819 * Returns the <i>y</i> position of the mouse, in the content coordinate system. 3820 * Content coordinates specify a pixel position relative to the upper left 3821 * corner of the component's content, and include all of the component's 3822 * content area, including any regions that are currently clipped and must 3823 * be accessed by scrolling the component. 3824 * 3825 * @langversion 3.0 3826 * @playerversion Flash 9 3827 * @playerversion AIR 1.1 3828 * @productversion Flex 3 3829 */ 3830 public function get contentMouseY():Number 3831 { 3832 return mouseY; 3833 } 3834 3835 //---------------------------------- 3836 // tweeningProperties 3837 //---------------------------------- 3838 3839 /** 3840 * @private 3841 */ 3842 private var _tweeningProperties:Array; 3843 3844 [Inspectable(environment="none")] 3845 3846 /** 3847 * Array of properties that are currently being tweened on this object. 3848 * 3849 * <p>Used to alert the EffectManager that certain properties of this object 3850 * are being tweened, so that the EffectManger doesn't attempt to animate 3851 * the same properties.</p> 3852 * 3853 * @langversion 3.0 3854 * @playerversion Flash 9 3855 * @playerversion AIR 1.1 3856 * @productversion Flex 3 3857 */ 3858 public function get tweeningProperties():Array 3859 { 3860 return _tweeningProperties; 3861 } 3862 3863 /** 3864 * @private 3865 */ 3866 public function set tweeningProperties(value:Array):void 3867 { 3868 _tweeningProperties = value; 3869 } 3870 3871 //-------------------------------------------------------------------------- 3872 // 3873 // Properties: Manager access 3874 // 3875 //-------------------------------------------------------------------------- 3876 3877 //---------------------------------- 3878 // cursorManager 3879 //---------------------------------- 3880 3881 /** 3882 * Gets the CursorManager that controls the cursor for this component 3883 * and its peers. 3884 * Each top-level window has its own instance of a CursorManager; 3885 * To make sure you're talking to the right one, use this method. 3886 * 3887 * @langversion 3.0 3888 * @playerversion Flash 9 3889 * @playerversion AIR 1.1 3890 * @productversion Flex 3 3891 */ 3892 public function get cursorManager():ICursorManager 3893 { 3894 var o:DisplayObject = parent; 3895 3896 while (o) 3897 { 3898 if (o is IUIComponent && "cursorManager" in o) 3899 { 3900 var cm:ICursorManager = o["cursorManager"]; 3901 return cm; 3902 } 3903 3904 o = o.parent; 3905 } 3906 3907 return CursorManager.getInstance(); 3908 } 3909 3910 //---------------------------------- 3911 // focusManager 3912 //---------------------------------- 3913 3914 /** 3915 * @private 3916 * Storage for the focusManager property. 3917 */ 3918 private var _focusManager:IFocusManager; 3919 3920 [Inspectable(environment="none")] 3921 3922 /** 3923 * Gets the FocusManager that controls focus for this component 3924 * and its peers. 3925 * Each popup has its own focus loop and therefore its own instance 3926 * of a FocusManager. 3927 * To make sure you're talking to the right one, use this method. 3928 * 3929 * @langversion 3.0 3930 * @playerversion Flash 9 3931 * @playerversion AIR 1.1 3932 * @productversion Flex 3 3933 */ 3934 public function get focusManager():IFocusManager 3935 { 3936 if (_focusManager) 3937 return _focusManager; 3938 3939 var o:DisplayObject = parent; 3940 3941 while (o) 3942 { 3943 if (o is IFocusManagerContainer) 3944 return IFocusManagerContainer(o).focusManager; 3945 3946 o = o.parent; 3947 } 3948 3949 return null; 3950 } 3951 3952 /** 3953 * @private 3954 * IFocusManagerContainers have this property assigned by the framework 3955 */ 3956 public function set focusManager(value:IFocusManager):void 3957 { 3958 _focusManager = value; 3959 dispatchEvent(new FlexEvent(FlexEvent.ADD_FOCUS_MANAGER)); 3960 } 3961 3962 //---------------------------------- 3963 // resourceManager 3964 //---------------------------------- 3965 3966 /** 3967 * @private 3968 * Storage for the resourceManager property. 3969 */ 3970 private var _resourceManager:IResourceManager = ResourceManager.getInstance(); 3971 3972 /** 3973 * @private 3974 * This metadata suppresses a trace() in PropertyWatcher: 3975 * "warning: unable to bind to property 'resourceManager' ..." 3976 */ 3977 [Bindable("unused")] 3978 3979 /** 3980 * A reference to the object which manages 3981 * all of the application's localized resources. 3982 * This is a singleton instance which implements 3983 * the IResourceManager interface. 3984 * 3985 * @langversion 3.0 3986 * @playerversion Flash 9 3987 * @playerversion AIR 1.1 3988 * @productversion Flex 3 3989 */ 3990 protected function get resourceManager():IResourceManager 3991 { 3992 return _resourceManager; 3993 } 3994 3995 //---------------------------------- 3996 // styleManager 3997 //---------------------------------- 3998 3999 /** 4000 * @private 4001 */ 4002 private var _styleManager:IStyleManager2; 4003 4004 /** 4005 * Returns the StyleManager instance used by this component. 4006 * 4007 * @langversion 3.0 4008 * @playerversion Flash 10 4009 * @playerversion AIR 1.5 4010 * @productversion Flex 4 4011 */ 4012 public function get styleManager():IStyleManager2 4013 { 4014 if (!_styleManager) 4015 _styleManager = StyleManager.getStyleManager(moduleFactory); 4016 4017 return _styleManager; 4018 } 4019 4020 //---------------------------------- 4021 // systemManager 4022 //---------------------------------- 4023 4024 /** 4025 * @private 4026 * Storage for the systemManager property. 4027 * Set by the SystemManager so that each UIComponent 4028 * has a references to its SystemManager 4029 */ 4030 private var _systemManager:ISystemManager; 4031 4032 /** 4033 * @private 4034 * if component has been reparented, we need to potentially 4035 * reassign systemManager, cause we could be in a new Window. 4036 */ 4037 private var _systemManagerDirty:Boolean = false; 4038 4039 [Inspectable(environment="none")] 4040 4041 /** 4042 * Returns the SystemManager object used by this component. 4043 * 4044 * @langversion 3.0 4045 * @playerversion Flash 9 4046 * @playerversion AIR 1.1 4047 * @productversion Flex 3 4048 */ 4049 public function get systemManager():ISystemManager 4050 { 4051 if (!_systemManager || _systemManagerDirty) 4052 { 4053 var r:DisplayObject = root; 4054 if (_systemManager && _systemManager.isProxy) 4055 { 4056 // keep the existing proxy 4057 } 4058 else if (r && !(r is Stage)) 4059 { 4060 // If this object is attached to the display list, then 4061 // the root property holds its SystemManager. 4062 _systemManager = (r as ISystemManager); 4063 } 4064 else if (r) 4065 { 4066 // if the root is the Stage, then we are in a second AIR window 4067 _systemManager = Stage(r).getChildAt(0) as ISystemManager; 4068 } 4069 else 4070 { 4071 // If this object isn't attached to the display list, then 4072 // we need to walk up the parent chain ourselves. 4073 var o:DisplayObjectContainer = parent; 4074 while (o) 4075 { 4076 var ui:IUIComponent = o as IUIComponent; 4077 if (ui) 4078 { 4079 _systemManager = ui.systemManager; 4080 break; 4081 } 4082 else if (o is ISystemManager) 4083 { 4084 _systemManager = o as ISystemManager; 4085 break; 4086 } 4087 o = o.parent; 4088 } 4089 } 4090 _systemManagerDirty = false; 4091 } 4092 4093 return _systemManager; 4094 } 4095 4096 /** 4097 * @private 4098 */ 4099 public function set systemManager(value:ISystemManager):void 4100 { 4101 _systemManager = value; 4102 _systemManagerDirty = false; 4103 } 4104 4105 /** 4106 * @private 4107 * Returns the current system manager, <code>systemManager</code>, 4108 * unless it is null. 4109 * If the current system manager is null, 4110 * then search to find the correct system manager. 4111 * 4112 * @return A system manager. This value is never null. 4113 */ 4114 mx_internal function getNonNullSystemManager():ISystemManager 4115 { 4116 var sm:ISystemManager = systemManager; 4117 4118 if (!sm) 4119 sm = ISystemManager(SystemManager.getSWFRoot(this)); 4120 4121 if (!sm) 4122 return SystemManagerGlobals.topLevelSystemManagers[0]; 4123 4124 return sm; 4125 } 4126 4127 /** 4128 * @private 4129 */ 4130 protected function invalidateSystemManager():void 4131 { 4132 var childList:IChildList = (this is IRawChildrenContainer) ? 4133 IRawChildrenContainer(this).rawChildren : IChildList(this); 4134 4135 var n:int = childList.numChildren; 4136 for (var i:int = 0; i < n; i++) 4137 { 4138 var child:UIComponent = childList.getChildAt(i) as UIComponent; 4139 if (child) 4140 child.invalidateSystemManager(); 4141 } 4142 _systemManagerDirty = true; 4143 } 4144 4145 //---------------------------------- 4146 // nestLevel 4147 //---------------------------------- 4148 4149 /** 4150 * @private 4151 * Storage for the nestLevel property. 4152 */ 4153 private var _nestLevel:int = 0; 4154 4155 [Inspectable(environment="none")] 4156 4157 /** 4158 * Depth of this object in the containment hierarchy. 4159 * This number is used by the measurement and layout code. 4160 * The value is 0 if this component is not on the DisplayList. 4161 * 4162 * @langversion 3.0 4163 * @playerversion Flash 9 4164 * @playerversion AIR 1.1 4165 * @productversion Flex 3 4166 */ 4167 public function get nestLevel():int 4168 { 4169 return _nestLevel; 4170 } 4171 4172 /** 4173 * @private 4174 */ 4175 public function set nestLevel(value:int):void 4176 { 4177 // If my parent hasn't been attached to the display list, then its nestLevel 4178 // will be zero. If it tries to set my nestLevel to 1, ignore it. We'll 4179 // update nest levels again after the parent is added to the display list. 4180 if (value == 1) 4181 return; 4182 4183 // Also punt if the new value for nestLevel is the same as my current value. 4184 // TODO: (aharui) add early exit if nestLevel isn't changing 4185 if (value > 1 && _nestLevel != value) 4186 { 4187 _nestLevel = value; 4188 4189 updateCallbacks(); 4190 4191 value ++; 4192 } 4193 else if (value == 0) 4194 _nestLevel = value = 0; 4195 else 4196 value ++; 4197 4198 var childList:IChildList = (this is IRawChildrenContainer) ? 4199 IRawChildrenContainer(this).rawChildren : IChildList(this); 4200 4201 var n:int = childList.numChildren; 4202 for (var i:int = 0; i < n; i++) 4203 { 4204 var ui:ILayoutManagerClient = childList.getChildAt(i) as ILayoutManagerClient; 4205 if (ui) 4206 { 4207 ui.nestLevel = value; 4208 } 4209 else 4210 { 4211 var textField:IUITextField = childList.getChildAt(i) as IUITextField; 4212 4213 if (textField) 4214 textField.nestLevel = value; 4215 } 4216 } 4217 } 4218 4219 //-------------------------------------------------------------------------- 4220 // 4221 // Properties: MXML 4222 // 4223 //-------------------------------------------------------------------------- 4224 4225 //---------------------------------- 4226 // descriptor 4227 //---------------------------------- 4228 4229 /** 4230 * @private 4231 * Storage for the descriptor property. 4232 * This variable is initialized in the construct() method 4233 * using the _descriptor in the initObj, which is set in 4234 * createComponentFromDescriptor(). 4235 * If this UIComponent was not created by createComponentFromDescriptor(), 4236 * its 'descriptor' property is null. 4237 */ 4238 mx_internal var _descriptor:UIComponentDescriptor; 4239 4240 [Inspectable(environment="none")] 4241 4242 /** 4243 * Reference to the UIComponentDescriptor, if any, that was used 4244 * by the <code>createComponentFromDescriptor()</code> method to create this 4245 * UIComponent instance. If this UIComponent instance 4246 * was not created from a descriptor, this property is null. 4247 * 4248 * @see mx.core.UIComponentDescriptor 4249 * 4250 * @langversion 3.0 4251 * @playerversion Flash 9 4252 * @playerversion AIR 1.1 4253 * @productversion Flex 3 4254 */ 4255 public function get descriptor():UIComponentDescriptor 4256 { 4257 return _descriptor; 4258 } 4259 4260 /** 4261 * @private 4262 */ 4263 public function set descriptor(value:UIComponentDescriptor):void 4264 { 4265 _descriptor = value; 4266 } 4267 4268 //---------------------------------- 4269 // document 4270 //---------------------------------- 4271 4272 /** 4273 * @private 4274 * Storage for the document property. 4275 * This variable is initialized in the init() method. 4276 * A document object (i.e., an Object at the top of the hierarchy 4277 * of a Flex application, MXML component, or AS component) has an 4278 * autogenerated override of initalize() which sets its _document to 4279 * 'this', so that its 'document' property is a reference to itself. 4280 * Other UIComponents set their _document to their parent's _document, 4281 * so that their 'document' property refers to the document object 4282 * that they are inside. 4283 */ 4284 mx_internal var _document:Object; 4285 4286 [Inspectable(environment="none")] 4287 4288 /** 4289 * A reference to the document object associated with this UIComponent. 4290 * A document object is an Object at the top of the hierarchy of a 4291 * Flex application, MXML component, or AS component. 4292 * 4293 * @langversion 3.0 4294 * @playerversion Flash 9 4295 * @playerversion AIR 1.1 4296 * @productversion Flex 3 4297 */ 4298 public function get document():Object 4299 { 4300 return _document; 4301 } 4302 4303 /** 4304 * A reference to the document object associated with this UIComponent. 4305 * A document object is an Object at the top of the hierarchy of a 4306 * Flex application, MXML component, or AS component. 4307 * 4308 * @langversion 3.0 4309 * @playerversion Flash 9 4310 * @playerversion AIR 1.1 4311 * @productversion Flex 3 4312 */ 4313 public function set document(value:Object):void 4314 { 4315 var n:int = numChildren; 4316 for (var i:int = 0; i < n; i++) 4317 { 4318 var child:IUIComponent = getChildAt(i) as IUIComponent; 4319 if (!child) 4320 continue; 4321 4322 if (child.document == _document || 4323 child.document == FlexGlobals.topLevelApplication) 4324 { 4325 child.document = value; 4326 } 4327 } 4328 4329 _document = value; 4330 } 4331 4332 //---------------------------------- 4333 // documentDescriptor 4334 //---------------------------------- 4335 4336 /** 4337 * @private 4338 * Storage for the documentDescriptor property. 4339 * A document object (i.e., a UIComponent at the top of the 4340 * hierarchy of a Flex application, MXML component, 4341 * or AS component) has an autogenerated override of init() 4342 * which sets its _documentDescriptor to the descriptor 4343 * at the top of the autogenerated descriptor tree for that 4344 * document. For other UIComponents, _documentDescriptor is 4345 * never defined. 4346 */ 4347 mx_internal var _documentDescriptor:UIComponentDescriptor; 4348 4349 /** 4350 * @private 4351 * For a document object, which is an instance of a UIComponent 4352 * at the top of the hierarchy of a Flex application, MXML 4353 * component, or ActionScript component, the 4354 * <code>documentDescriptor</code> property is a reference 4355 * to the UIComponentDescriptor at the top of the autogenerated 4356 * descriptor tree for that document, which describes the 4357 * set of children and their attributes for that document. 4358 * For other UIComponents, it is <code>null</code>. 4359 */ 4360 mx_internal function get documentDescriptor():UIComponentDescriptor 4361 { 4362 return _documentDescriptor; 4363 } 4364 4365 //---------------------------------- 4366 // id 4367 //---------------------------------- 4368 4369 /** 4370 * @private 4371 */ 4372 private var _id:String; 4373 4374 /** 4375 * ID of the component. This value becomes the instance name of the object 4376 * and should not contain any white space or special characters. Each component 4377 * throughout an application should have a unique id. 4378 * 4379 * <p>If your application is going to be tested by third party tools, give each component 4380 * a meaningful id. Testing tools use ids to represent the control in their scripts and 4381 * having a meaningful name can make scripts more readable. For example, set the 4382 * value of a button to submit_button rather than b1 or button1.</p> 4383 * 4384 * @langversion 3.0 4385 * @playerversion Flash 9 4386 * @playerversion AIR 1.1 4387 * @productversion Flex 3 4388 */ 4389 public function get id():String 4390 { 4391 return _id; 4392 } 4393 4394 /** 4395 * @private 4396 */ 4397 public function set id(value:String):void 4398 { 4399 _id = value; 4400 } 4401 4402 //---------------------------------- 4403 // isDocument 4404 //---------------------------------- 4405 4406 /** 4407 * Contains <code>true</code> if this UIComponent instance is a document object. 4408 * That means it is at the top of the hierarchy of a Flex 4409 * application, MXML component, or ActionScript component. 4410 * 4411 * @langversion 3.0 4412 * @playerversion Flash 9 4413 * @playerversion AIR 1.1 4414 * @productversion Flex 3 4415 */ 4416 public function get isDocument():Boolean 4417 { 4418 return document == this; 4419 } 4420 4421 //---------------------------------- 4422 // parentApplication 4423 //---------------------------------- 4424 4425 [Bindable("initialize")] 4426 4427 /* 4428 * Note: 4429 * There are two reasons that 'parentApplication' is typed as Object 4430 * rather than as Application. The first is that typing it as Application 4431 * would make UIComponent dependent on Application, slowing down compile 4432 * times not only for SWCs for also for MXML and AS components. The 4433 * second is that authors would not be able to access properties and 4434 * methods in the <Script> of their <Application> without casting it 4435 * to their application's subclass, as in 4436 * MyApplication(paentApplication).myAppMethod(). 4437 * Therefore we decided to dispense with strict typing for 4438 * 'parentApplication'. 4439 */ 4440 /** 4441 * A reference to the Application object that contains this UIComponent 4442 * instance. 4443 * This Application object might exist in a SWFLoader control in another 4444 * Application, and so on, creating a chain of Application objects that 4445 * can be walked using parentApplication. 4446 * 4447 * <p>The <code>parentApplication</code> property of an Application is never itself; 4448 * it is either the Application into which it was loaded or null 4449 * (for the top-level Application).</p> 4450 * 4451 * <p>Walking the application chain using the <code>parentApplication</code> 4452 * property is similar to walking the document chain using the 4453 * <code>parentDocument</code> property. 4454 * You can access the top-level application using the 4455 * <code>application</code> property of the Application class.</p> 4456 * 4457 * @langversion 3.0 4458 * @playerversion Flash 9 4459 * @playerversion AIR 1.1 4460 * @productversion Flex 3 4461 */ 4462 public function get parentApplication():Object 4463 { 4464 // Look for the SystemManager's document, 4465 // which should be the Application. 4466 var o:Object = systemManager.document; 4467 4468 // If this UIComponent is its own root, then it is an Application. 4469 // We want to return its parent Application, or null 4470 // (if it has no parent because it is the top-level Application). 4471 // The hierarchy in this situation looks something like this: 4472 // 4473 // SystemManager 4474 // Application 4475 // SomeContainer 4476 // Loader 4477 // Loaded App's SystemManager 4478 // Application 4479 // ThisComponent 4480 if (o == this) 4481 { 4482 var p:UIComponent = o.systemManager.parent as UIComponent; 4483 o = p ? p.systemManager.document : null; 4484 } 4485 4486 return o; 4487 } 4488 4489 //---------------------------------- 4490 // parentDocument 4491 //---------------------------------- 4492 4493 [Bindable("initialize")] 4494 4495 /** 4496 * A reference to the parent document object for this UIComponent. 4497 * A document object is a UIComponent at the top of the hierarchy 4498 * of a Flex application, MXML component, or AS component. 4499 * 4500 * <p>For the Application object, the <code>parentDocument</code> 4501 * property is null. 4502 * This property is useful in MXML scripts to go up a level 4503 * in the chain of document objects. 4504 * It can be used to walk this chain using 4505 * <code>parentDocument.parentDocument</code>, and so on.</p> 4506 * 4507 * <p>It is typed as Object so that authors can access properties 4508 * and methods on ancestor document objects without casting.</p> 4509 * 4510 * @langversion 3.0 4511 * @playerversion Flash 9 4512 * @playerversion AIR 1.1 4513 * @productversion Flex 3 4514 */ 4515 public function get parentDocument():Object 4516 { 4517 if (document == this) 4518 { 4519 var p:IUIComponent = parent as IUIComponent; 4520 if (p) 4521 return p.document; 4522 4523 var sm:ISystemManager = parent as ISystemManager; 4524 if (sm) 4525 return sm.document; 4526 4527 return null; 4528 } 4529 else 4530 { 4531 return document; 4532 } 4533 } 4534 4535 //---------------------------------- 4536 // screen 4537 //---------------------------------- 4538 4539 /** 4540 * Returns an object that contains the size and position of the base 4541 * drawing surface for this object. 4542 * 4543 * @langversion 3.0 4544 * @playerversion Flash 9 4545 * @playerversion AIR 1.1 4546 * @productversion Flex 3 4547 */ 4548 public function get screen():Rectangle 4549 { 4550 var sm:ISystemManager = systemManager; 4551 4552 return sm ? sm.screen : null; 4553 } 4554 4555 //-------------------------------------------------------------------------- 4556 // 4557 // Properties: Modules 4558 // 4559 //-------------------------------------------------------------------------- 4560 4561 //---------------------------------- 4562 // moduleFactory 4563 //---------------------------------- 4564 4565 /** 4566 * @private 4567 * Storage for the moduleFactory property. 4568 */ 4569 private var _moduleFactory:IFlexModuleFactory; 4570 4571 [Inspectable(environment="none")] 4572 4573 /** 4574 * A module factory is used as context for using embedded fonts and for 4575 * finding the style manager that controls the styles for this 4576 * component. 4577 * 4578 * @langversion 3.0 4579 * @playerversion Flash 9 4580 * @playerversion AIR 1.1 4581 * @productversion Flex 3 4582 */ 4583 public function get moduleFactory():IFlexModuleFactory 4584 { 4585 return _moduleFactory; 4586 } 4587 4588 /** 4589 * @private 4590 */ 4591 public function set moduleFactory(factory:IFlexModuleFactory):void 4592 { 4593 _styleManager = null; 4594 4595 var n:int = numChildren; 4596 for (var i:int = 0; i < n; i++) 4597 { 4598 var child:IFlexModule = getChildAt(i) as IFlexModule; 4599 if (!child) 4600 continue; 4601 4602 if (child.moduleFactory == null || child.moduleFactory == _moduleFactory) 4603 { 4604 child.moduleFactory = factory; 4605 } 4606 } 4607 4608 if (advanceStyleClientChildren != null) 4609 { 4610 for (var styleClient:Object in advanceStyleClientChildren) 4611 { 4612 var iAdvanceStyleClientChild:IFlexModule = styleClient 4613 as IFlexModule; 4614 4615 if (iAdvanceStyleClientChild && 4616 (iAdvanceStyleClientChild.moduleFactory == null 4617 || iAdvanceStyleClientChild.moduleFactory == _moduleFactory)) 4618 { 4619 iAdvanceStyleClientChild.moduleFactory = factory; 4620 } 4621 } 4622 } 4623 _moduleFactory = factory; 4624 4625 setDeferredStyles(); 4626 } 4627 4628 //-------------------------------------------------------------------------- 4629 // 4630 // Properties: Styles 4631 // 4632 //-------------------------------------------------------------------------- 4633 4634 //---------------------------------- 4635 // inheritingStyles 4636 //---------------------------------- 4637 4638 /** 4639 * @private 4640 * Storage for the inheritingStyles property. 4641 */ 4642 private var _inheritingStyles:Object = StyleProtoChain.STYLE_UNINITIALIZED; 4643 4644 [Inspectable(environment="none")] 4645 4646 /** 4647 * The beginning of this component's chain of inheriting styles. 4648 * The <code>getStyle()</code> method simply accesses 4649 * <code>inheritingStyles[styleName]</code> to search the entire 4650 * prototype-linked chain. 4651 * This object is set up by <code>initProtoChain()</code>. 4652 * Developers typically never need to access this property directly. 4653 * 4654 * @langversion 3.0 4655 * @playerversion Flash 9 4656 * @playerversion AIR 1.1 4657 * @productversion Flex 3 4658 */ 4659 public function get inheritingStyles():Object 4660 { 4661 return _inheritingStyles; 4662 } 4663 4664 /** 4665 * @private 4666 */ 4667 public function set inheritingStyles(value:Object):void 4668 { 4669 _inheritingStyles = value; 4670 } 4671 4672 //---------------------------------- 4673 // nonInheritingStyles 4674 //---------------------------------- 4675 4676 /** 4677 * @private 4678 * Storage for the nonInheritingStyles property. 4679 */ 4680 private var _nonInheritingStyles:Object = 4681 StyleProtoChain.STYLE_UNINITIALIZED; 4682 4683 [Inspectable(environment="none")] 4684 4685 /** 4686 * The beginning of this component's chain of non-inheriting styles. 4687 * The <code>getStyle()</code> method simply accesses 4688 * <code>nonInheritingStyles[styleName]</code> to search the entire 4689 * prototype-linked chain. 4690 * This object is set up by <code>initProtoChain()</code>. 4691 * Developers typically never need to access this property directly. 4692 * 4693 * @langversion 3.0 4694 * @playerversion Flash 9 4695 * @playerversion AIR 1.1 4696 * @productversion Flex 3 4697 */ 4698 public function get nonInheritingStyles():Object 4699 { 4700 return _nonInheritingStyles; 4701 } 4702 4703 /** 4704 * @private 4705 */ 4706 public function set nonInheritingStyles(value:Object):void 4707 { 4708 _nonInheritingStyles = value; 4709 } 4710 4711 //---------------------------------- 4712 // styleDeclaration 4713 //---------------------------------- 4714 4715 /** 4716 * @private 4717 * Storage for the styleDeclaration property. 4718 */ 4719 private var _styleDeclaration:CSSStyleDeclaration; 4720 4721 [Inspectable(environment="none")] 4722 4723 /** 4724 * Storage for the inline inheriting styles on this object. 4725 * This CSSStyleDeclaration is created the first time that 4726 * the <code>setStyle()</code> method 4727 * is called on this component to set an inheriting style. 4728 * Developers typically never need to access this property directly. 4729 * 4730 * @langversion 3.0 4731 * @playerversion Flash 9 4732 * @playerversion AIR 1.1 4733 * @productversion Flex 3 4734 */ 4735 public function get styleDeclaration():CSSStyleDeclaration 4736 { 4737 return _styleDeclaration; 4738 } 4739 4740 /** 4741 * @private 4742 */ 4743 public function set styleDeclaration(value:CSSStyleDeclaration):void 4744 { 4745 _styleDeclaration = value; 4746 } 4747 4748 //-------------------------------------------------------------------------- 4749 // 4750 // Properties: Bitmap caching 4751 // 4752 //-------------------------------------------------------------------------- 4753 4754 //---------------------------------- 4755 // cachePolicy 4756 //---------------------------------- 4757 4758 /** 4759 * @private 4760 * Storage for cachePolicy property. 4761 */ 4762 private var _cachePolicy:String = UIComponentCachePolicy.AUTO; 4763 4764 [Inspectable(enumeration="on,off,auto", defaultValue="auto")] 4765 4766 /** 4767 * Specifies the bitmap caching policy for this object. 4768 * Possible values in MXML are <code>"on"</code>, 4769 * <code>"off"</code> and 4770 * <code>"auto"</code> (default). 4771 * 4772 * <p>Possible values in ActionScript are <code>UIComponentCachePolicy.ON</code>, 4773 * <code>UIComponentCachePolicy.OFF</code> and 4774 * <code>UIComponentCachePolicy.AUTO</code> (default).</p> 4775 * 4776 * <p><ul> 4777 * <li>A value of <code>UIComponentCachePolicy.ON</code> means that 4778 * the object is always cached as a bitmap.</li> 4779 * <li>A value of <code>UIComponentCachePolicy.OFF</code> means that 4780 * the object is never cached as a bitmap.</li> 4781 * <li>A value of <code>UIComponentCachePolicy.AUTO</code> means that 4782 * the framework uses heuristics to decide whether the object should 4783 * be cached as a bitmap.</li> 4784 * </ul></p> 4785 * 4786 * @default UIComponentCachePolicy.AUTO 4787 * 4788 * @langversion 3.0 4789 * @playerversion Flash 9 4790 * @playerversion AIR 1.1 4791 * @productversion Flex 3 4792 */ 4793 public function get cachePolicy():String 4794 { 4795 return _cachePolicy; 4796 } 4797 4798 /** 4799 * @private 4800 */ 4801 public function set cachePolicy(value:String):void 4802 { 4803 if (_cachePolicy != value) 4804 { 4805 _cachePolicy = value; 4806 4807 if (value == UIComponentCachePolicy.OFF) 4808 cacheAsBitmap = false; 4809 else if (value == UIComponentCachePolicy.ON) 4810 cacheAsBitmap = true; 4811 else 4812 cacheAsBitmap = (cacheAsBitmapCount > 0); 4813 } 4814 } 4815 4816 //---------------------------------- 4817 // cacheHeuristic 4818 //---------------------------------- 4819 4820 /** 4821 * @private 4822 * Counter used by the cacheHeuristic property. 4823 */ 4824 private var cacheAsBitmapCount:int = 0; 4825 4826 [Inspectable(environment="none")] 4827 4828 /** 4829 * Used by Flex to suggest bitmap caching for the object. 4830 * If <code>cachePolicy</code> is <code>UIComponentCachePolicy.AUTO</code>, 4831 * then <code>cacheHeuristic</code> 4832 * is used to control the object's <code>cacheAsBitmap</code> property. 4833 * 4834 * @langversion 3.0 4835 * @playerversion Flash 9 4836 * @playerversion AIR 1.1 4837 * @productversion Flex 3 4838 */ 4839 public function set cacheHeuristic(value:Boolean):void 4840 { 4841 if (_cachePolicy == UIComponentCachePolicy.AUTO) 4842 { 4843 if (value) 4844 cacheAsBitmapCount++; 4845 else if (cacheAsBitmapCount != 0) 4846 cacheAsBitmapCount--; 4847 4848 super.cacheAsBitmap = (cacheAsBitmapCount != 0); 4849 } 4850 } 4851 4852 //-------------------------------------------------------------------------- 4853 // 4854 // Properties: Focus management 4855 // 4856 //-------------------------------------------------------------------------- 4857 4858 //---------------------------------- 4859 // focusPane 4860 //---------------------------------- 4861 4862 /** 4863 * @private 4864 * Storage for the focusPane property. 4865 */ 4866 private var _focusPane:Sprite; 4867 4868 [Inspectable(environment="none")] 4869 4870 /** 4871 * The focus pane associated with this object. 4872 * An object has a focus pane when one of its children has focus. 4873 * 4874 * @langversion 3.0 4875 * @playerversion Flash 9 4876 * @playerversion AIR 1.1 4877 * @productversion Flex 3 4878 */ 4879 public function get focusPane():Sprite 4880 { 4881 return _focusPane; 4882 } 4883 4884 /** 4885 * @private 4886 */ 4887 public function set focusPane(value:Sprite):void 4888 { 4889 if (value) 4890 { 4891 addChild(value); 4892 4893 value.x = 0; 4894 value.y = 0; 4895 value.scrollRect = null; 4896 4897 _focusPane = value; 4898 } 4899 else 4900 { 4901 removeChild(_focusPane); 4902 4903 _focusPane.mask = null; 4904 _focusPane = null; 4905 } 4906 } 4907 4908 //---------------------------------- 4909 // focusEnabled 4910 //---------------------------------- 4911 4912 /** 4913 * @private 4914 * Storage for the focusEnabled property. 4915 */ 4916 private var _focusEnabled:Boolean = true; 4917 4918 [Inspectable(defaultValue="true")] 4919 4920 /** 4921 * Indicates whether the component can receive focus when tabbed to. 4922 * You can set <code>focusEnabled</code> to <code>false</code> 4923 * when a UIComponent is used as a subcomponent of another component 4924 * so that the outer component becomes the focusable entity. 4925 * If this property is <code>false</code>, focus is transferred to 4926 * the first parent that has <code>focusEnable</code> 4927 * set to <code>true</code>. 4928 * 4929 * <p>The default value is <code>true</code>, except for the 4930 * spark.components.Scroller component. 4931 * For that component, the default value is <code>false</code>.</p> 4932 * 4933 * @see spark.components.Scroller 4934 * 4935 * @langversion 3.0 4936 * @playerversion Flash 9 4937 * @playerversion AIR 1.1 4938 * @productversion Flex 3 4939 */ 4940 public function get focusEnabled():Boolean 4941 { 4942 return _focusEnabled; 4943 } 4944 4945 /** 4946 * @private 4947 */ 4948 public function set focusEnabled(value:Boolean):void 4949 { 4950 _focusEnabled = value; 4951 } 4952 4953 //---------------------------------- 4954 // hasFocusableChildren 4955 //---------------------------------- 4956 4957 /** 4958 * @private 4959 * Storage for the hasFocusableChildren property. 4960 */ 4961 private var _hasFocusableChildren:Boolean = false; 4962 4963 [Bindable("hasFocusableChildrenChange")] 4964 [Inspectable(defaultValue="false")] 4965 4966 /** 4967 * A flag that indicates whether child objects can receive focus. 4968 * 4969 * <p><b>Note: </b>This property is similar to the <code>tabChildren</code> property 4970 * used by Flash Player. 4971 * Use the <code>hasFocusableChildren</code> property with Flex applications. 4972 * Do not use the <code>tabChildren</code> property.</p> 4973 * 4974 * <p>This property is usually <code>false</code> because most components 4975 * either receive focus themselves or delegate focus to a single 4976 * internal sub-component and appear as if the component has 4977 * received focus. 4978 * For example, a TextInput control contains a focusable 4979 * child RichEditableText control, but while the RichEditableText 4980 * sub-component actually receives focus, it appears as if the 4981 * TextInput has focus. TextInput sets <code>hasFocusableChildren</code> 4982 * to <code>false</code> because TextInput is considered the 4983 * component that has focus. Its internal structure is an 4984 * abstraction.</p> 4985 * 4986 * <p>Usually only navigator components, such as TabNavigator and 4987 * Accordion, have this flag set to <code>true</code> because they 4988 * receive focus on Tab but focus goes to components in the child 4989 * containers on further Tabs.</p> 4990 * 4991 * <p>The default value is <code>false</code>, except for the 4992 * spark.components.Scroller component. 4993 * For that component, the default value is <code>true</code>.</p> 4994 * 4995 * @see spark.components.Scroller 4996 * 4997 * @langversion 3.0 4998 * @playerversion Flash 10 4999 * @playerversion AIR 1.5 5000 * @productversion Flex 4 5001 */ 5002 public function get hasFocusableChildren():Boolean 5003 { 5004 return _hasFocusableChildren; 5005 } 5006 5007 /** 5008 * @private 5009 */ 5010 public function set hasFocusableChildren(value:Boolean):void 5011 { 5012 if (value != _hasFocusableChildren) 5013 { 5014 _hasFocusableChildren = value; 5015 dispatchEvent(new Event("hasFocusableChildrenChange")); 5016 } 5017 } 5018 5019 //---------------------------------- 5020 // mouseFocusEnabled 5021 //---------------------------------- 5022 5023 /** 5024 * @private 5025 * Storage for the mouseFocusEnabled property. 5026 */ 5027 private var _mouseFocusEnabled:Boolean = true; 5028 5029 [Inspectable(defaultValue="true")] 5030 5031 /** 5032 * Whether you can receive focus when clicked on. 5033 * If <code>false</code>, focus is transferred to 5034 * the first parent that is <code>mouseFocusEnable</code> 5035 * set to <code>true</code>. 5036 * For example, you can set this property to <code>false</code> 5037 * on a Button control so that you can use the Tab key to move focus 5038 * to the control, but not have the control get focus when you click on it. 5039 * 5040 * <p>The default value is <code>true</code> for most subclasses, except the Spark TabBar. In that case, the default is <code>false</code>.</p> 5041 * 5042 * @default true 5043 * 5044 * @langversion 3.0 5045 * @playerversion Flash 9 5046 * @playerversion AIR 1.1 5047 * @productversion Flex 3 5048 */ 5049 public function get mouseFocusEnabled():Boolean 5050 { 5051 return _mouseFocusEnabled; 5052 } 5053 5054 /** 5055 * @private 5056 */ 5057 public function set mouseFocusEnabled(value:Boolean):void 5058 { 5059 _mouseFocusEnabled = value; 5060 } 5061 5062 //---------------------------------- 5063 // tabFocusEnabled 5064 //---------------------------------- 5065 5066 /** 5067 * @private 5068 * Storage for the tabFocusEnabled property. 5069 */ 5070 private var _tabFocusEnabled:Boolean = true; 5071 5072 [Bindable("tabFocusEnabledChange")] 5073 [Inspectable(defaultValue="true")] 5074 5075 /** 5076 * A flag that indicates whether this object can receive focus 5077 * via the TAB key 5078 * 5079 * <p>This is similar to the <code>tabEnabled</code> property 5080 * used by the Flash Player.</p> 5081 * 5082 * <p>This is usually <code>true</code> for components that 5083 * handle keyboard input, but some components in controlbars 5084 * have them set to <code>false</code> because they should not steal 5085 * focus from another component like an editor. 5086 * </p> 5087 * 5088 * @default true 5089 * 5090 * @langversion 3.0 5091 * @playerversion Flash 10 5092 * @playerversion AIR 1.5 5093 * @productversion Flex 4 5094 */ 5095 public function get tabFocusEnabled():Boolean 5096 { 5097 return _tabFocusEnabled; 5098 } 5099 5100 /** 5101 * @private 5102 */ 5103 public function set tabFocusEnabled(value:Boolean):void 5104 { 5105 if (value != _tabFocusEnabled) 5106 { 5107 _tabFocusEnabled = value; 5108 dispatchEvent(new Event("tabFocusEnabledChange")); 5109 } 5110 } 5111 5112 //-------------------------------------------------------------------------- 5113 // 5114 // Properties: Measurement 5115 // 5116 //-------------------------------------------------------------------------- 5117 5118 //---------------------------------- 5119 // measuredMinWidth 5120 //---------------------------------- 5121 5122 /** 5123 * @private 5124 * Storage for the measuredMinWidth property. 5125 */ 5126 private var _measuredMinWidth:Number = 0; 5127 5128 [Inspectable(environment="none")] 5129 5130 /** 5131 * The default minimum width of the component, in pixels. 5132 * This value is set by the <code>measure()</code> method. 5133 * 5134 * @langversion 3.0 5135 * @playerversion Flash 9 5136 * @playerversion AIR 1.1 5137 * @productversion Flex 3 5138 */ 5139 public function get measuredMinWidth():Number 5140 { 5141 return _measuredMinWidth; 5142 } 5143 5144 /** 5145 * @private 5146 */ 5147 public function set measuredMinWidth(value:Number):void 5148 { 5149 _measuredMinWidth = value; 5150 } 5151 5152 //---------------------------------- 5153 // measuredMinHeight 5154 //---------------------------------- 5155 5156 /** 5157 * @private 5158 * Storage for the measuredMinHeight property. 5159 */ 5160 private var _measuredMinHeight:Number = 0; 5161 5162 [Inspectable(environment="none")] 5163 5164 /** 5165 * The default minimum height of the component, in pixels. 5166 * This value is set by the <code>measure()</code> method. 5167 * 5168 * @langversion 3.0 5169 * @playerversion Flash 9 5170 * @playerversion AIR 1.1 5171 * @productversion Flex 3 5172 */ 5173 public function get measuredMinHeight():Number 5174 { 5175 return _measuredMinHeight; 5176 } 5177 5178 /** 5179 * @private 5180 */ 5181 public function set measuredMinHeight(value:Number):void 5182 { 5183 _measuredMinHeight = value; 5184 } 5185 5186 //---------------------------------- 5187 // measuredWidth 5188 //---------------------------------- 5189 5190 /** 5191 * @private 5192 * Storage for the measuredWidth property. 5193 */ 5194 private var _measuredWidth:Number = 0; 5195 5196 [Inspectable(environment="none")] 5197 5198 /** 5199 * The default width of the component, in pixels. 5200 * This value is set by the <code>measure()</code> method. 5201 * 5202 * @langversion 3.0 5203 * @playerversion Flash 9 5204 * @playerversion AIR 1.1 5205 * @productversion Flex 3 5206 */ 5207 public function get measuredWidth():Number 5208 { 5209 return _measuredWidth; 5210 } 5211 5212 /** 5213 * @private 5214 */ 5215 public function set measuredWidth(value:Number):void 5216 { 5217 _measuredWidth = value; 5218 } 5219 5220 //---------------------------------- 5221 // measuredHeight 5222 //---------------------------------- 5223 5224 /** 5225 * @private 5226 * Storage for the measuredHeight property. 5227 */ 5228 private var _measuredHeight:Number = 0; 5229 5230 [Inspectable(environment="none")] 5231 5232 /** 5233 * The default height of the component, in pixels. 5234 * This value is set by the <code>measure()</code> method. 5235 * 5236 * @langversion 3.0 5237 * @playerversion Flash 9 5238 * @playerversion AIR 1.1 5239 * @productversion Flex 3 5240 */ 5241 public function get measuredHeight():Number 5242 { 5243 return _measuredHeight; 5244 } 5245 5246 /** 5247 * @private 5248 */ 5249 public function set measuredHeight(value:Number):void 5250 { 5251 _measuredHeight = value; 5252 } 5253 5254 //-------------------------------------------------------------------------- 5255 // 5256 // Properties: Layout 5257 // 5258 //-------------------------------------------------------------------------- 5259 5260 //---------------------------------- 5261 // percentWidth 5262 //---------------------------------- 5263 5264 /** 5265 * @private 5266 * Storage for the percentWidth property. 5267 */ 5268 private var _percentWidth:Number; 5269 5270 [Bindable("resize")] 5271 [Inspectable(environment="none")] 5272 5273 /** 5274 * Specifies the width of a component as a percentage 5275 * of its parent's size. Allowed values are 0-100. The default value is NaN. 5276 * Setting the <code>width</code> or <code>explicitWidth</code> properties 5277 * resets this property to NaN. 5278 * 5279 * <p>This property returns a numeric value only if the property was 5280 * previously set; it does not reflect the exact size of the component 5281 * in percent.</p> 5282 * 5283 * <p>This property is always set to NaN for the UITextField control.</p> 5284 * 5285 * <p>When used with Spark layouts, this property is used to calculate the 5286 * width of the component's bounds after scaling and rotation. For example 5287 * if the component is rotated at 90 degrees, then specifying 5288 * <code>percentWidth</code> will affect the component's height.</p> 5289 * 5290 * @langversion 3.0 5291 * @playerversion Flash 9 5292 * @playerversion AIR 1.1 5293 * @productversion Flex 3 5294 */ 5295 public function get percentWidth():Number 5296 { 5297 return _percentWidth; 5298 } 5299 5300 /** 5301 * @private 5302 */ 5303 public function set percentWidth(value:Number):void 5304 { 5305 if (_percentWidth == value) 5306 return; 5307 5308 if (!isNaN(value)) 5309 _explicitWidth = NaN; 5310 5311 _percentWidth = value; 5312 5313 invalidateParentSizeAndDisplayList(); 5314 } 5315 5316 //---------------------------------- 5317 // percentHeight 5318 //---------------------------------- 5319 5320 /** 5321 * @private 5322 * Storage for the percentHeight property. 5323 */ 5324 private var _percentHeight:Number; 5325 5326 [Bindable("resize")] 5327 [Inspectable(environment="none")] 5328 5329 /** 5330 * Specifies the height of a component as a percentage 5331 * of its parent's size. Allowed values are 0-100. The default value is NaN. 5332 * Setting the <code>height</code> or <code>explicitHeight</code> properties 5333 * resets this property to NaN. 5334 * 5335 * <p>This property returns a numeric value only if the property was 5336 * previously set; it does not reflect the exact size of the component 5337 * in percent.</p> 5338 * 5339 * <p>This property is always set to NaN for the UITextField control.</p> 5340 * 5341 * <p>When used with Spark layouts, this property is used to calculate the 5342 * height of the component's bounds after scaling and rotation. For example 5343 * if the component is rotated at 90 degrees, then specifying 5344 * <code>percentHeight</code> will affect the component's width.</p> 5345 * 5346 * @langversion 3.0 5347 * @playerversion Flash 9 5348 * @playerversion AIR 1.1 5349 * @productversion Flex 3 5350 */ 5351 public function get percentHeight():Number 5352 { 5353 return _percentHeight; 5354 } 5355 5356 /** 5357 * @private 5358 */ 5359 public function set percentHeight(value:Number):void 5360 { 5361 if (_percentHeight == value) 5362 return; 5363 5364 if (!isNaN(value)) 5365 _explicitHeight = NaN; 5366 5367 _percentHeight = value; 5368 5369 invalidateParentSizeAndDisplayList(); 5370 } 5371 5372 //---------------------------------- 5373 // minWidth 5374 //---------------------------------- 5375 5376 [Bindable("explicitMinWidthChanged")] 5377 [Inspectable(category="Size", defaultValue="0")] 5378 5379 /** 5380 * The minimum recommended width of the component to be considered 5381 * by the parent during layout. This value is in the 5382 * component's coordinates, in pixels. The default value depends on 5383 * the component's implementation. 5384 * 5385 * <p>If the application developer sets the value of minWidth, 5386 * the new value is stored in explicitMinWidth. The default value of minWidth 5387 * does not change. As a result, at layout time, if 5388 * minWidth was explicitly set by the application developer, then the value of 5389 * explicitMinWidth is used for the component's minimum recommended width. 5390 * If minWidth is not set explicitly by the application developer, then the value of 5391 * measuredMinWidth is used.</p> 5392 * 5393 * <p>This value is used by the container in calculating 5394 * the size and position of the component. 5395 * It is not used by the component itself in determining 5396 * its default size. 5397 * Thus this property may not have any effect if parented by 5398 * Container, or containers that don't factor in 5399 * this property. 5400 * Because the value is in component coordinates, 5401 * the true <code>minWidth</code> with respect to its parent 5402 * is affected by the <code>scaleX</code> property.</p> 5403 * 5404 * @langversion 3.0 5405 * @playerversion Flash 9 5406 * @playerversion AIR 1.1 5407 * @productversion Flex 3 5408 */ 5409 public function get minWidth():Number 5410 { 5411 if (!isNaN(explicitMinWidth)) 5412 return explicitMinWidth; 5413 5414 return measuredMinWidth; 5415 } 5416 5417 /** 5418 * @private 5419 */ 5420 public function set minWidth(value:Number):void 5421 { 5422 if (explicitMinWidth == value) 5423 return; 5424 5425 explicitMinWidth = value; 5426 } 5427 5428 //---------------------------------- 5429 // minHeight 5430 //---------------------------------- 5431 5432 [Bindable("explicitMinHeightChanged")] 5433 [Inspectable(category="Size", defaultValue="0")] 5434 5435 /** 5436 * The minimum recommended height of the component to be considered 5437 * by the parent during layout. This value is in the 5438 * component's coordinates, in pixels. The default value depends on 5439 * the component's implementation. 5440 * 5441 * <p>If the application developer sets the value of minHeight, 5442 * the new value is stored in explicitMinHeight. The default value of minHeight 5443 * does not change. As a result, at layout time, if 5444 * minHeight was explicitly set by the application developer, then the value of 5445 * explicitMinHeight is used for the component's minimum recommended height. 5446 * If minHeight is not set explicitly by the application developer, then the value of 5447 * measuredMinHeight is used.</p> 5448 * 5449 * <p>This value is used by the container in calculating 5450 * the size and position of the component. 5451 * It is not used by the component itself in determining 5452 * its default size. 5453 * Thus this property may not have any effect if parented by 5454 * Container, or containers that don't factor in 5455 * this property. 5456 * Because the value is in component coordinates, 5457 * the true <code>minHeight</code> with respect to its parent 5458 * is affected by the <code>scaleY</code> property.</p> 5459 * 5460 * @langversion 3.0 5461 * @playerversion Flash 9 5462 * @playerversion AIR 1.1 5463 * @productversion Flex 3 5464 */ 5465 public function get minHeight():Number 5466 { 5467 if (!isNaN(explicitMinHeight)) 5468 return explicitMinHeight; 5469 5470 return measuredMinHeight; 5471 } 5472 5473 /** 5474 * @private 5475 */ 5476 public function set minHeight(value:Number):void 5477 { 5478 if (explicitMinHeight == value) 5479 return; 5480 5481 explicitMinHeight = value; 5482 } 5483 5484 //---------------------------------- 5485 // maxWidth 5486 //---------------------------------- 5487 5488 [Bindable("explicitMaxWidthChanged")] 5489 [Inspectable(category="Size", defaultValue="10000")] 5490 5491 /** 5492 * The maximum recommended width of the component to be considered 5493 * by the parent during layout. This value is in the 5494 * component's coordinates, in pixels. The default value of this property is 5495 * set by the component developer. 5496 * 5497 * <p>The component developer uses this property to set an upper limit on the 5498 * width of the component.</p> 5499 * 5500 * <p>If the application developer overrides the default value of maxWidth, 5501 * the new value is stored in explicitMaxWidth. The default value of maxWidth 5502 * does not change. As a result, at layout time, if 5503 * maxWidth was explicitly set by the application developer, then the value of 5504 * explicitMaxWidth is used for the component's maximum recommended width. 5505 * If maxWidth is not set explicitly by the user, then the default value is used.</p> 5506 * 5507 * <p>This value is used by the container in calculating 5508 * the size and position of the component. 5509 * It is not used by the component itself in determining 5510 * its default size. 5511 * Thus this property may not have any effect if parented by 5512 * Container, or containers that don't factor in 5513 * this property. 5514 * Because the value is in component coordinates, 5515 * the true <code>maxWidth</code> with respect to its parent 5516 * is affected by the <code>scaleX</code> property. 5517 * Some components have no theoretical limit to their width. 5518 * In those cases their <code>maxWidth</code> is set to 5519 * <code>UIComponent.DEFAULT_MAX_WIDTH</code>.</p> 5520 * 5521 * @default 10000 5522 * 5523 * @langversion 3.0 5524 * @playerversion Flash 9 5525 * @playerversion AIR 1.1 5526 * @productversion Flex 3 5527 */ 5528 public function get maxWidth():Number 5529 { 5530 return !isNaN(explicitMaxWidth) ? 5531 explicitMaxWidth : 5532 DEFAULT_MAX_WIDTH; 5533 } 5534 5535 /** 5536 * @private 5537 */ 5538 public function set maxWidth(value:Number):void 5539 { 5540 if (explicitMaxWidth == value) 5541 return; 5542 5543 explicitMaxWidth = value; 5544 } 5545 5546 //---------------------------------- 5547 // maxHeight 5548 //---------------------------------- 5549 5550 [Bindable("explicitMaxHeightChanged")] 5551 [Inspectable(category="Size", defaultValue="10000")] 5552 5553 /** 5554 * The maximum recommended height of the component to be considered 5555 * by the parent during layout. This value is in the 5556 * component's coordinates, in pixels. The default value of this property is 5557 * set by the component developer. 5558 * 5559 * <p>The component developer uses this property to set an upper limit on the 5560 * height of the component.</p> 5561 * 5562 * <p>If the application developer overrides the default value of maxHeight, 5563 * the new value is stored in explicitMaxHeight. The default value of maxHeight 5564 * does not change. As a result, at layout time, if 5565 * maxHeight was explicitly set by the application developer, then the value of 5566 * explicitMaxHeight is used for the component's maximum recommended height. 5567 * If maxHeight is not set explicitly by the user, then the default value is used.</p> 5568 * 5569 * <p>This value is used by the container in calculating 5570 * the size and position of the component. 5571 * It is not used by the component itself in determining 5572 * its default size. 5573 * 5574 * Thus this property may not have any effect if parented by 5575 * Container, or containers that don't factor in 5576 * this property. 5577 * Because the value is in component coordinates, 5578 * the true <code>maxHeight</code> with respect to its parent 5579 * is affected by the <code>scaleY</code> property. 5580 * Some components have no theoretical limit to their height. 5581 * In those cases their <code>maxHeight</code> is set to 5582 * <code>UIComponent.DEFAULT_MAX_HEIGHT</code>.</p> 5583 * 5584 * @default 10000 5585 * 5586 * @langversion 3.0 5587 * @playerversion Flash 9 5588 * @playerversion AIR 1.1 5589 * @productversion Flex 3 5590 */ 5591 public function get maxHeight():Number 5592 { 5593 return !isNaN(explicitMaxHeight) ? 5594 explicitMaxHeight : 5595 DEFAULT_MAX_HEIGHT; 5596 } 5597 5598 /** 5599 * @private 5600 */ 5601 public function set maxHeight(value:Number):void 5602 { 5603 if (explicitMaxHeight == value) 5604 return; 5605 5606 explicitMaxHeight = value; 5607 } 5608 5609 //---------------------------------- 5610 // explicitMinWidth 5611 //---------------------------------- 5612 5613 /** 5614 * @private 5615 * Storage for the minWidth property. 5616 */ 5617 mx_internal var _explicitMinWidth:Number; 5618 5619 [Bindable("explicitMinWidthChanged")] 5620 [Inspectable(environment="none")] 5621 5622 /** 5623 * The minimum recommended width of the component to be considered 5624 * by the parent during layout. This value is in the 5625 * component's coordinates, in pixels. 5626 * 5627 * <p>Application developers typically do not set the explicitMinWidth property. Instead, they 5628 * set the value of the minWidth property, which sets the explicitMinWidth property. The 5629 * value of minWidth does not change.</p> 5630 * 5631 * <p>At layout time, if minWidth was explicitly set by the application developer, then 5632 * the value of explicitMinWidth is used. Otherwise, the value of measuredMinWidth 5633 * is used.</p> 5634 * 5635 * <p>This value is used by the container in calculating 5636 * the size and position of the component. 5637 * It is not used by the component itself in determining 5638 * its default size. 5639 * Thus this property may not have any effect if parented by 5640 * Container, or containers that don't factor in 5641 * this property. 5642 * Because the value is in component coordinates, 5643 * the true <code>minWidth</code> with respect to its parent 5644 * is affected by the <code>scaleX</code> property.</p> 5645 * 5646 * @default NaN 5647 * 5648 * @langversion 3.0 5649 * @playerversion Flash 9 5650 * @playerversion AIR 1.1 5651 * @productversion Flex 3 5652 */ 5653 public function get explicitMinWidth():Number 5654 { 5655 return _explicitMinWidth; 5656 } 5657 5658 /** 5659 * @private 5660 */ 5661 public function set explicitMinWidth(value:Number):void 5662 { 5663 if (_explicitMinWidth == value) 5664 return; 5665 5666 _explicitMinWidth = value; 5667 5668 // We invalidate size because locking in width 5669 // may change the measured height in flow-based components. 5670 invalidateSize(); 5671 invalidateParentSizeAndDisplayList(); 5672 5673 dispatchEvent(new Event("explicitMinWidthChanged")); 5674 } 5675 5676 //---------------------------------- 5677 // minHeight 5678 //---------------------------------- 5679 5680 /** 5681 * @private 5682 * Storage for the minHeight property. 5683 */ 5684 mx_internal var _explicitMinHeight:Number; 5685 5686 [Bindable("explictMinHeightChanged")] 5687 [Inspectable(environment="none")] 5688 5689 /** 5690 * The minimum recommended height of the component to be considered 5691 * by the parent during layout. This value is in the 5692 * component's coordinates, in pixels. 5693 * 5694 * <p>Application developers typically do not set the explicitMinHeight property. Instead, they 5695 * set the value of the minHeight property, which sets the explicitMinHeight property. The 5696 * value of minHeight does not change.</p> 5697 * 5698 * <p>At layout time, if minHeight was explicitly set by the application developer, then 5699 * the value of explicitMinHeight is used. Otherwise, the value of measuredMinHeight 5700 * is used.</p> 5701 * 5702 * <p>This value is used by the container in calculating 5703 * the size and position of the component. 5704 * It is not used by the component itself in determining 5705 * its default size. 5706 * Thus this property may not have any effect if parented by 5707 * Container, or containers that don't factor in 5708 * this property. 5709 * Because the value is in component coordinates, 5710 * the true <code>minHeight</code> with respect to its parent 5711 * is affected by the <code>scaleY</code> property.</p> 5712 * 5713 * @default NaN 5714 * 5715 * @langversion 3.0 5716 * @playerversion Flash 9 5717 * @playerversion AIR 1.1 5718 * @productversion Flex 3 5719 */ 5720 public function get explicitMinHeight():Number 5721 { 5722 return _explicitMinHeight; 5723 } 5724 5725 /** 5726 * @private 5727 */ 5728 public function set explicitMinHeight(value:Number):void 5729 { 5730 if (_explicitMinHeight == value) 5731 return; 5732 5733 _explicitMinHeight = value; 5734 5735 // We invalidate size because locking in height 5736 // may change the measured width in flow-based components. 5737 invalidateSize(); 5738 invalidateParentSizeAndDisplayList(); 5739 5740 dispatchEvent(new Event("explicitMinHeightChanged")); 5741 } 5742 5743 //---------------------------------- 5744 // explicitMaxWidth 5745 //---------------------------------- 5746 5747 /** 5748 * @private 5749 * Storage for the maxWidth property. 5750 */ 5751 mx_internal var _explicitMaxWidth:Number; 5752 5753 [Bindable("explicitMaxWidthChanged")] 5754 [Inspectable(environment="none")] 5755 5756 /** 5757 * The maximum recommended width of the component to be considered 5758 * by the parent during layout. This value is in the 5759 * component's coordinates, in pixels. 5760 * 5761 * <p>Application developers typically do not set the explicitMaxWidth property. Instead, they 5762 * set the value of the maxWidth property, which sets the explicitMaxWidth property. The 5763 * value of maxWidth does not change.</p> 5764 * 5765 * <p>At layout time, if maxWidth was explicitly set by the application developer, then 5766 * the value of explicitMaxWidth is used. Otherwise, the default value for maxWidth 5767 * is used.</p> 5768 * 5769 * <p>This value is used by the container in calculating 5770 * the size and position of the component. 5771 * It is not used by the component itself in determining 5772 * its default size. 5773 * Thus this property may not have any effect if parented by 5774 * Container, or containers that don't factor in 5775 * this property. 5776 * Because the value is in component coordinates, 5777 * the true <code>maxWidth</code> with respect to its parent 5778 * is affected by the <code>scaleX</code> property. 5779 * Some components have no theoretical limit to their width. 5780 * In those cases their <code>maxWidth</code> is set to 5781 * <code>UIComponent.DEFAULT_MAX_WIDTH</code>.</p> 5782 * 5783 * @default NaN 5784 * 5785 * @langversion 3.0 5786 * @playerversion Flash 9 5787 * @playerversion AIR 1.1 5788 * @productversion Flex 3 5789 */ 5790 public function get explicitMaxWidth():Number 5791 { 5792 return _explicitMaxWidth; 5793 } 5794 5795 /** 5796 * @private 5797 */ 5798 public function set explicitMaxWidth(value:Number):void 5799 { 5800 if (_explicitMaxWidth == value) 5801 return; 5802 5803 _explicitMaxWidth = value; 5804 5805 // Se invalidate size because locking in width 5806 // may change the measured height in flow-based components. 5807 invalidateSize(); 5808 invalidateParentSizeAndDisplayList(); 5809 5810 dispatchEvent(new Event("explicitMaxWidthChanged")); 5811 } 5812 5813 //---------------------------------- 5814 // explicitMaxHeight 5815 //---------------------------------- 5816 5817 /** 5818 * @private 5819 * Storage for the maxHeight property. 5820 */ 5821 mx_internal var _explicitMaxHeight:Number; 5822 5823 [Bindable("explicitMaxHeightChanged")] 5824 [Inspectable(environment="none")] 5825 5826 /** 5827 * The maximum recommended height of the component to be considered 5828 * by the parent during layout. This value is in the 5829 * component's coordinates, in pixels. 5830 * 5831 * <p>Application developers typically do not set the explicitMaxHeight property. Instead, they 5832 * set the value of the maxHeight property, which sets the explicitMaxHeight property. The 5833 * value of maxHeight does not change.</p> 5834 * 5835 * <p>At layout time, if maxHeight was explicitly set by the application developer, then 5836 * the value of explicitMaxHeight is used. Otherwise, the default value for maxHeight 5837 * is used.</p> 5838 * 5839 * <p>This value is used by the container in calculating 5840 * the size and position of the component. 5841 * It is not used by the component itself in determining 5842 * its default size. 5843 * Thus this property may not have any effect if parented by 5844 * Container, or containers that don't factor in 5845 * this property. 5846 * Because the value is in component coordinates, 5847 * the true <code>maxHeight</code> with respect to its parent 5848 * is affected by the <code>scaleY</code> property. 5849 * Some components have no theoretical limit to their height. 5850 * In those cases their <code>maxHeight</code> is set to 5851 * <code>UIComponent.DEFAULT_MAX_HEIGHT</code>.</p> 5852 * 5853 * @default NaN 5854 * 5855 * @langversion 3.0 5856 * @playerversion Flash 9 5857 * @playerversion AIR 1.1 5858 * @productversion Flex 3 5859 */ 5860 public function get explicitMaxHeight():Number 5861 { 5862 return _explicitMaxHeight; 5863 } 5864 5865 /** 5866 * @private 5867 */ 5868 public function set explicitMaxHeight(value:Number):void 5869 { 5870 if (_explicitMaxHeight == value) 5871 return; 5872 5873 _explicitMaxHeight = value; 5874 5875 // Se invalidate size because locking in height 5876 // may change the measured width in flow-based components. 5877 invalidateSize(); 5878 invalidateParentSizeAndDisplayList(); 5879 5880 dispatchEvent(new Event("explicitMaxHeightChanged")); 5881 } 5882 5883 //---------------------------------- 5884 // explicitWidth 5885 //---------------------------------- 5886 5887 /** 5888 * @private 5889 * Storage for the explicitWidth property. 5890 */ 5891 private var _explicitWidth:Number; 5892 5893 [Bindable("explicitWidthChanged")] 5894 [Inspectable(environment="none")] 5895 5896 /** 5897 * Number that specifies the explicit width of the component, 5898 * in pixels, in the component's coordinates. 5899 * 5900 * <p>This value is used by the container in calculating 5901 * the size and position of the component. 5902 * It is not used by the component itself in determining 5903 * its default size. 5904 * Thus this property may not have any effect if parented by 5905 * Container, or containers that don't factor in 5906 * this property. 5907 * Because the value is in component coordinates, 5908 * the true <code>explicitWidth</code> with respect to its parent 5909 * is affected by the <code>scaleX</code> property.</p> 5910 * <p>Setting the <code>width</code> property also sets this property to 5911 * the specified width value.</p> 5912 * 5913 * @langversion 3.0 5914 * @playerversion Flash 9 5915 * @playerversion AIR 1.1 5916 * @productversion Flex 3 5917 */ 5918 public function get explicitWidth():Number 5919 { 5920 return _explicitWidth; 5921 } 5922 5923 /** 5924 * @private 5925 */ 5926 public function set explicitWidth(value:Number):void 5927 { 5928 if (_explicitWidth == value) 5929 return; 5930 5931 // width can be pixel or percent not both 5932 if (!isNaN(value)) 5933 _percentWidth = NaN; 5934 5935 _explicitWidth = value; 5936 5937 // We invalidate size because locking in width 5938 // may change the measured height in flow-based components. 5939 invalidateSize(); 5940 invalidateParentSizeAndDisplayList(); 5941 5942 dispatchEvent(new Event("explicitWidthChanged")); 5943 } 5944 5945 //---------------------------------- 5946 // explicitHeight 5947 //---------------------------------- 5948 5949 /** 5950 * @private 5951 * Storage for the explicitHeight property. 5952 */ 5953 private var _explicitHeight:Number; 5954 5955 [Bindable("explicitHeightChanged")] 5956 [Inspectable(environment="none")] 5957 5958 /** 5959 * Number that specifies the explicit height of the component, 5960 * in pixels, in the component's coordinates. 5961 * 5962 * <p>This value is used by the container in calculating 5963 * the size and position of the component. 5964 * It is not used by the component itself in determining 5965 * its default size. 5966 * Thus this property may not have any effect if parented by 5967 * Container, or containers that don't factor in 5968 * this property. 5969 * Because the value is in component coordinates, 5970 * the true <code>explicitHeight</code> with respect to its parent 5971 * is affected by the <code>scaleY</code> property.</p> 5972 * <p>Setting the <code>height</code> property also sets this property to 5973 * the specified height value.</p> 5974 * 5975 * @langversion 3.0 5976 * @playerversion Flash 9 5977 * @playerversion AIR 1.1 5978 * @productversion Flex 3 5979 */ 5980 public function get explicitHeight():Number 5981 { 5982 return _explicitHeight; 5983 } 5984 5985 /** 5986 * @private 5987 */ 5988 public function set explicitHeight(value:Number):void 5989 { 5990 if (_explicitHeight == value) 5991 return; 5992 5993 // height can be pixel or percent, not both 5994 if (!isNaN(value)) 5995 _percentHeight = NaN; 5996 5997 _explicitHeight = value; 5998 5999 // We invalidate size because locking in height 6000 // may change the measured width in flow-based components. 6001 invalidateSize(); 6002 invalidateParentSizeAndDisplayList(); 6003 6004 dispatchEvent(new Event("explicitHeightChanged")); 6005 } 6006 6007 //---------------------------------- 6008 // hasComplexLayoutMatrix 6009 //---------------------------------- 6010 6011 /** 6012 * @private 6013 * 6014 * when false, the transform on this component consists only of translation. Otherwise, it may be arbitrarily complex. 6015 */ 6016 private var _hasComplexLayoutMatrix:Boolean = false; 6017 6018 /** 6019 * Returns <code>true</code> if the UIComponent has any non-translation (x,y) transform properties. 6020 * 6021 * @langversion 3.0 6022 * @playerversion Flash 10 6023 * @playerversion AIR 1.5 6024 * @productversion Flex 4 6025 */ 6026 protected function get hasComplexLayoutMatrix():Boolean 6027 { 6028 // we set _hasComplexLayoutMatrix when any scale or rotation transform gets set 6029 // because sometimes when those are set, we don't allocate a layoutFeatures object. 6030 6031 // if the flag isn't set, we def. don't have a complex layout matrix. 6032 // if the flag is set and we don't have an AdvancedLayoutFeatures object, 6033 // then we'll check the transform and see if it's actually transformed. 6034 // otherwise we'll check the layoutMatrix on the AdvancedLayoutFeatures object, 6035 // to see if we're actually transformed. 6036 if (!_hasComplexLayoutMatrix) 6037 return false; 6038 else 6039 { 6040 if (_layoutFeatures == null) 6041 { 6042 _hasComplexLayoutMatrix = !MatrixUtil.isDeltaIdentity(super.transform.matrix); 6043 return _hasComplexLayoutMatrix; 6044 } 6045 else 6046 { 6047 return !MatrixUtil.isDeltaIdentity(_layoutFeatures.layoutMatrix); 6048 } 6049 } 6050 } 6051 6052 //---------------------------------- 6053 // includeInLayout 6054 //---------------------------------- 6055 6056 /** 6057 * @private 6058 * Storage for the includeInLayout property. 6059 */ 6060 private var _includeInLayout:Boolean = true; 6061 6062 [Bindable("includeInLayoutChanged")] 6063 [Inspectable(category="General", defaultValue="true")] 6064 6065 /** 6066 * Specifies whether this component is included in the layout of the 6067 * parent container. 6068 * If <code>true</code>, the object is included in its parent container's 6069 * layout and is sized and positioned by its parent container as per its layout rules. 6070 * If <code>false</code>, the object size and position are not affected by its parent container's 6071 * layout. 6072 * 6073 * @default true 6074 * 6075 * @langversion 3.0 6076 * @playerversion Flash 9 6077 * @playerversion AIR 1.1 6078 * @productversion Flex 3 6079 */ 6080 public function get includeInLayout():Boolean 6081 { 6082 return _includeInLayout; 6083 } 6084 6085 /** 6086 * @private 6087 */ 6088 public function set includeInLayout(value:Boolean):void 6089 { 6090 if (_includeInLayout != value) 6091 { 6092 _includeInLayout = value; 6093 6094 var p:IInvalidating = parent as IInvalidating; 6095 if (p) 6096 { 6097 p.invalidateSize(); 6098 p.invalidateDisplayList(); 6099 } 6100 6101 dispatchEvent(new Event("includeInLayoutChanged")); 6102 } 6103 } 6104 6105 //---------------------------------- 6106 // layoutDirection 6107 //---------------------------------- 6108 6109 /** 6110 * Checked at commitProperties() time to see if our layoutDirection has changed, 6111 * or our parent's layoutDirection has changed. This variable is reset after the 6112 * entire validateProperties() phase is complete so that it's possible for a child 6113 * to check if its parent's layoutDirection has changed, see commitProperties(). 6114 * The flag is cleared in validateDisplayList(). 6115 */ 6116 mx_internal var oldLayoutDirection:String = LayoutDirection.LTR; 6117 6118 /** 6119 * @inheritDoc 6120 */ 6121 public function get layoutDirection():String 6122 { 6123 if (layoutDirectionCachedValue == LAYOUT_DIRECTION_CACHE_UNSET) 6124 { 6125 layoutDirectionCachedValue = getStyle("layoutDirection"); 6126 } 6127 return layoutDirectionCachedValue; 6128 } 6129 6130 /** 6131 * @private 6132 * Changes to the layoutDirection style cause an invalidateProperties() call, 6133 * see StyleProtoChain/styleChanged(). At commitProperties() time we use 6134 * invalidateLayoutDirection() to add/remove the mirroring transform. 6135 * 6136 * layoutDirection=undefined or layoutDirection=null has the same effect 6137 * as setStyle(“layoutDirection”, undefined). 6138 */ 6139 public function set layoutDirection(value:String):void 6140 { 6141 // Set the value to null to inherit the layoutDirection. 6142 if (value == null) 6143 setStyle("layoutDirection", undefined); 6144 else 6145 setStyle("layoutDirection", value); 6146 } 6147 6148 //-------------------------------------------------------------------------- 6149 // 6150 // Properties: Repeater 6151 // 6152 //-------------------------------------------------------------------------- 6153 6154 //---------------------------------- 6155 // instanceIndex 6156 //---------------------------------- 6157 6158 /** 6159 * The index of a repeated component. 6160 * If the component is not within a Repeater, the value is -1. 6161 * 6162 * @langversion 3.0 6163 * @playerversion Flash 9 6164 * @playerversion AIR 1.1 6165 * @productversion Flex 3 6166 */ 6167 public function get instanceIndex():int 6168 { 6169 // For efficiency, _instanceIndices starts out null rather than []. 6170 return _instanceIndices ? 6171 _instanceIndices[_instanceIndices.length - 1] : 6172 -1; 6173 } 6174 6175 //---------------------------------- 6176 // instanceIndices 6177 //---------------------------------- 6178 6179 /** 6180 * @private 6181 * Storage for the instanceIndices and index properties. 6182 */ 6183 private var _instanceIndices:Array /* of int */; 6184 6185 [Inspectable(environment="none")] 6186 6187 /** 6188 * An Array containing the indices required to reference 6189 * this UIComponent object from its parent document. 6190 * The Array is empty unless this UIComponent object is within one or more Repeaters. 6191 * The first element corresponds to the outermost Repeater. 6192 * For example, if the id is "b" and instanceIndices is [2,4], 6193 * you would reference it on the parent document as b[2][4]. 6194 * 6195 * @langversion 3.0 6196 * @playerversion Flash 9 6197 * @playerversion AIR 1.1 6198 * @productversion Flex 3 6199 */ 6200 public function get instanceIndices():Array 6201 { 6202 // For efficiency, _instanceIndices starts out undefined rather than []. 6203 return _instanceIndices ? _instanceIndices.slice(0) : null; 6204 } 6205 6206 /** 6207 * @private 6208 */ 6209 public function set instanceIndices(value:Array):void 6210 { 6211 _instanceIndices = value; 6212 } 6213 6214 //---------------------------------- 6215 // repeater 6216 //---------------------------------- 6217 6218 /** 6219 * A reference to the Repeater object 6220 * in the parent document that produced this UIComponent. 6221 * Use this property, rather than the <code>repeaters</code> property, 6222 * when the UIComponent is created by a single Repeater object. 6223 * Use the <code>repeaters</code> property when this UIComponent is created 6224 * by nested Repeater objects. 6225 * 6226 * <p>The property is set to <code>null</code> when this UIComponent 6227 * is not created by a Repeater.</p> 6228 * 6229 * @langversion 3.0 6230 * @playerversion Flash 9 6231 * @playerversion AIR 1.1 6232 * @productversion Flex 3 6233 */ 6234 public function get repeater():IRepeater 6235 { 6236 // For efficiency, _repeaters starts out undefined rather than []. 6237 return _repeaters ? _repeaters[_repeaters.length - 1] : null; 6238 } 6239 6240 //---------------------------------- 6241 // repeaters 6242 //---------------------------------- 6243 6244 /** 6245 * @private 6246 * Storage for the repeaters and repeater properties. 6247 */ 6248 private var _repeaters:Array /* of Repeater */; 6249 6250 [Inspectable(environment="none")] 6251 6252 /** 6253 * An Array containing references to the Repeater objects 6254 * in the parent document that produced this UIComponent. 6255 * The Array is empty unless this UIComponent is within 6256 * one or more Repeaters. 6257 * The first element corresponds to the outermost Repeater object. 6258 * 6259 * @langversion 3.0 6260 * @playerversion Flash 9 6261 * @playerversion AIR 1.1 6262 * @productversion Flex 3 6263 */ 6264 public function get repeaters():Array 6265 { 6266 // For efficiency, _repeaters starts out undefined rather than []. 6267 return _repeaters ? _repeaters.slice(0) : []; 6268 } 6269 6270 /** 6271 * @private 6272 */ 6273 public function set repeaters(value:Array):void 6274 { 6275 _repeaters = value; 6276 } 6277 6278 //---------------------------------- 6279 // repeaterIndex 6280 //---------------------------------- 6281 6282 /** 6283 * The index of the item in the data provider 6284 * of the Repeater that produced this UIComponent. 6285 * Use this property, rather than the <code>repeaterIndices</code> property, 6286 * when the UIComponent is created by a single Repeater object. 6287 * Use the <code>repeaterIndices</code> property when this UIComponent is created 6288 * by nested Repeater objects. 6289 * 6290 * <p>This property is set to -1 when this UIComponent is 6291 * not created by a Repeater.</p> 6292 * 6293 * @langversion 3.0 6294 * @playerversion Flash 9 6295 * @playerversion AIR 1.1 6296 * @productversion Flex 3 6297 */ 6298 public function get repeaterIndex():int 6299 { 6300 // For efficiency, _repeaterIndices starts out null rather than []. 6301 return _repeaterIndices ? 6302 _repeaterIndices[_repeaterIndices.length - 1] : 6303 -1; 6304 } 6305 6306 //---------------------------------- 6307 // repeaterIndices 6308 //---------------------------------- 6309 6310 /** 6311 * @private 6312 * Storage for the repeaterIndices and repeaterIndex properties. 6313 */ 6314 private var _repeaterIndices:Array /* of int */; 6315 6316 [Inspectable(environment="none")] 6317 6318 /** 6319 * An Array containing the indices of the items in the data provider 6320 * of the Repeaters in the parent document that produced this UIComponent. 6321 * The Array is empty unless this UIComponent is within one or more Repeaters. 6322 * 6323 * <p>The first element in the Array corresponds to the outermost Repeater. 6324 * For example, if <code>repeaterIndices</code> is [2,4] it means that the 6325 * outer repeater used item <code>dataProvider[2]</code> and the inner repeater 6326 * used item <code>dataProvider[4]</code>.</p> 6327 * 6328 * <p>Note that this property differs from the <code>instanceIndices</code> property 6329 * if the <code>startingIndex</code> property of any of the Repeaters is not 0. 6330 * For example, even if a Repeater starts at <code>dataProvider[4]</code>, 6331 * the document reference of the first repeated object is b[0], not b[4].</p> 6332 * 6333 * @langversion 3.0 6334 * @playerversion Flash 9 6335 * @playerversion AIR 1.1 6336 * @productversion Flex 3 6337 */ 6338 public function get repeaterIndices():Array 6339 { 6340 // For efficiency, _repeaterIndices starts out null rather than []. 6341 return _repeaterIndices ? _repeaterIndices.slice() : []; 6342 } 6343 6344 /** 6345 * @private 6346 */ 6347 public function set repeaterIndices(value:Array):void 6348 { 6349 _repeaterIndices = value; 6350 } 6351 6352 //-------------------------------------------------------------------------- 6353 // 6354 // Properties: States 6355 // 6356 //-------------------------------------------------------------------------- 6357 6358 //---------------------------------- 6359 // currentState 6360 //---------------------------------- 6361 6362 /** 6363 * @private 6364 * Storage for the currentState property. 6365 */ 6366 private var _currentState:String; 6367 6368 /** 6369 * @private 6370 * Pending current state name. 6371 */ 6372 private var requestedCurrentState:String; 6373 6374 /** 6375 * @private 6376 * Flag to play state transition 6377 */ 6378 private var playStateTransition:Boolean = true; 6379 6380 /** 6381 * @private 6382 * Flag that is set when the currentState has changed and needs to be 6383 * committed. 6384 * This property name needs the initial underscore to avoid collisions 6385 * with the "currentStateChange" event attribute. 6386 */ 6387 private var _currentStateChanged:Boolean; 6388 6389 [Bindable("currentStateChange")] 6390 6391 /** 6392 * The current view state of the component. 6393 * Set to <code>""</code> or <code>null</code> to reset 6394 * the component back to its base state. 6395 * 6396 * <p>When you use this property to set a component's state, 6397 * Flex applies any transition you have defined. 6398 * You can also use the <code>setCurrentState()</code> method to set the 6399 * current state; this method can optionally change states without 6400 * applying a transition.</p> 6401 * 6402 * @see #setCurrentState() 6403 * 6404 * @langversion 3.0 6405 * @playerversion Flash 9 6406 * @playerversion AIR 1.1 6407 * @productversion Flex 3 6408 */ 6409 public function get currentState():String 6410 { 6411 return _currentStateChanged ? requestedCurrentState : _currentState; 6412 } 6413 6414 /** 6415 * @private 6416 */ 6417 public function set currentState(value:String):void 6418 { 6419 // We have a deferred state change currently queued up, let's override 6420 // the originally requested state with the newly requested. Otherwise 6421 // we'll synchronously assign our new state. 6422 if (_currentStateDeferred != null) 6423 _currentStateDeferred = value; 6424 else 6425 setCurrentState(value, true); 6426 } 6427 6428 /** 6429 * @private 6430 * Backing variable for currentStateDeferred property 6431 */ 6432 private var _currentStateDeferred:String; 6433 6434 /** 6435 * @private 6436 * Version of currentState property that defers setting currentState 6437 * until commitProperties() time. This is used by SetProperty.remove() 6438 * to avoid causing state transitions when currentState is being rolled 6439 * back in a state change operation just to be set immediately after to the 6440 * actual new currentState value. This avoids unnecessary, and sometimes 6441 * incorrect, use of transitions based on this transient state of currentState. 6442 */ 6443 mx_internal function get currentStateDeferred():String 6444 { 6445 return (_currentStateDeferred != null) ? _currentStateDeferred : currentState; 6446 } 6447 6448 /** 6449 * @private 6450 */ 6451 mx_internal function set currentStateDeferred(value:String):void 6452 { 6453 _currentStateDeferred = value; 6454 if (value != null) 6455 invalidateProperties(); 6456 } 6457 6458 6459 //---------------------------------- 6460 // states 6461 //---------------------------------- 6462 6463 private var _states:Array /* of State */ = []; 6464 6465 [Inspectable(arrayType="mx.states.State")] 6466 [ArrayElementType("mx.states.State")] 6467 6468 /** 6469 * The view states that are defined for this component. 6470 * You can specify the <code>states</code> property only on the root 6471 * of the application or on the root tag of an MXML component. 6472 * The compiler generates an error if you specify it on any other control. 6473 * 6474 * @langversion 3.0 6475 * @playerversion Flash 9 6476 * @playerversion AIR 1.1 6477 * @productversion Flex 3 6478 */ 6479 public function get states():Array 6480 { 6481 return _states; 6482 } 6483 6484 /** 6485 * @private 6486 */ 6487 public function set states(value:Array):void 6488 { 6489 _states = value; 6490 } 6491 6492 //---------------------------------- 6493 // transitions 6494 //---------------------------------- 6495 6496 /** 6497 * @private 6498 * Transition currently playing. 6499 */ 6500 private var _currentTransition:Transition; 6501 6502 private var _transitions:Array /* of Transition */ = []; 6503 6504 [Inspectable(arrayType="mx.states.Transition")] 6505 [ArrayElementType("mx.states.Transition")] 6506 6507 /** 6508 * An Array of Transition objects, where each Transition object defines a 6509 * set of effects to play when a view state change occurs. 6510 * 6511 * @see mx.states.Transition 6512 * 6513 * @langversion 3.0 6514 * @playerversion Flash 9 6515 * @playerversion AIR 1.1 6516 * @productversion Flex 3 6517 */ 6518 public function get transitions():Array 6519 { 6520 return _transitions; 6521 } 6522 6523 /** 6524 * @private 6525 */ 6526 public function set transitions(value:Array):void 6527 { 6528 _transitions = value; 6529 } 6530 //-------------------------------------------------------------------------- 6531 // 6532 // Properties: Other 6533 // 6534 //-------------------------------------------------------------------------- 6535 6536 //---------------------------------- 6537 // baselinePosition 6538 //---------------------------------- 6539 6540 /** 6541 * @inheritDoc 6542 * 6543 * @langversion 3.0 6544 * @playerversion Flash 9 6545 * @playerversion AIR 1.1 6546 * @productversion Flex 3 6547 */ 6548 public function get baselinePosition():Number 6549 { 6550 if (!validateBaselinePosition()) 6551 return NaN; 6552 6553 // Unless the height is very small, the baselinePosition 6554 // of a generic UIComponent is calculated as if there was 6555 // a UITextField using the component's styles 6556 // whose top coincides with the component's top. 6557 // If the height is small, the baselinePosition is calculated 6558 // as if there were text within whose ascent the component 6559 // is vertically centered. 6560 // At the crossover height, these two calculations 6561 // produce the same result. 6562 6563 var lineMetrics:TextLineMetrics = measureText("Wj"); 6564 6565 if (height < 2 + lineMetrics.ascent + 2) 6566 return int(height + (lineMetrics.ascent - height) / 2); 6567 6568 return 2 + lineMetrics.ascent; 6569 } 6570 6571 //---------------------------------- 6572 // className 6573 //---------------------------------- 6574 6575 /** 6576 * The name of this instance's class, such as <code>"Button"</code>. 6577 * 6578 * <p>This string does not include the package name. 6579 * If you need the package name as well, call the 6580 * <code>getQualifiedClassName()</code> method in the flash.utils package. 6581 * It returns a string such as <code>"mx.controls::Button"</code>.</p> 6582 * 6583 * @langversion 3.0 6584 * @playerversion Flash 9 6585 * @playerversion AIR 1.1 6586 * @productversion Flex 3 6587 */ 6588 public function get className():String 6589 { 6590 return NameUtil.getUnqualifiedClassName(this); 6591 } 6592 6593 //---------------------------------- 6594 // effectsStarted 6595 //---------------------------------- 6596 6597 /** 6598 * The list of effects that are currently playing on the component, 6599 * as an Array of EffectInstance instances. 6600 * 6601 * @langversion 3.0 6602 * @playerversion Flash 9 6603 * @playerversion AIR 1.1 6604 * @productversion Flex 3 6605 */ 6606 public function get activeEffects():Array 6607 { 6608 return _effectsStarted; 6609 } 6610 6611 //---------------------------------- 6612 // flexContextMenu 6613 //---------------------------------- 6614 6615 /** 6616 * @private 6617 * Storage for the flexContextMenu property. 6618 */ 6619 private var _flexContextMenu:IFlexContextMenu; 6620 6621 /** 6622 * The context menu for this UIComponent. 6623 * 6624 * @default null 6625 * 6626 * @langversion 3.0 6627 * @playerversion Flash 9 6628 * @playerversion AIR 1.1 6629 * @productversion Flex 3 6630 */ 6631 public function get flexContextMenu():IFlexContextMenu 6632 { 6633 return _flexContextMenu; 6634 } 6635 6636 /** 6637 * @private 6638 */ 6639 public function set flexContextMenu(value:IFlexContextMenu):void 6640 { 6641 if (_flexContextMenu) 6642 _flexContextMenu.unsetContextMenu(this); 6643 6644 _flexContextMenu = value; 6645 6646 if (value != null) 6647 _flexContextMenu.setContextMenu(this); 6648 } 6649 6650 //---------------------------------- 6651 // styleName 6652 //---------------------------------- 6653 6654 /** 6655 * @private 6656 * Storage for the styleName property. 6657 */ 6658 private var _styleName:Object /* String, CSSStyleDeclaration, or UIComponent */; 6659 6660 [Inspectable(category="General")] 6661 6662 /** 6663 * The class style used by this component. This can be a String, CSSStyleDeclaration 6664 * or an IStyleClient. 6665 * 6666 * <p>If this is a String, it is the name of one or more whitespace delimited class 6667 * declarations in an <code><fx:Style></code> tag or CSS file. You do not include the period 6668 * in the <code>styleName</code>. For example, if you have a class style named <code>".bigText"</code>, 6669 * set the <code>styleName</code> property to <code>"bigText"</code> (no period).</p> 6670 * 6671 * <p>If this is an IStyleClient (typically a UIComponent), all styles in the 6672 * <code>styleName</code> object are used by this component.</p> 6673 * 6674 * @default null 6675 * 6676 * @langversion 3.0 6677 * @playerversion Flash 9 6678 * @playerversion AIR 1.1 6679 * @productversion Flex 3 6680 */ 6681 public function get styleName():Object /* String, CSSStyleDeclaration, or UIComponent */ 6682 { 6683 return _styleName; 6684 } 6685 6686 /** 6687 * @private 6688 */ 6689 public function set styleName(value:Object /* String, CSSStyleDeclaration, or UIComponent */):void 6690 { 6691 if (_styleName === value) 6692 return; 6693 6694 _styleName = value; 6695 6696 // If inheritingStyles is undefined, then this object is being 6697 // initialized and we haven't yet generated the proto chain. 6698 // To avoid redundant work, don't bother to create 6699 // the proto chain here. 6700 if (inheritingStyles == StyleProtoChain.STYLE_UNINITIALIZED) 6701 return; 6702 6703 regenerateStyleCache(true); 6704 6705 initThemeColor(); 6706 6707 styleChanged("styleName"); 6708 6709 notifyStyleChangeInChildren("styleName", true); 6710 } 6711 6712 //---------------------------------- 6713 // toolTip 6714 //---------------------------------- 6715 6716 /** 6717 * @private 6718 * Storage for the toolTip property. 6719 */ 6720 mx_internal var _toolTip:String; 6721 6722 [Bindable("toolTipChanged")] 6723 [Inspectable(category="General", defaultValue="null")] 6724 6725 /** 6726 * Text to display in the ToolTip. 6727 * 6728 * @default null 6729 * 6730 * @langversion 3.0 6731 * @playerversion Flash 9 6732 * @playerversion AIR 1.1 6733 * @productversion Flex 3 6734 */ 6735 public function get toolTip():String 6736 { 6737 return _toolTip; 6738 } 6739 6740 /** 6741 * @private 6742 */ 6743 public function set toolTip(value:String):void 6744 { 6745 var oldValue:String = _toolTip; 6746 _toolTip = value; 6747 6748 ToolTipManager.registerToolTip(this, oldValue, value); 6749 6750 dispatchEvent(new Event("toolTipChanged")); 6751 } 6752 6753 //---------------------------------- 6754 // uid 6755 //---------------------------------- 6756 6757 /** 6758 * @private 6759 */ 6760 private var _uid:String; 6761 6762 /** 6763 * A unique identifier for the object. 6764 * Flex data-driven controls, including all controls that are 6765 * subclasses of List class, use a UID to track data provider items. 6766 * 6767 * <p>Flex can automatically create and manage UIDs. 6768 * However, there are circumstances when you must supply your own 6769 * <code>uid</code> property by implementing the IUID interface, 6770 * or when supplying your own <code>uid</code> property improves processing efficiency. 6771 * UIDs do not need to be universally unique for most uses in Flex. 6772 * One exception is for messages sent by data services.</p> 6773 * 6774 * @see IUID 6775 * @see mx.utils.UIDUtil 6776 * 6777 * @langversion 3.0 6778 * @playerversion Flash 9 6779 * @playerversion AIR 1.1 6780 * @productversion Flex 3 6781 */ 6782 public function get uid():String 6783 { 6784 if (!_uid) 6785 _uid = toString(); 6786 6787 return _uid; 6788 } 6789 6790 /** 6791 * @private 6792 */ 6793 public function set uid(uid:String):void 6794 { 6795 this._uid = uid; 6796 } 6797 6798 //---------------------------------- 6799 // indexedID 6800 //---------------------------------- 6801 6802 /** 6803 * @private 6804 * Utility getter used by uid. It returns an indexed id string 6805 * such as "foo[1][2]" if this object is a repeated object, 6806 * or a nonindexed id string like "bar" if it isn't. 6807 */ 6808 private function get indexedID():String 6809 { 6810 var s:String = id; 6811 var indices:Array /* of int */ = instanceIndices; 6812 if (indices) 6813 s += "[" + indices.join("][") + "]"; 6814 return s; 6815 } 6816 6817 //-------------------------------------------------------------------------- 6818 // 6819 // Properties: Popups 6820 // 6821 //-------------------------------------------------------------------------- 6822 6823 //---------------------------------- 6824 // isPopUp 6825 //---------------------------------- 6826 6827 /** 6828 * @private 6829 */ 6830 private var _isPopUp:Boolean; 6831 6832 [Inspectable(environment="none")] 6833 6834 /** 6835 * Set to <code>true</code> by the PopUpManager to indicate 6836 * that component has been popped up. 6837 * 6838 * @langversion 3.0 6839 * @playerversion Flash 9 6840 * @playerversion AIR 1.1 6841 * @productversion Flex 3 6842 */ 6843 public function get isPopUp():Boolean 6844 { 6845 return _isPopUp; 6846 } 6847 public function set isPopUp(value:Boolean):void 6848 { 6849 _isPopUp = value; 6850 } 6851 6852 //-------------------------------------------------------------------------- 6853 // 6854 // Properties: Required to support automated testing 6855 // 6856 //-------------------------------------------------------------------------- 6857 6858 //---------------------------------- 6859 // automationDelegate 6860 //---------------------------------- 6861 6862 /** 6863 * @private 6864 */ 6865 private var _automationDelegate:IAutomationObject; 6866 6867 /** 6868 * The delegate object that handles the automation-related functionality. 6869 * 6870 * @langversion 3.0 6871 * @playerversion Flash 9 6872 * @playerversion AIR 1.1 6873 * @productversion Flex 3 6874 */ 6875 public function get automationDelegate():Object 6876 { 6877 return _automationDelegate; 6878 } 6879 6880 /** 6881 * @private 6882 */ 6883 public function set automationDelegate(value:Object):void 6884 { 6885 _automationDelegate = value as IAutomationObject; 6886 } 6887 6888 //---------------------------------- 6889 // automationName 6890 //---------------------------------- 6891 6892 /** 6893 * @private 6894 * Storage for the <code>automationName</code> property. 6895 */ 6896 private var _automationName:String = null; 6897 6898 /** 6899 * @inheritDoc 6900 * 6901 * @langversion 3.0 6902 * @playerversion Flash 9 6903 * @playerversion AIR 1.1 6904 * @productversion Flex 3 6905 */ 6906 public function get automationName():String 6907 { 6908 if (_automationName) 6909 return _automationName; 6910 if (automationDelegate) 6911 return automationDelegate.automationName; 6912 6913 return ""; 6914 } 6915 6916 /** 6917 * @private 6918 */ 6919 public function set automationName(value:String):void 6920 { 6921 _automationName = value; 6922 } 6923 6924 /** 6925 * @copy mx.automation.IAutomationObject#automationValue 6926 * 6927 * @langversion 3.0 6928 * @playerversion Flash 9 6929 * @playerversion AIR 1.1 6930 * @productversion Flex 3 6931 */ 6932 public function get automationValue():Array 6933 { 6934 if (automationDelegate) 6935 return automationDelegate.automationValue; 6936 6937 return []; 6938 } 6939 6940 //---------------------------------- 6941 // showInAutomationHierarchy 6942 //---------------------------------- 6943 6944 /** 6945 * @private 6946 * Storage for the <code>showInAutomationHierarchy</code> property. 6947 */ 6948 private var _showInAutomationHierarchy:Boolean = true; 6949 6950 /** 6951 * @inheritDoc 6952 * 6953 * @langversion 3.0 6954 * @playerversion Flash 9 6955 * @playerversion AIR 1.1 6956 * @productversion Flex 3 6957 */ 6958 public function get showInAutomationHierarchy():Boolean 6959 { 6960 return _showInAutomationHierarchy; 6961 } 6962 6963 /** 6964 * @private 6965 */ 6966 public function set showInAutomationHierarchy(value:Boolean):void 6967 { 6968 _showInAutomationHierarchy = value; 6969 } 6970 6971 //-------------------------------------------------------------------------- 6972 // 6973 // Properties Validation 6974 // 6975 //-------------------------------------------------------------------------- 6976 6977 //---------------------------------- 6978 // errorString 6979 //---------------------------------- 6980 6981 /** 6982 * @private 6983 * Storage for errorString property. 6984 */ 6985 mx_internal var _errorString:String = ""; 6986 6987 /** 6988 * @private 6989 * Storage for previous errorString property. 6990 */ 6991 private var oldErrorString:String = ""; 6992 6993 /** 6994 * @private 6995 * Individual error messages from validators 6996 */ 6997 private var errorArray:Array; 6998 6999 /** 7000 * @private 7001 * Array of validators who gave error messages 7002 */ 7003 private var errorObjectArray:Array; 7004 7005 /** 7006 * @private 7007 * Flag set when error string changes. 7008 */ 7009 private var errorStringChanged:Boolean = false; 7010 7011 [Bindable("errorStringChanged")] 7012 7013 /** 7014 * The text that displayed by a component's error tip when a 7015 * component is monitored by a Validator and validation fails. 7016 * 7017 * <p>You can use the <code>errorString</code> property to show a 7018 * validation error for a component, without actually using a validator class. 7019 * When you write a String value to the <code>errorString</code> property, 7020 * Flex draws a red border around the component to indicate the validation error, 7021 * and the String appears in a tooltip as the validation error message when you move 7022 * the mouse over the component, just as if a validator detected a validation error.</p> 7023 * 7024 * <p>To clear the validation error, write an empty String, "", 7025 * to the <code>errorString</code> property.</p> 7026 * 7027 * <p>Note that writing a value to the <code>errorString</code> property 7028 * does not trigger the valid or invalid events; it only changes the border 7029 * color and displays the validation error message.</p> 7030 * 7031 * @langversion 3.0 7032 * @playerversion Flash 9 7033 * @playerversion AIR 1.1 7034 * @productversion Flex 3 7035 */ 7036 public function get errorString():String 7037 { 7038 return _errorString; 7039 } 7040 7041 /** 7042 * @private 7043 */ 7044 public function set errorString(value:String):void 7045 { 7046 if (value == _errorString) 7047 return; 7048 7049 oldErrorString = _errorString; 7050 _errorString = value; 7051 7052 errorStringChanged = true; 7053 invalidateProperties(); 7054 dispatchEvent(new Event("errorStringChanged")); 7055 } 7056 7057 /** 7058 * @private 7059 * Set the appropriate borderColor based on errorString. 7060 * If we have an errorString, use errorColor. If we don't 7061 * have an errorString, restore the original borderColor. 7062 */ 7063 private function setBorderColorForErrorString():void 7064 { 7065 var showErrorSkin:Boolean = FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0 || getStyle("showErrorSkin"); 7066 7067 if (showErrorSkin) 7068 { 7069 7070 if (!_errorString || _errorString.length == 0) 7071 { 7072 if (!isNaN(origBorderColor)) 7073 { 7074 setStyle("borderColor", origBorderColor); 7075 saveBorderColor = true; 7076 } 7077 } 7078 else 7079 { 7080 // Remember the original border color 7081 if (saveBorderColor) 7082 { 7083 saveBorderColor = false; 7084 origBorderColor = getStyle("borderColor"); 7085 } 7086 7087 setStyle("borderColor", getStyle("errorColor")); 7088 } 7089 7090 styleChanged("themeColor"); 7091 7092 var focusManager:IFocusManager = focusManager; 7093 var focusObj:DisplayObject = focusManager ? 7094 DisplayObject(focusManager.getFocus()) : 7095 null; 7096 if (focusManager && focusManager.showFocusIndicator && 7097 focusObj == this) 7098 { 7099 drawFocus(true); 7100 } 7101 7102 } 7103 } 7104 7105 //---------------------------------- 7106 // validationSubField 7107 //---------------------------------- 7108 7109 /** 7110 * @private 7111 * Storage for the validationSubField property. 7112 */ 7113 private var _validationSubField:String; 7114 7115 /** 7116 * Used by a validator to associate a subfield with this component. 7117 * 7118 * @langversion 3.0 7119 * @playerversion Flash 9 7120 * @playerversion AIR 1.1 7121 * @productversion Flex 3 7122 */ 7123 public function get validationSubField():String 7124 { 7125 return _validationSubField; 7126 } 7127 7128 /** 7129 * @private 7130 */ 7131 public function set validationSubField(value:String):void 7132 { 7133 _validationSubField = value; 7134 } 7135 7136 //-------------------------------------------------------------------------- 7137 // 7138 // Overridden methods 7139 // 7140 //-------------------------------------------------------------------------- 7141 7142 /** 7143 * @private 7144 */ 7145 override public function addChild(child:DisplayObject):DisplayObject 7146 { 7147 var formerParent:DisplayObjectContainer = child.parent; 7148 if (formerParent && !(formerParent is Loader)) 7149 formerParent.removeChild(child); 7150 7151 // If there is an overlay, place the child underneath it. 7152 var index:int = effectOverlayReferenceCount && child != effectOverlay ? 7153 Math.max(0, super.numChildren - 1) : 7154 super.numChildren; 7155 7156 // Do anything that needs to be done before the child is added. 7157 // When adding a child to UIComponent, this will set the child's 7158 // virtual parent, its nestLevel, its document, etc. 7159 // When adding a child to a Container, the override will also 7160 // invalidate the container, adjust its content/chrome partitions, 7161 // etc. 7162 addingChild(child); 7163 7164 // Call a low-level player method in DisplayObjectContainer which 7165 // actually attaches the child to this component. 7166 // The player dispatches an "added" event from the child just after 7167 // it is attached, so all "added" handlers execute during this call. 7168 // UIComponent registers an addedHandler() in its constructor, 7169 // which makes it runs before any other "added" handlers except 7170 // capture-phase ones; it sets up the child's styles. 7171 $addChildAt(child, index); 7172 7173 // Do anything that needs to be done after the child is added 7174 // and after all "added" handlers have executed. 7175 // This is where 7176 childAdded(child); 7177 7178 return child; 7179 } 7180 7181 /** 7182 * @private 7183 */ 7184 override public function addChildAt(child:DisplayObject, 7185 index:int):DisplayObject 7186 { 7187 var formerParent:DisplayObjectContainer = child.parent; 7188 if (formerParent && !(formerParent is Loader)) 7189 formerParent.removeChild(child); 7190 7191 // If there is an overlay, place the child underneath it. 7192 if (effectOverlayReferenceCount && child != effectOverlay) 7193 index = Math.min(index, Math.max(0, super.numChildren - 1)); 7194 7195 addingChild(child); 7196 7197 $addChildAt(child, index); 7198 7199 childAdded(child); 7200 7201 return child; 7202 } 7203 7204 /** 7205 * @private 7206 */ 7207 override public function removeChild(child:DisplayObject):DisplayObject 7208 { 7209 removingChild(child); 7210 7211 $removeChild(child); 7212 7213 childRemoved(child); 7214 7215 return child; 7216 } 7217 7218 7219 /** 7220 * @private 7221 */ 7222 override public function removeChildAt(index:int):DisplayObject 7223 { 7224 var child:DisplayObject = getChildAt(index); 7225 7226 removingChild(child); 7227 7228 $removeChild(child); 7229 7230 childRemoved(child); 7231 7232 return child; 7233 } 7234 7235 /** 7236 * @private 7237 */ 7238 override public function setChildIndex(child:DisplayObject, 7239 newIndex:int):void 7240 { 7241 // Place the child underneath the overlay. 7242 if (effectOverlayReferenceCount && child != effectOverlay) 7243 newIndex = Math.min(newIndex, Math.max(0, super.numChildren - 2)); 7244 7245 super.setChildIndex(child, newIndex); 7246 } 7247 7248 /** 7249 * @private 7250 */ 7251 override public function stopDrag():void 7252 { 7253 super.stopDrag(); 7254 7255 invalidateProperties(); 7256 7257 dispatchEvent(new Event("xChanged")); 7258 dispatchEvent(new Event("yChanged")); 7259 } 7260 7261 //-------------------------------------------------------------------------- 7262 // 7263 // Methods: Access to overridden methods of base classes 7264 // 7265 //-------------------------------------------------------------------------- 7266 7267 /** 7268 * @private 7269 * This method allows access to the Player's native implementation 7270 * of addChild(), which can be useful since components 7271 * can override addChild() and thereby hide the native implementation. 7272 * Note that this "base method" is final and cannot be overridden, 7273 * so you can count on it to reflect what is happening at the player level. 7274 */ 7275 mx_internal final function $addChild(child:DisplayObject):DisplayObject 7276 { 7277 return super.addChild(child); 7278 } 7279 7280 /** 7281 * @private 7282 * This method allows access to the Player's native implementation 7283 * of addChildAt(), which can be useful since components 7284 * can override addChildAt() and thereby hide the native implementation. 7285 * Note that this "base method" is final and cannot be overridden, 7286 * so you can count on it to reflect what is happening at the player level. 7287 */ 7288 mx_internal final function $addChildAt(child:DisplayObject, 7289 index:int):DisplayObject 7290 { 7291 return super.addChildAt(child, index); 7292 } 7293 7294 /** 7295 * @private 7296 * This method allows access to the Player's native implementation 7297 * of removeChild(), which can be useful since components 7298 * can override removeChild() and thereby hide the native implementation. 7299 * Note that this "base method" is final and cannot be overridden, 7300 * so you can count on it to reflect what is happening at the player level. 7301 */ 7302 mx_internal final function $removeChild(child:DisplayObject):DisplayObject 7303 { 7304 return super.removeChild(child); 7305 } 7306 7307 /** 7308 * @private 7309 * This method allows access to the Player's native implementation 7310 * of removeChildAt(), which can be useful since components 7311 * can override removeChildAt() and thereby hide the native implementation. 7312 * Note that this "base method" is final and cannot be overridden, 7313 * so you can count on it to reflect what is happening at the player level. 7314 */ 7315 mx_internal final function $removeChildAt(index:int):DisplayObject 7316 { 7317 return super.removeChildAt(index); 7318 } 7319 7320 /** 7321 * @private 7322 * This method allows access to the Player's native implementation 7323 * of setChildIndex(), which can be useful since components 7324 * can override setChildIndex() and thereby hide the native implementation. 7325 * Note that this "base method" is final and cannot be overridden, 7326 * so you can count on it to reflect what is happening at the player level. 7327 */ 7328 mx_internal final function $setChildIndex(child:DisplayObject, index:int):void 7329 { 7330 super.setChildIndex(child, index); 7331 } 7332 7333 //-------------------------------------------------------------------------- 7334 // 7335 // Methods: Initialization 7336 // 7337 //-------------------------------------------------------------------------- 7338 7339 /** 7340 * @private 7341 */ 7342 mx_internal function updateCallbacks():void 7343 { 7344 if (invalidateDisplayListFlag) 7345 UIComponentGlobals.layoutManager.invalidateDisplayList(this); 7346 7347 if (invalidateSizeFlag) 7348 UIComponentGlobals.layoutManager.invalidateSize(this); 7349 7350 if (invalidatePropertiesFlag) 7351 UIComponentGlobals.layoutManager.invalidateProperties(this); 7352 7353 // systemManager getter tries to set the internal _systemManager varaible 7354 // if it is null. Hence a call to the getter is necessary. 7355 // Stage can be null when an untrusted application is loaded by an application 7356 // that isn't on stage yet. 7357 if (systemManager && (_systemManager.stage || usingBridge)) 7358 { 7359 if (methodQueue.length > 0 && !listeningForRender) 7360 { 7361 _systemManager.addEventListener(FlexEvent.RENDER, callLaterDispatcher); 7362 _systemManager.addEventListener(FlexEvent.ENTER_FRAME, callLaterDispatcher); 7363 listeningForRender = true; 7364 } 7365 7366 if (_systemManager.stage) 7367 _systemManager.stage.invalidate(); 7368 } 7369 } 7370 7371 /** 7372 * Called by Flex when a UIComponent object is added to or removed from a parent. 7373 * Developers typically never need to call this method. 7374 * 7375 * @param p The parent of this UIComponent object. 7376 * 7377 * @langversion 3.0 7378 * @playerversion Flash 9 7379 * @playerversion AIR 1.1 7380 * @productversion Flex 3 7381 */ 7382 public function parentChanged(p:DisplayObjectContainer):void 7383 { 7384 // trace("parentChanged: " + _parent + " of " + this + " changed to "); 7385 7386 if (!p) 7387 { 7388 _parent = null; 7389 nestLevel = 0; 7390 } 7391 else if (p is IStyleClient) 7392 { 7393 _parent = p; 7394 } 7395 else if (p is ISystemManager) 7396 { 7397 _parent = p; 7398 } 7399 else 7400 { 7401 _parent = p.parent; 7402 } 7403 7404 // trace(" " + p); 7405 parentChangedFlag = true; 7406 } 7407 7408 /** 7409 * @private 7410 */ 7411 mx_internal function addingChild(child:DisplayObject):void 7412 { 7413 // If the document property isn't already set on the child, 7414 // set it to be the same as this component's document. 7415 // The document setter will recursively set it on any 7416 // descendants of the child that exist. 7417 if (child is IUIComponent && 7418 !IUIComponent(child).document) 7419 { 7420 IUIComponent(child).document = document ? 7421 document : 7422 FlexGlobals.topLevelApplication; 7423 } 7424 7425 // Propagate moduleFactory to the child, but don't overwrite an existing moduleFactory. 7426 if (child is IFlexModule && IFlexModule(child).moduleFactory == null) 7427 { 7428 if (moduleFactory != null) 7429 IFlexModule(child).moduleFactory = moduleFactory; 7430 7431 else if (document is IFlexModule && document.moduleFactory != null) 7432 IFlexModule(child).moduleFactory = document.moduleFactory; 7433 7434 else if (parent is IFlexModule && IFlexModule(parent).moduleFactory != null) 7435 IFlexModule(child).moduleFactory = IFlexModule(parent).moduleFactory; 7436 } 7437 7438 // Set the font context in non-UIComponent children. 7439 // UIComponent children use moduleFactory. 7440 if (child is IFontContextComponent && !(child is UIComponent) && 7441 IFontContextComponent(child).fontContext == null) 7442 IFontContextComponent(child).fontContext = moduleFactory; 7443 7444 if (child is IUIComponent) 7445 IUIComponent(child).parentChanged(this); 7446 7447 // Set the nestLevel of the child to be one greater 7448 // than the nestLevel of this component. 7449 // The nestLevel setter will recursively set it on any 7450 // descendants of the child that exist. 7451 if (child is ILayoutManagerClient) 7452 ILayoutManagerClient(child).nestLevel = nestLevel + 1; 7453 else if (child is IUITextField) 7454 IUITextField(child).nestLevel = nestLevel + 1; 7455 7456 if (child is InteractiveObject) 7457 if (doubleClickEnabled) 7458 InteractiveObject(child).doubleClickEnabled = true; 7459 7460 // Sets up the inheritingStyles and nonInheritingStyles objects 7461 // and their proto chains so that getStyle() works. 7462 // If this object already has some children, 7463 // then reinitialize the children's proto chains. 7464 if (child is IStyleClient) 7465 IStyleClient(child).regenerateStyleCache(true); 7466 else if (child is IUITextField && IUITextField(child).inheritingStyles) 7467 StyleProtoChain.initTextField(IUITextField(child)); 7468 7469 if (child is ISimpleStyleClient) 7470 ISimpleStyleClient(child).styleChanged(null); 7471 7472 if (child is IStyleClient) 7473 IStyleClient(child).notifyStyleChangeInChildren(null, true); 7474 7475 if (child is UIComponent) 7476 UIComponent(child).initThemeColor(); 7477 7478 // Inform the component that it's style properties 7479 // have been fully initialized. Most components won't care, 7480 // but some need to react to even this early change. 7481 if (child is UIComponent) 7482 UIComponent(child).stylesInitialized(); 7483 } 7484 7485 /** 7486 * @private 7487 */ 7488 mx_internal function childAdded(child:DisplayObject):void 7489 { 7490 if (!UIComponentGlobals.designMode) 7491 { 7492 if (child is UIComponent) 7493 { 7494 if (!UIComponent(child).initialized) 7495 UIComponent(child).initialize(); 7496 } 7497 else if (child is IUIComponent) 7498 { 7499 IUIComponent(child).initialize(); 7500 } 7501 } 7502 else 7503 { 7504 try 7505 { 7506 if (child is UIComponent) 7507 { 7508 if (!UIComponent(child).initialized) 7509 UIComponent(child).initialize(); 7510 } 7511 else if (child is IUIComponent) 7512 { 7513 IUIComponent(child).initialize(); 7514 } 7515 } 7516 catch (e:Error) 7517 { 7518 // Dispatch a initializeError dynamic event for tooling. 7519 var initializeErrorEvent:DynamicEvent = new DynamicEvent("initializeError"); 7520 initializeErrorEvent.error = e; 7521 initializeErrorEvent.source = child; 7522 systemManager.dispatchEvent(initializeErrorEvent); 7523 } 7524 } 7525 } 7526 7527 /** 7528 * @private 7529 */ 7530 mx_internal function removingChild(child:DisplayObject):void 7531 { 7532 } 7533 7534 /** 7535 * @private 7536 */ 7537 mx_internal function childRemoved(child:DisplayObject):void 7538 { 7539 if (child is IUIComponent) 7540 { 7541 // only reset document if the child isn't 7542 // a document itself 7543 if (IUIComponent(child).document != child) 7544 IUIComponent(child).document = null; 7545 IUIComponent(child).parentChanged(null); 7546 } 7547 } 7548 7549 /** 7550 * Initializes the internal structure of this component. 7551 * 7552 * <p>Initializing a UIComponent is the fourth step in the creation 7553 * of a visual component instance, and happens automatically 7554 * the first time that the instance is added to a parent. 7555 * Therefore, you do not generally need to call 7556 * <code>initialize()</code>; the Flex framework calls it for you 7557 * from UIComponent's override of the <code>addChild()</code> 7558 * and <code>addChildAt()</code> methods.</p> 7559 * 7560 * <p>The first step in the creation of a visual component instance 7561 * is construction, with the <code>new</code> operator:</p> 7562 * 7563 * <pre> 7564 * var okButton:Button = new Button();</pre> 7565 * 7566 * <p>After construction, the new Button instance is a solitary 7567 * DisplayObject; it does not yet have a UITextField as a child 7568 * to display its label, and it doesn't have a parent.</p> 7569 * 7570 * <p>The second step is configuring the newly-constructed instance 7571 * with the appropriate properties, styles, and event handlers:</p> 7572 * 7573 * <pre> 7574 * okButton.label = "OK"; 7575 * okButton.setStyle("cornerRadius", 0); 7576 * okButton.addEventListener(MouseEvent.CLICK, clickHandler);</pre> 7577 * 7578 * <p>The third step is adding the instance to a parent:</p> 7579 * 7580 * <pre> 7581 * someContainer.addChild(okButton);</pre> 7582 * 7583 * <p>A side effect of calling <code>addChild()</code> 7584 * or <code>addChildAt()</code>, when adding a component to a parent 7585 * for the first time, is that <code>initialize</code> gets 7586 * automatically called.</p> 7587 * 7588 * <p>This method first dispatches a <code>preinitialize</code> event, 7589 * giving developers using this component a chance to affect it 7590 * before its internal structure has been created. 7591 * Next it calls the <code>createChildren()</code> method 7592 * to create the component's internal structure; for a Button, 7593 * this method creates and adds the UITextField for the label. 7594 * Then it dispatches an <code>initialize</code> event, 7595 * giving developers a chance to affect the component 7596 * after its internal structure has been created.</p> 7597 * 7598 * <p>Note that it is the act of attaching a component to a parent 7599 * for the first time that triggers the creation of its internal structure. 7600 * If its internal structure includes other UIComponents, then this is a 7601 * recursive process in which the tree of DisplayObjects grows by one leaf 7602 * node at a time.</p> 7603 * 7604 * <p>If you are writing a component, you do not need 7605 * to override this method.</p> 7606 * 7607 * @langversion 3.0 7608 * @playerversion Flash 9 7609 * @playerversion AIR 1.1 7610 * @productversion Flex 3 7611 */ 7612 public function initialize():void 7613 { 7614 if (initialized) 7615 return; 7616 7617 // The "preinitialize" event gets dispatched after everything about this 7618 // DisplayObject has been initialized, and it has been attached to 7619 // its parent, but before any of its children have been created. 7620 // This allows a "preinitialize" event handler to set properties which 7621 // affect child creation. 7622 // Note that this implies that "preinitialize" handlers are called 7623 // top-down; i.e., parents before children. 7624 dispatchEvent(new FlexEvent(FlexEvent.PREINITIALIZE)); 7625 7626 // Create child objects. 7627 7628 CONFIG::performanceInstrumentation 7629 { 7630 var perfUtil:mx.utils.PerfUtil = mx.utils.PerfUtil.getInstance(); 7631 var token:int = perfUtil.markStart(); 7632 } 7633 7634 createChildren(); 7635 7636 CONFIG::performanceInstrumentation 7637 { 7638 perfUtil.markEnd(".createChildren()", token, 2 /*tolerance*/, this); 7639 } 7640 7641 childrenCreated(); 7642 7643 // Create and initialize the accessibility implementation. 7644 // for this component. For some components accessible object is attached 7645 // to child component so it should be called after createChildren 7646 initializeAccessibility(); 7647 7648 // This should always be the last thing that initialize() calls. 7649 initializationComplete(); 7650 } 7651 7652 /** 7653 * Finalizes the initialization of this component. 7654 * 7655 * <p>This method is the last code that executes when you add a component 7656 * to a parent for the first time using <code>addChild()</code> 7657 * or <code>addChildAt()</code>. 7658 * It handles some housekeeping related to dispatching 7659 * the <code>initialize</code> event. 7660 * If you are writing a component, you do not need 7661 * to override this method.</p> 7662 * 7663 * @langversion 3.0 7664 * @playerversion Flash 9 7665 * @playerversion AIR 1.1 7666 * @productversion Flex 3 7667 */ 7668 protected function initializationComplete():void 7669 { 7670 processedDescriptors = true; 7671 } 7672 7673 /** 7674 * Initializes this component's accessibility code. 7675 * 7676 * <p>This method is called by the <code>initialize()</code> method to hook in the 7677 * component's accessibility code, which resides in a separate class 7678 * in the mx.accessibility package. 7679 * Each subclass that supports accessibility must override this method 7680 * because the hook-in process uses a different static variable 7681 * in each subclass.</p> 7682 * 7683 * @langversion 3.0 7684 * @playerversion Flash 9 7685 * @playerversion AIR 1.1 7686 * @productversion Flex 3 7687 */ 7688 protected function initializeAccessibility():void 7689 { 7690 if (UIComponent.createAccessibilityImplementation != null) 7691 UIComponent.createAccessibilityImplementation(this); 7692 } 7693 7694 /** 7695 * Initializes various properties which keep track of repeated instances 7696 * of this component. 7697 * 7698 * <p>An MXML <code><mx:Repeater/></code> tag can cause repeated instances 7699 * of a component to be created, one instance for each item in the 7700 * Repeater's data provider. 7701 * The <code>instanceIndices</code>, <code>repeaters</code>, 7702 * and <code>repeaterIndices</code> properties of UIComponent 7703 * keep track of which instance came from which data item 7704 * and which Repeater.</p> 7705 * 7706 * <p>This method is an internal method which is automatically called 7707 * by the Flex framework. 7708 * You do not have to call it or override it.</p> 7709 * 7710 * @param parent The parent object containing the Repeater that created 7711 * this component. 7712 * 7713 * @langversion 3.0 7714 * @playerversion Flash 9 7715 * @playerversion AIR 1.1 7716 * @productversion Flex 3 7717 */ 7718 public function initializeRepeaterArrays(parent:IRepeaterClient):void 7719 { 7720 // In the case, where the parent is a document, but isn't the 7721 // child's document, we want to copy the instanceIndices down. 7722 // See SDK-15317. 7723 if (parent && parent.instanceIndices && 7724 ((!parent.isDocument) || (parent != descriptor.document)) && 7725 !_instanceIndices) 7726 { 7727 _instanceIndices = parent.instanceIndices; 7728 _repeaters = parent.repeaters; 7729 _repeaterIndices = parent.repeaterIndices; 7730 } 7731 } 7732 7733 /** 7734 * Create child objects of the component. 7735 * This is an advanced method that you might override 7736 * when creating a subclass of UIComponent. 7737 * 7738 * <p>A component that creates other components or objects within it is called a composite component. 7739 * For example, the Flex ComboBox control is actually made up of a TextInput control 7740 * to define the text area of the ComboBox, and a Button control to define the ComboBox arrow. 7741 * Components implement the <code>createChildren()</code> method to create child 7742 * objects (such as other components) within the component.</p> 7743 * 7744 * <p>From within an override of the <code>createChildren()</code> method, 7745 * you call the <code>addChild()</code> method to add each child object. </p> 7746 * 7747 * <p>You do not call this method directly. Flex calls the 7748 * <code>createChildren()</code> method in response to the call to 7749 * the <code>addChild()</code> method to add the component to its parent. </p> 7750 * 7751 * @langversion 3.0 7752 * @playerversion Flash 9 7753 * @playerversion AIR 1.1 7754 * @productversion Flex 3 7755 */ 7756 protected function createChildren():void 7757 { 7758 } 7759 7760 /** 7761 * Performs any final processing after child objects are created. 7762 * This is an advanced method that you might override 7763 * when creating a subclass of UIComponent. 7764 * 7765 * @langversion 3.0 7766 * @playerversion Flash 9 7767 * @playerversion AIR 1.1 7768 * @productversion Flex 3 7769 */ 7770 protected function childrenCreated():void 7771 { 7772 invalidateProperties(); 7773 invalidateSize(); 7774 invalidateDisplayList(); 7775 } 7776 7777 7778 //-------------------------------------------------------------------------- 7779 // 7780 // Methods: Invalidation 7781 // 7782 //-------------------------------------------------------------------------- 7783 7784 /** 7785 * Marks a component so that its <code>commitProperties()</code> 7786 * method gets called during a later screen update. 7787 * 7788 * <p>Invalidation is a useful mechanism for eliminating duplicate 7789 * work by delaying processing of changes to a component until a 7790 * later screen update. 7791 * For example, if you want to change the text color and size, 7792 * it would be wasteful to update the color immediately after you 7793 * change it and then update the size when it gets set. 7794 * It is more efficient to change both properties and then render 7795 * the text with its new size and color once.</p> 7796 * 7797 * <p>Invalidation methods rarely get called. 7798 * In general, setting a property on a component automatically 7799 * calls the appropriate invalidation method.</p> 7800 * 7801 * @langversion 3.0 7802 * @playerversion Flash 9 7803 * @playerversion AIR 1.1 7804 * @productversion Flex 3 7805 */ 7806 public function invalidateProperties():void 7807 { 7808 if (!invalidatePropertiesFlag) 7809 { 7810 invalidatePropertiesFlag = true; 7811 7812 if (nestLevel && UIComponentGlobals.layoutManager) 7813 UIComponentGlobals.layoutManager.invalidateProperties(this); 7814 } 7815 } 7816 7817 /** 7818 * Marks a component so that its <code>measure()</code> 7819 * method gets called during a later screen update. 7820 * 7821 * <p>Invalidation is a useful mechanism for eliminating duplicate 7822 * work by delaying processing of changes to a component until a 7823 * later screen update. 7824 * For example, if you want to change the text and font size, 7825 * it would be wasteful to update the text immediately after you 7826 * change it and then update the size when it gets set. 7827 * It is more efficient to change both properties and then render 7828 * the text with its new size once.</p> 7829 * 7830 * <p>Invalidation methods rarely get called. 7831 * In general, setting a property on a component automatically 7832 * calls the appropriate invalidation method.</p> 7833 * 7834 * @langversion 3.0 7835 * @playerversion Flash 9 7836 * @playerversion AIR 1.1 7837 * @productversion Flex 3 7838 */ 7839 public function invalidateSize():void 7840 { 7841 if (!invalidateSizeFlag) 7842 { 7843 invalidateSizeFlag = true; 7844 7845 if (nestLevel && UIComponentGlobals.layoutManager) 7846 UIComponentGlobals.layoutManager.invalidateSize(this); 7847 } 7848 } 7849 7850 /** 7851 * Helper method to invalidate parent size and display list if 7852 * this object affects its layout (includeInLayout is true). 7853 * 7854 * @langversion 3.0 7855 * @playerversion Flash 9 7856 * @playerversion AIR 1.1 7857 * @productversion Flex 3 7858 */ 7859 protected function invalidateParentSizeAndDisplayList():void 7860 { 7861 if (!includeInLayout) 7862 return; 7863 7864 var p:IInvalidating = parent as IInvalidating; 7865 if (!p) 7866 return; 7867 7868 p.invalidateSize(); 7869 p.invalidateDisplayList(); 7870 } 7871 7872 /** 7873 * Marks a component so that its <code>updateDisplayList()</code> 7874 * method gets called during a later screen update. 7875 * 7876 * <p>Invalidation is a useful mechanism for eliminating duplicate 7877 * work by delaying processing of changes to a component until a 7878 * later screen update. 7879 * For example, if you want to change the width and height, 7880 * it would be wasteful to update the component immediately after you 7881 * change the width and then update again with the new height. 7882 * It is more efficient to change both properties and then render 7883 * the component with its new size once.</p> 7884 * 7885 * <p>Invalidation methods rarely get called. 7886 * In general, setting a property on a component automatically 7887 * calls the appropriate invalidation method.</p> 7888 * 7889 * @langversion 3.0 7890 * @playerversion Flash 9 7891 * @playerversion AIR 1.1 7892 * @productversion Flex 3 7893 */ 7894 public function invalidateDisplayList():void 7895 { 7896 if (!invalidateDisplayListFlag) 7897 { 7898 invalidateDisplayListFlag = true; 7899 7900 if (nestLevel && UIComponentGlobals.layoutManager) 7901 UIComponentGlobals.layoutManager.invalidateDisplayList(this); 7902 } 7903 } 7904 7905 private function invalidateTransform():void 7906 { 7907 if (_layoutFeatures && _layoutFeatures.updatePending == false) 7908 { 7909 _layoutFeatures.updatePending = true; 7910 if (nestLevel && UIComponentGlobals.layoutManager && 7911 invalidateDisplayListFlag == false) 7912 { 7913 UIComponentGlobals.layoutManager.invalidateDisplayList(this); 7914 } 7915 } 7916 } 7917 7918 /** 7919 * @inheritDoc 7920 * 7921 * @langversion 3.0 7922 * @playerversion Flash 9 7923 * @playerversion AIR 1.1 7924 * @productversion Flex 3 7925 */ 7926 public function invalidateLayoutDirection():void 7927 { 7928 const parentElt:ILayoutDirectionElement = parent as ILayoutDirectionElement; 7929 const thisLayoutDirection:String = layoutDirection; 7930 7931 // If this element's layoutDirection doesn't match its parent's, then 7932 // set the _layoutFeatures.mirror flag. Similarly, if mirroring isn't 7933 // required, then clear the _layoutFeatures.mirror flag. 7934 7935 const mirror:Boolean = (parentElt) 7936 ? (parentElt.layoutDirection != thisLayoutDirection) 7937 : (LayoutDirection.LTR != thisLayoutDirection); 7938 7939 if ((_layoutFeatures) ? (mirror != _layoutFeatures.mirror) : mirror) 7940 { 7941 if (_layoutFeatures == null) 7942 initAdvancedLayoutFeatures(); 7943 _layoutFeatures.mirror = mirror; 7944 // width may have already been set 7945 _layoutFeatures.layoutWidth = _width; 7946 invalidateTransform(); 7947 } 7948 7949 // Children are notified only if the component's layoutDirection has changed. 7950 if (oldLayoutDirection != layoutDirection) 7951 { 7952 var i:int; 7953 7954 // If we have children, the styleChanged() machinery (via commitProperties()) will 7955 // deal with UIComponent children. We have to deal with IVisualElement and 7956 // ILayoutDirectionElement children that don't support styles, like GraphicElements, here. 7957 if (this is IVisualElementContainer) 7958 { 7959 const thisContainer:IVisualElementContainer = IVisualElementContainer(this); 7960 const thisContainerNumElements:int = thisContainer.numElements; 7961 7962 for (i = 0; i < thisContainerNumElements; i++) 7963 { 7964 var elt:IVisualElement = thisContainer.getElementAt(i); 7965 // Can be null if IUITextField or IUIFTETextField. 7966 if (elt && !(elt is IStyleClient)) 7967 elt.invalidateLayoutDirection(); 7968 } 7969 } 7970 else 7971 { 7972 const thisNumChildren:int = numChildren; 7973 7974 for (i = 0; i < thisNumChildren; i++) 7975 { 7976 var child:DisplayObject = getChildAt(i); 7977 if (!(child is IStyleClient) && child is ILayoutDirectionElement) 7978 ILayoutDirectionElement(child).invalidateLayoutDirection(); 7979 } 7980 } 7981 } 7982 } 7983 7984 private function transformOffsetsChangedHandler(e:Event):void 7985 { 7986 invalidateTransform(); 7987 } 7988 7989 7990 /** 7991 * Flex calls the <code>stylesInitialized()</code> method when 7992 * the styles for a component are first initialized. 7993 * 7994 * <p>This is an advanced method that you might override 7995 * when creating a subclass of UIComponent. Flex guarantees that 7996 * your component's styles are fully initialized before 7997 * the first time your component's <code>measure</code> and 7998 * <code>updateDisplayList</code> methods are called. For most 7999 * components, that is sufficient. But if you need early access to 8000 * your style values, you can override the stylesInitialized() function 8001 * to access style properties as soon as they are initialized the first time.</p> 8002 * 8003 * @langversion 3.0 8004 * @playerversion Flash 9 8005 * @playerversion AIR 1.1 8006 * @productversion Flex 3 8007 */ 8008 public function stylesInitialized():void 8009 { 8010 } 8011 8012 /** 8013 * Detects changes to style properties. When any style property is set, 8014 * Flex calls the <code>styleChanged()</code> method, 8015 * passing to it the name of the style being set. 8016 * 8017 * <p>This is an advanced method that you might override 8018 * when creating a subclass of UIComponent. When you create a custom component, 8019 * you can override the <code>styleChanged()</code> method 8020 * to check the style name passed to it, and handle the change accordingly. 8021 * This lets you override the default behavior of an existing style, 8022 * or add your own custom style properties.</p> 8023 * 8024 * <p>If you handle the style property, your override of 8025 * the <code>styleChanged()</code> method should call the 8026 * <code>invalidateDisplayList()</code> method to cause Flex to execute 8027 * the component's <code>updateDisplayList()</code> method at the next screen update.</p> 8028 * 8029 * @param styleProp The name of the style property, or null if all styles for this 8030 * component have changed. 8031 * 8032 * @langversion 3.0 8033 * @playerversion Flash 9 8034 * @playerversion AIR 1.1 8035 * @productversion Flex 3 8036 */ 8037 public function styleChanged(styleProp:String):void 8038 { 8039 var allStyles:Boolean = !styleProp || styleProp == "styleName"; 8040 8041 StyleProtoChain.styleChanged(this, styleProp); 8042 8043 if (!allStyles) 8044 { 8045 if (hasEventListener(styleProp + "Changed")) 8046 dispatchEvent(new Event(styleProp + "Changed")); 8047 } 8048 else 8049 { 8050 if (hasEventListener("allStylesChanged")) 8051 dispatchEvent(new Event("allStylesChanged")); 8052 } 8053 8054 if (allStyles || styleProp == "layoutDirection") 8055 layoutDirectionCachedValue = LAYOUT_DIRECTION_CACHE_UNSET; 8056 } 8057 8058 /** 8059 * Validate and update the properties and layout of this object 8060 * and redraw it, if necessary. 8061 * 8062 * Processing properties that require substantial computation are normally 8063 * not processed until the script finishes executing. 8064 * For example setting the <code>width</code> property is delayed, because it can 8065 * require recalculating the widths of the objects children or its parent. 8066 * Delaying the processing prevents it from being repeated 8067 * multiple times if the script sets the <code>width</code> property more than once. 8068 * This method lets you manually override this behavior. 8069 * 8070 * @langversion 3.0 8071 * @playerversion Flash 9 8072 * @playerversion AIR 1.1 8073 * @productversion Flex 3 8074 */ 8075 public function validateNow():void 8076 { 8077 UIComponentGlobals.layoutManager.validateClient(this); 8078 } 8079 8080 /** 8081 * @private 8082 * This method is called at the beginning of each getter 8083 * for the baselinePosition property. 8084 * If it returns false, the getter should return NaN 8085 * because the baselinePosition can't be computed. 8086 * If it returns true, the getter can do computations 8087 * like textField.y + textField.baselinePosition 8088 * because these properties will be valid. 8089 */ 8090 mx_internal function validateBaselinePosition():Boolean 8091 { 8092 // If this component isn't parented, 8093 // then it doesn't know its text styles 8094 // and we can't compute a baselinePosition. 8095 if (!parent) 8096 return false; 8097 8098 // If this component hasn't been sized yet, assign it 8099 // an actual size that's based on its explicit or measured size. 8100 // 8101 // TODO (egeorgie): remove this code when all SDK clients 8102 // follow the rule to size first and query baselinePosition later. 8103 if (!setActualSizeCalled && (width == 0 || height == 0)) 8104 { 8105 validateNow(); 8106 8107 var w:Number = getExplicitOrMeasuredWidth(); 8108 var h:Number = getExplicitOrMeasuredHeight(); 8109 8110 setActualSize(w, h); 8111 } 8112 8113 // Ensure that this component's internal TextFields 8114 // are properly laid out, so that we can use 8115 // their locations to compute a baselinePosition. 8116 validateNow(); 8117 8118 8119 return true; 8120 } 8121 8122 /** 8123 * Queues a function to be called later. 8124 * 8125 * <p>Before each update of the screen, Flash Player or AIR calls 8126 * the set of functions that are scheduled for the update. 8127 * Sometimes, a function should be called in the next update 8128 * to allow the rest of the code scheduled for the current 8129 * update to be executed. 8130 * Some features, like effects, can cause queued functions to be 8131 * delayed until the feature completes.</p> 8132 * 8133 * @param method Reference to a method to be executed later. 8134 * 8135 * @param args Array of Objects that represent the arguments to pass to the method. 8136 * 8137 * 8138 * @langversion 3.0 8139 * @playerversion Flash 9 8140 * @playerversion AIR 1.1 8141 * @productversion Flex 3 8142 */ 8143 public function callLater(method:Function, 8144 args:Array /* of Object */ = null):void 8145 { 8146 // trace(">>calllater " + this) 8147 // Push the method and the arguments onto the method queue. 8148 methodQueue.push(new MethodQueueElement(method, args)); 8149 8150 // Register to get the next "render" event 8151 // just before the next rasterization. 8152 var sm:ISystemManager = systemManager; 8153 8154 // Stage can be null when an untrusted application is loaded by an application 8155 // that isn't on stage yet. 8156 if (sm && (sm.stage || usingBridge)) 8157 { 8158 if (!listeningForRender) 8159 { 8160 // trace(" added"); 8161 sm.addEventListener(FlexEvent.RENDER, callLaterDispatcher); 8162 sm.addEventListener(FlexEvent.ENTER_FRAME, callLaterDispatcher); 8163 listeningForRender = true; 8164 } 8165 8166 // Force a "render" event to happen soon 8167 if (sm.stage) 8168 sm.stage.invalidate(); 8169 } 8170 8171 // trace("<<calllater " + this) 8172 } 8173 8174 /** 8175 * @private 8176 * Cancels all queued functions. 8177 */ 8178 mx_internal function cancelAllCallLaters():void 8179 { 8180 var sm:ISystemManager = systemManager; 8181 8182 // Stage can be null when an untrusted application is loaded by an application 8183 // that isn't on stage yet. 8184 if (sm && (sm.stage || usingBridge)) 8185 { 8186 if (listeningForRender) 8187 { 8188 sm.removeEventListener(FlexEvent.RENDER, callLaterDispatcher); 8189 sm.removeEventListener(FlexEvent.ENTER_FRAME, callLaterDispatcher); 8190 listeningForRender = false; 8191 } 8192 } 8193 8194 // Empty the method queue. 8195 methodQueue.splice(0); 8196 } 8197 8198 //-------------------------------------------------------------------------- 8199 // 8200 // Methods: Commitment 8201 // 8202 //-------------------------------------------------------------------------- 8203 8204 /** 8205 * Used by layout logic to validate the properties of a component 8206 * by calling the <code>commitProperties()</code> method. 8207 * In general, subclassers should 8208 * override the <code>commitProperties()</code> method and not this method. 8209 * 8210 * @langversion 3.0 8211 * @playerversion Flash 9 8212 * @playerversion AIR 1.1 8213 * @productversion Flex 3 8214 */ 8215 public function validateProperties():void 8216 { 8217 if (invalidatePropertiesFlag) 8218 { 8219 commitProperties(); 8220 8221 invalidatePropertiesFlag = false; 8222 } 8223 } 8224 8225 /** 8226 * Processes the properties set on the component. 8227 * This is an advanced method that you might override 8228 * when creating a subclass of UIComponent. 8229 * 8230 * <p>You do not call this method directly. 8231 * Flex calls the <code>commitProperties()</code> method when you 8232 * use the <code>addChild()</code> method to add a component to a container, 8233 * or when you call the <code>invalidateProperties()</code> method of the component. 8234 * Calls to the <code>commitProperties()</code> method occur before calls to the 8235 * <code>measure()</code> method. This lets you set property values that might 8236 * be used by the <code>measure()</code> method.</p> 8237 * 8238 * <p>Some components have properties that affect the number or kinds 8239 * of child objects that they need to create, or have properties that 8240 * interact with each other, such as the <code>horizontalScrollPolicy</code> 8241 * and <code>horizontalScrollPosition</code> properties. 8242 * It is often best at startup time to process all of these 8243 * properties at one time to avoid duplicating work.</p> 8244 * 8245 * @langversion 3.0 8246 * @playerversion Flash 9 8247 * @playerversion AIR 1.1 8248 * @productversion Flex 3 8249 */ 8250 protected function commitProperties():void 8251 { 8252 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8253 { 8254 if (_scaleX != oldScaleX) 8255 { 8256 var scalingFactorX:Number = Math.abs(_scaleX / oldScaleX); 8257 if (!isNaN(explicitMinWidth)) 8258 explicitMinWidth *= scalingFactorX; 8259 if (!isNaN(explicitWidth)) 8260 explicitWidth *= scalingFactorX; 8261 if (!isNaN(explicitMaxWidth)) 8262 explicitMaxWidth *= scalingFactorX; 8263 8264 _width *= scalingFactorX; 8265 8266 super.scaleX = oldScaleX = _scaleX; 8267 } 8268 8269 if (_scaleY != oldScaleY) 8270 { 8271 var scalingFactorY:Number = Math.abs(_scaleY / oldScaleY); 8272 if (!isNaN(explicitMinHeight)) 8273 explicitMinHeight *= scalingFactorY; 8274 if (!isNaN(explicitHeight)) 8275 explicitHeight *= scalingFactorY; 8276 if (!isNaN(explicitMaxHeight)) 8277 explicitMaxHeight *= scalingFactorY; 8278 8279 _height *= scalingFactorY; 8280 8281 super.scaleY = oldScaleY = _scaleY; 8282 } 8283 } 8284 else 8285 { 8286 // Handle a deferred state change request. 8287 if (_currentStateDeferred != null) 8288 { 8289 var newState:String = _currentStateDeferred; 8290 _currentStateDeferred = null; 8291 currentState = newState; 8292 } 8293 8294 oldScaleX = scaleX; 8295 oldScaleY = scaleY; 8296 } 8297 8298 // Typically state changes occur immediately, but during 8299 // component initialization we defer until commitProperties to 8300 // reduce a bit of the startup noise. 8301 if (_currentStateChanged && !initialized) 8302 { 8303 _currentStateChanged = false; 8304 commitCurrentState(); 8305 } 8306 8307 if (FlexVersion.compatibilityVersion >= FlexVersion.VERSION_4_0) 8308 { 8309 // If this component's layout direction has changed, or its parent's layoutDirection 8310 // has changed, then call invalidateLayoutDirection(). 8311 const parentUIC:UIComponent = parent as UIComponent; 8312 8313 if ((oldLayoutDirection != layoutDirection) || parentChangedFlag || 8314 (parentUIC && (parentUIC.layoutDirection != parentUIC.oldLayoutDirection))) 8315 invalidateLayoutDirection(); 8316 } 8317 8318 if (x != oldX || y != oldY) 8319 { 8320 dispatchMoveEvent(); 8321 } 8322 8323 if (width != oldWidth || height != oldHeight) 8324 dispatchResizeEvent(); 8325 8326 if (errorStringChanged) 8327 { 8328 errorStringChanged = false; 8329 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0 || getStyle("showErrorTip")) 8330 ToolTipManager.registerErrorString(this, oldErrorString, errorString); 8331 8332 setBorderColorForErrorString(); 8333 } 8334 8335 if (blendModeChanged) 8336 { 8337 blendModeChanged = false; 8338 8339 if (!blendShaderChanged) 8340 { 8341 $blendMode = _blendMode; 8342 } 8343 else 8344 { 8345 // The graphic element's blendMode was set to a non-Flash 8346 // blendMode. We mimic the look by instantiating the 8347 // appropriate shader class and setting the blendShader 8348 // property on the displayObject. 8349 blendShaderChanged = false; 8350 8351 $blendMode = BlendMode.NORMAL; 8352 8353 switch(_blendMode) 8354 { 8355 case "color": 8356 { 8357 $blendShader = new ColorShader(); 8358 break; 8359 } 8360 case "colordodge": 8361 { 8362 $blendShader = new ColorDodgeShader(); 8363 break; 8364 } 8365 case "colorburn": 8366 { 8367 $blendShader = new ColorBurnShader(); 8368 break; 8369 } 8370 case "exclusion": 8371 { 8372 $blendShader = new ExclusionShader(); 8373 break; 8374 } 8375 case "hue": 8376 { 8377 $blendShader = new HueShader(); 8378 break; 8379 } 8380 case "luminosity": 8381 { 8382 $blendShader = new LuminosityShader(); 8383 break; 8384 } 8385 case "saturation": 8386 { 8387 $blendShader = new SaturationShader(); 8388 break; 8389 } 8390 case "softlight": 8391 { 8392 $blendShader = new SoftLightShader(); 8393 break; 8394 } 8395 } 8396 } 8397 } 8398 8399 parentChangedFlag = false; 8400 } 8401 8402 //-------------------------------------------------------------------------- 8403 // 8404 // Methods: Measurement 8405 // 8406 //-------------------------------------------------------------------------- 8407 8408 /** 8409 * @inheritDoc 8410 * 8411 * @langversion 3.0 8412 * @playerversion Flash 9 8413 * @playerversion AIR 1.1 8414 * @productversion Flex 3 8415 */ 8416 public function validateSize(recursive:Boolean = false):void 8417 { 8418 if (recursive) 8419 { 8420 for (var i:int = 0; i < numChildren; i++) 8421 { 8422 var child:DisplayObject = getChildAt(i); 8423 if (child is ILayoutManagerClient ) 8424 (child as ILayoutManagerClient ).validateSize(true); 8425 } 8426 } 8427 8428 if (invalidateSizeFlag) 8429 { 8430 var sizeChanging:Boolean = measureSizes(); 8431 8432 if (sizeChanging && includeInLayout) 8433 { 8434 // TODO (egeorgie): we don't need this invalidateDisplayList() here 8435 // because we'll call it if the parent sets new actual size? 8436 invalidateDisplayList(); 8437 invalidateParentSizeAndDisplayList(); 8438 } 8439 } 8440 } 8441 8442 /** 8443 * Determines if the call to the <code>measure()</code> method can be skipped. 8444 * 8445 * @return Returns <code>true</code> when the <code>measureSizes()</code> method can skip the call to 8446 * the <code>measure()</code> method. For example this is usually <code>true</code> when both <code>explicitWidth</code> and 8447 * <code>explicitHeight</code> are set. For paths, this is <code>true</code> when the bounds of the path 8448 * have not changed. 8449 * 8450 * @langversion 3.0 8451 * @playerversion Flash 9 8452 * @playerversion AIR 1.1 8453 * @productversion Flex 4 8454 */ 8455 protected function canSkipMeasurement():Boolean 8456 { 8457 // We can skip the measure function if the object's width and height 8458 // have been explicitly specified (e.g.: the object's MXML tag has 8459 // attributes like width="50" and height="100"). 8460 // 8461 // If an object's width and height have been explicitly specified, 8462 // then the explicitWidth and explicitHeight properties contain 8463 // Numbers (as opposed to NaN) 8464 return !isNaN(explicitWidth) && !isNaN(explicitHeight); 8465 } 8466 8467 /** 8468 * @private 8469 */ 8470 mx_internal function measureSizes():Boolean 8471 { 8472 var changed:Boolean = false; 8473 8474 if (!invalidateSizeFlag) 8475 return changed; 8476 8477 var scalingFactor:Number; 8478 var newValue:Number; 8479 8480 if (canSkipMeasurement()) 8481 { 8482 invalidateSizeFlag = false; 8483 _measuredMinWidth = 0; 8484 _measuredMinHeight = 0; 8485 } 8486 else 8487 { 8488 var xScale:Number = Math.abs(scaleX); 8489 var yScale:Number = Math.abs(scaleY); 8490 8491 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8492 { 8493 if (xScale != 1.0) 8494 { 8495 _measuredMinWidth /= xScale; 8496 _measuredWidth /= xScale; 8497 } 8498 8499 if (yScale != 1.0) 8500 { 8501 _measuredMinHeight /= yScale; 8502 _measuredHeight /= yScale; 8503 } 8504 } 8505 8506 measure(); 8507 8508 invalidateSizeFlag = false; 8509 8510 if (!isNaN(explicitMinWidth) && measuredWidth < explicitMinWidth) 8511 measuredWidth = explicitMinWidth; 8512 8513 if (!isNaN(explicitMaxWidth) && measuredWidth > explicitMaxWidth) 8514 measuredWidth = explicitMaxWidth; 8515 8516 if (!isNaN(explicitMinHeight) && measuredHeight < explicitMinHeight) 8517 measuredHeight = explicitMinHeight; 8518 8519 if (!isNaN(explicitMaxHeight) && measuredHeight > explicitMaxHeight) 8520 measuredHeight = explicitMaxHeight; 8521 8522 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8523 { 8524 if (xScale != 1.0) 8525 { 8526 _measuredMinWidth *= xScale; 8527 _measuredWidth *= xScale; 8528 } 8529 8530 if (yScale != 1.0) 8531 { 8532 _measuredMinHeight *= yScale; 8533 _measuredHeight *= yScale; 8534 } 8535 } 8536 } 8537 8538 adjustSizesForScaleChanges(); 8539 8540 if (isNaN(oldMinWidth)) 8541 { 8542 // This branch does the same thing as the else branch, 8543 // but it is optimized for the first time that 8544 // measureSizes() is called on this object. 8545 oldMinWidth = !isNaN(explicitMinWidth) ? 8546 explicitMinWidth : 8547 measuredMinWidth; 8548 8549 oldMinHeight = !isNaN(explicitMinHeight) ? 8550 explicitMinHeight : 8551 measuredMinHeight; 8552 8553 oldExplicitWidth = !isNaN(explicitWidth) ? 8554 explicitWidth : 8555 measuredWidth; 8556 8557 oldExplicitHeight = !isNaN(explicitHeight) ? 8558 explicitHeight : 8559 measuredHeight; 8560 8561 changed = true; 8562 } 8563 else 8564 { 8565 newValue = !isNaN(explicitMinWidth) ? 8566 explicitMinWidth : 8567 measuredMinWidth; 8568 if (newValue != oldMinWidth) 8569 { 8570 oldMinWidth = newValue; 8571 changed = true; 8572 } 8573 8574 newValue = !isNaN(explicitMinHeight) ? 8575 explicitMinHeight : 8576 measuredMinHeight; 8577 if (newValue != oldMinHeight) 8578 { 8579 oldMinHeight = newValue; 8580 changed = true; 8581 } 8582 8583 newValue = !isNaN(explicitWidth) ? 8584 explicitWidth : 8585 measuredWidth; 8586 if (newValue != oldExplicitWidth) 8587 { 8588 oldExplicitWidth = newValue; 8589 changed = true; 8590 } 8591 8592 newValue = !isNaN(explicitHeight) ? 8593 explicitHeight : 8594 measuredHeight; 8595 if (newValue != oldExplicitHeight) 8596 { 8597 oldExplicitHeight = newValue; 8598 changed = true; 8599 } 8600 8601 } 8602 8603 return changed; 8604 } 8605 8606 /** 8607 * Calculates the default size, and optionally the default minimum size, 8608 * of the component. This is an advanced method that you might override when 8609 * creating a subclass of UIComponent. 8610 * 8611 * <p>You do not call this method directly. Flex calls the 8612 * <code>measure()</code> method when the component is added to a container 8613 * using the <code>addChild()</code> method, and when the component's 8614 * <code>invalidateSize()</code> method is called. </p> 8615 * 8616 * <p>When you set a specific height and width of a component, 8617 * Flex does not call the <code>measure()</code> method, 8618 * even if you explicitly call the <code>invalidateSize()</code> method. 8619 * That is, Flex only calls the <code>measure()</code> method if 8620 * the <code>explicitWidth</code> property or the <code>explicitHeight</code> 8621 * property of the component is NaN. </p> 8622 * 8623 * <p>In your override of this method, you must set the 8624 * <code>measuredWidth</code> and <code>measuredHeight</code> properties 8625 * to define the default size. 8626 * You can optionally set the <code>measuredMinWidth</code> and 8627 * <code>measuredMinHeight</code> properties to define the default 8628 * minimum size.</p> 8629 * 8630 * <p>Most components calculate these values based on the content they are 8631 * displaying, and from the properties that affect content display. 8632 * A few components simply have hard-coded default values. </p> 8633 * 8634 * <p>The conceptual point of <code>measure()</code> is for the component to provide 8635 * its own natural or intrinsic size as a default. Therefore, the 8636 * <code>measuredWidth</code> and <code>measuredHeight</code> properties 8637 * should be determined by factors such as:</p> 8638 * <ul> 8639 * <li>The amount of text the component needs to display.</li> 8640 * <li>The styles, such as <code>fontSize</code>, for that text.</li> 8641 * <li>The size of a JPEG image that the component displays.</li> 8642 * <li>The measured or explicit sizes of the component's children.</li> 8643 * <li>Any borders, margins, and gaps.</li> 8644 * </ul> 8645 * 8646 * <p>In some cases, there is no intrinsic way to determine default values. 8647 * For example, a simple GreenCircle component might simply set 8648 * measuredWidth = 100 and measuredHeight = 100 in its <code>measure()</code> method to 8649 * provide a reasonable default size. In other cases, such as a TextArea, 8650 * an appropriate computation (such as finding the right width and height 8651 * that would just display all the text and have the aspect ratio of a Golden Rectangle) 8652 * might be too time-consuming to be worthwhile.</p> 8653 * 8654 * <p>The default implementation of <code>measure()</code> 8655 * sets <code>measuredWidth</code>, <code>measuredHeight</code>, 8656 * <code>measuredMinWidth</code>, and <code>measuredMinHeight</code> 8657 * to <code>0</code>.</p> 8658 * 8659 * @langversion 3.0 8660 * @playerversion Flash 9 8661 * @playerversion AIR 1.1 8662 * @productversion Flex 3 8663 */ 8664 protected function measure():void 8665 { 8666 measuredMinWidth = 0; 8667 measuredMinHeight = 0; 8668 measuredWidth = 0; 8669 measuredHeight = 0; 8670 } 8671 8672 /** 8673 * @private 8674 */ 8675 mx_internal function adjustSizesForScaleChanges():void 8676 { 8677 var xScale:Number = scaleX; 8678 var yScale:Number = scaleY; 8679 8680 var scalingFactor:Number; 8681 8682 if (xScale != oldScaleX) 8683 { 8684 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8685 { 8686 scalingFactor = Math.abs(xScale / oldScaleX); 8687 8688 if (explicitMinWidth) 8689 explicitMinWidth *= scalingFactor; 8690 8691 if (!isNaN(explicitWidth)) 8692 explicitWidth *= scalingFactor; 8693 8694 if (explicitMaxWidth) 8695 explicitMaxWidth *= scalingFactor; 8696 } 8697 8698 oldScaleX = xScale; 8699 } 8700 8701 if (yScale != oldScaleY) 8702 { 8703 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8704 { 8705 scalingFactor = Math.abs(yScale / oldScaleY); 8706 8707 if (explicitMinHeight) 8708 explicitMinHeight *= scalingFactor; 8709 8710 if (explicitHeight) 8711 explicitHeight *= scalingFactor; 8712 8713 if (explicitMaxHeight) 8714 explicitMaxHeight *= scalingFactor; 8715 } 8716 8717 oldScaleY = yScale; 8718 } 8719 } 8720 8721 /** 8722 * A convenience method for determining whether to use the 8723 * explicit or measured width 8724 * 8725 * @return A Number which is explicitWidth if defined 8726 * or measuredWidth if not. 8727 * 8728 * @langversion 3.0 8729 * @playerversion Flash 9 8730 * @playerversion AIR 1.1 8731 * @productversion Flex 3 8732 */ 8733 public function getExplicitOrMeasuredWidth():Number 8734 { 8735 return !isNaN(explicitWidth) ? explicitWidth : measuredWidth; 8736 } 8737 8738 /** 8739 * A convenience method for determining whether to use the 8740 * explicit or measured height 8741 * 8742 * @return A Number which is explicitHeight if defined 8743 * or measuredHeight if not. 8744 * 8745 * @langversion 3.0 8746 * @playerversion Flash 9 8747 * @playerversion AIR 1.1 8748 * @productversion Flex 3 8749 */ 8750 public function getExplicitOrMeasuredHeight():Number 8751 { 8752 return !isNaN(explicitHeight) ? explicitHeight : measuredHeight; 8753 } 8754 8755 /** 8756 * A convenience method for determining the unscaled width 8757 * of the component 8758 * All of a component's drawing and child layout should be done 8759 * within a bounding rectangle of this width, which is also passed 8760 * as an argument to <code>updateDisplayList()</code>. 8761 * 8762 * @return A Number which is unscaled width of the component. 8763 * 8764 * @langversion 3.0 8765 * @playerversion Flash 9 8766 * @playerversion AIR 1.1 8767 * @productversion Flex 3 8768 */ 8769 protected function get unscaledWidth():Number 8770 { 8771 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8772 return width / Math.abs(scaleX); 8773 else 8774 return width; 8775 } 8776 8777 /** 8778 * @private 8779 */ 8780 mx_internal function getUnscaledWidth():Number { return unscaledWidth; } 8781 8782 /** 8783 * A convenience method for setting the unscaledWidth of a 8784 * component. 8785 * 8786 * Setting this sets the width of the component as desired 8787 * before any transformation is applied. 8788 * 8789 * @langversion 3.0 8790 * @playerversion Flash 9 8791 * @playerversion AIR 1.1 8792 * @productversion Flex 3 8793 */ 8794 mx_internal function setUnscaledWidth(value:Number):void 8795 { 8796 var newValue:Number = value; 8797 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8798 newValue *= Math.abs(oldScaleX); 8799 if (_explicitWidth == newValue) 8800 return; 8801 8802 // width can be pixel or percent not both 8803 if (!isNaN(newValue)) 8804 _percentWidth = NaN; 8805 8806 _explicitWidth = newValue; 8807 8808 // We invalidate size because locking in width 8809 // may change the measured height in flow-based components. 8810 invalidateSize(); 8811 8812 invalidateParentSizeAndDisplayList(); 8813 } 8814 8815 /** 8816 * A convenience method for determining the unscaled height 8817 * of the component. 8818 * All of a component's drawing and child layout should be done 8819 * within a bounding rectangle of this height, which is also passed 8820 * as an argument to <code>updateDisplayList()</code>. 8821 * 8822 * @return A Number which is unscaled height of the component. 8823 * 8824 * @langversion 3.0 8825 * @playerversion Flash 9 8826 * @playerversion AIR 1.1 8827 * @productversion Flex 3 8828 */ 8829 protected function get unscaledHeight():Number 8830 { 8831 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8832 return height / Math.abs(scaleY); 8833 else 8834 return height; 8835 } 8836 8837 /** 8838 * @private 8839 */ 8840 mx_internal function getUnscaledHeight():Number { return unscaledHeight; } 8841 8842 /** 8843 * A convenience method for setting the unscaledHeight of a 8844 * component. 8845 * 8846 * Setting this sets the height of the component as desired 8847 * before any transformation is applied. 8848 * 8849 * @langversion 3.0 8850 * @playerversion Flash 9 8851 * @playerversion AIR 1.1 8852 * @productversion Flex 3 8853 */ 8854 mx_internal function setUnscaledHeight(value:Number):void 8855 { 8856 var newValue:Number = value; 8857 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8858 newValue *= Math.abs(oldScaleY); 8859 if (_explicitHeight == newValue) 8860 return; 8861 8862 // height can be pixel or percent, not both 8863 if (!isNaN(newValue)) 8864 _percentHeight = NaN; 8865 8866 _explicitHeight = newValue; 8867 8868 // We invalidate size because locking in height 8869 // may change the measured width in flow-based components. 8870 invalidateSize(); 8871 8872 invalidateParentSizeAndDisplayList(); 8873 } 8874 8875 /** 8876 * Measures the specified text, assuming that it is displayed 8877 * in a single-line UITextField (or UIFTETextField) using a UITextFormat 8878 * determined by the styles of this UIComponent. Does not 8879 * work for Spark components since they don't use UITextField 8880 * (or UIFTETextField). To measure text in Spark components, 8881 * get the measurements of a spark.components.Label 8882 * or spark.components.RichText 8883 * 8884 * @param text A String specifying the text to measure. 8885 * 8886 * @return A TextLineMetrics object containing the text measurements. 8887 * 8888 * @langversion 3.0 8889 * @playerversion Flash 9 8890 * @playerversion AIR 1.1 8891 * @productversion Flex 3 8892 */ 8893 public function measureText(text:String):TextLineMetrics 8894 { 8895 return determineTextFormatFromStyles().measureText(text); 8896 } 8897 8898 /** 8899 * Measures the specified HTML text, which can contain HTML tags such 8900 * as <code><font></code> and <code><b></code>, 8901 * assuming that it is displayed 8902 * in a single-line UITextField using a UITextFormat 8903 * determined by the styles of this UIComponent. 8904 * 8905 * @param text A String specifying the HTML text to measure. 8906 * 8907 * @return A TextLineMetrics object containing the text measurements. 8908 * 8909 * @langversion 3.0 8910 * @playerversion Flash 9 8911 * @playerversion AIR 1.1 8912 * @productversion Flex 3 8913 */ 8914 public function measureHTMLText(htmlText:String):TextLineMetrics 8915 { 8916 return determineTextFormatFromStyles().measureHTMLText(htmlText); 8917 } 8918 8919 //-------------------------------------------------------------------------- 8920 // 8921 // Methods: Drawing and Child Layout 8922 // 8923 //-------------------------------------------------------------------------- 8924 8925 /** 8926 * @private 8927 */ 8928 private var lastUnscaledWidth:Number; 8929 /** 8930 * @private 8931 */ 8932 private var lastUnscaledHeight:Number; 8933 8934 /** 8935 * @private 8936 */ 8937 protected function validateMatrix():void 8938 { 8939 if (_layoutFeatures != null && _layoutFeatures.updatePending == true) 8940 { 8941 applyComputedMatrix(); 8942 } 8943 8944 if (_maintainProjectionCenter) 8945 { 8946 var pmatrix:PerspectiveProjection = super.transform.perspectiveProjection; 8947 if (pmatrix != null) 8948 { 8949 pmatrix.projectionCenter = new Point(unscaledWidth/2,unscaledHeight/2); 8950 } 8951 } 8952 } 8953 /** 8954 * @inheritDoc 8955 * 8956 * @langversion 3.0 8957 * @playerversion Flash 9 8958 * @playerversion AIR 1.1 8959 * @productversion Flex 3 8960 */ 8961 public function validateDisplayList():void 8962 { 8963 oldLayoutDirection = layoutDirection; 8964 8965 if (invalidateDisplayListFlag) 8966 { 8967 // Check if our parent is the top level system manager 8968 var sm:ISystemManager = parent as ISystemManager; 8969 if (sm) 8970 { 8971 if (sm.isProxy || (sm == systemManager.topLevelSystemManager && 8972 sm.document != this)) 8973 { 8974 // Size ourself to the new measured width/height This can 8975 // cause the _layoutFeatures computed matrix to become invalid 8976 setActualSize(getExplicitOrMeasuredWidth(), 8977 getExplicitOrMeasuredHeight()); 8978 } 8979 } 8980 8981 // Don't validate transform.matrix until after setting actual size 8982 validateMatrix(); 8983 8984 var unscaledWidth:Number = width; 8985 var unscaledHeight:Number = height; 8986 if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 8987 { 8988 unscaledWidth = scaleX == 0 ? 0 : width / scaleX; 8989 unscaledHeight = scaleY == 0 ? 0 : height / scaleY; 8990 8991 // Use some hysteresis to prevent roundoff errors from 8992 // causing problems as we scale. This isn't a full solution, 8993 // but it helps. 8994 if (Math.abs(unscaledWidth - lastUnscaledWidth) < .00001) 8995 unscaledWidth = lastUnscaledWidth; 8996 if (Math.abs(unscaledHeight - lastUnscaledHeight) < .00001) 8997 unscaledHeight = lastUnscaledHeight; 8998 } 8999 updateDisplayList(unscaledWidth,unscaledHeight); 9000 lastUnscaledWidth = unscaledWidth; 9001 lastUnscaledHeight = unscaledHeight; 9002 9003 invalidateDisplayListFlag = false; 9004 9005 // LAYOUT_DEBUG 9006 // LayoutManager.debugHelper.addElement(ILayoutElement(this)); 9007 } 9008 else 9009 validateMatrix(); 9010 9011 } 9012 9013 /** 9014 * Draws the object and/or sizes and positions its children. 9015 * This is an advanced method that you might override 9016 * when creating a subclass of UIComponent. 9017 * 9018 * <p>You do not call this method directly. Flex calls the 9019 * <code>updateDisplayList()</code> method when the component is added to a container 9020 * using the <code>addChild()</code> method, and when the component's 9021 * <code>invalidateDisplayList()</code> method is called. </p> 9022 * 9023 * <p>If the component has no children, this method 9024 * is where you would do programmatic drawing 9025 * using methods on the component's Graphics object 9026 * such as <code>graphics.drawRect()</code>.</p> 9027 * 9028 * <p>If the component has children, this method is where 9029 * you would call the <code>move()</code> and <code>setActualSize()</code> 9030 * methods on its children.</p> 9031 * 9032 * <p>Components can do programmatic drawing even if 9033 * they have children. In doing either, use the 9034 * component's <code>unscaledWidth</code> and <code>unscaledHeight</code> 9035 * as its bounds.</p> 9036 * 9037 * <p>It is important to use <code>unscaledWidth</code> and 9038 * <code>unscaledHeight</code> instead of the <code>width</code> 9039 * and <code>height</code> properties.</p> 9040 * 9041 * @param unscaledWidth Specifies the width of the component, in pixels, 9042 * in the component's coordinates, regardless of the value of the 9043 * <code>scaleX</code> property of the component. 9044 * 9045 * @param unscaledHeight Specifies the height of the component, in pixels, 9046 * in the component's coordinates, regardless of the value of the 9047 * <code>scaleY</code> property of the component. 9048 * 9049 * @langversion 3.0 9050 * @playerversion Flash 9 9051 * @playerversion AIR 1.1 9052 * @productversion Flex 3 9053 */ 9054 protected function updateDisplayList(unscaledWidth:Number, 9055 unscaledHeight:Number):void 9056 { 9057 } 9058 9059 /** 9060 * Returns a layout constraint value, which is the same as 9061 * getting the constraint style for this component. 9062 * 9063 * @param constraintName The name of the constraint style, which 9064 * can be any of the following: left, right, top, bottom, 9065 * verticalCenter, horizontalCenter, baseline 9066 * 9067 * @return Returns the layout constraint value, which can be 9068 * specified in either of two forms. It can be specified as a 9069 * numeric string, for example, "10" or it can be specified as 9070 * identifier:numeric string. For identifier:numeric string, 9071 * identifier is the <code>id</code> of a ConstraintRow or 9072 * ConstraintColumn. For example, a value of "cc1:10" specifies a 9073 * value of 10 for the ConstraintColumn that has the 9074 * <code>id</code> "cc1." 9075 * 9076 * @langversion 3.0 9077 * @playerversion Flash 9 9078 * @playerversion AIR 1.1 9079 * @productversion Flex 3 9080 */ 9081 public function getConstraintValue(constraintName:String):* 9082 { 9083 return getStyle(constraintName); 9084 } 9085 9086 /** 9087 * Sets a layout constraint value, which is the same as 9088 * setting the constraint style for this component. 9089 * 9090 * @param constraintName The name of the constraint style, which 9091 * can be any of the following: left, right, top, bottom, 9092 * verticalCenter, horizontalCenter, baseline 9093 * 9094 * @param value The value of the constraint can be specified in either 9095 * of two forms. It can be specified as a numeric string, for 9096 * example, "10" or it can be specified as identifier:numeric 9097 * string. For identifier:numeric string, identifier is the 9098 * <code>id</code> of a ConstraintRow or ConstraintColumn. For 9099 * example, a value of "cc1:10" specifies a value of 10 for the 9100 * ConstraintColumn that has the <code>id</code> "cc1." 9101 * 9102 * 9103 * @langversion 3.0 9104 * @playerversion Flash 9 9105 * @playerversion AIR 1.1 9106 * @productversion Flex 3 9107 */ 9108 public function setConstraintValue(constraintName:String, value:*):void 9109 { 9110 setStyle(constraintName, value); 9111 } 9112 9113 [Inspectable(category="General")] 9114 9115 /** 9116 * <p>For components, this layout constraint property is a 9117 * facade on top of the similarly-named style. To set 9118 * a state-specific value of the property in MXML to its default 9119 * value of <code>undefined</code>, 9120 * use the @Clear() directive. For example, in MXML code, 9121 * <code>left.s2="@Clear()"</code> unsets the <code>left</code> 9122 * constraint in state s2. Or in ActionScript code, 9123 * <code>button.left = undefined</code> unsets the <code>left</code> 9124 * constraint on <code>button</code>.</p> 9125 * 9126 * @inheritDoc 9127 * 9128 * @langversion 3.0 9129 * @playerversion Flash 9 9130 * @playerversion AIR 1.1 9131 * @productversion Flex 3 9132 */ 9133 public function get left():Object 9134 { 9135 return getConstraintValue("left"); 9136 } 9137 public function set left(value:Object):void 9138 { 9139 setConstraintValue("left", value != null ? value : undefined); 9140 } 9141 9142 [Inspectable(category="General")] 9143 9144 /** 9145 * <p>For components, this layout constraint property is a 9146 * facade on top of the similarly-named style. To set 9147 * the property to its default value of <code>undefined</code>, 9148 * use the @Clear() directive in MXML or the <code>undefined</code> 9149 * value in ActionScript code. For example, in MXML code, 9150 * <code>right.s2="@Clear()"</code> unsets the <code>right</code> 9151 * constraint in state s2. Or in ActionScript code, 9152 * <code>button.right = undefined</code> unsets the <code>right</code> 9153 * constraint on <code>button</code>.</p> 9154 * 9155 * @inheritDoc 9156 * 9157 * @langversion 3.0 9158 * @playerversion Flash 9 9159 * @playerversion AIR 1.1 9160 * @productversion Flex 3 9161 */ 9162 public function get right():Object 9163 { 9164 return getConstraintValue("right"); 9165 } 9166 public function set right(value:Object):void 9167 { 9168 setConstraintValue("right", value != null ? value : undefined); 9169 } 9170 9171 [Inspectable(category="General")] 9172 9173 /** 9174 * <p>For components, this layout constraint property is a 9175 * facade on top of the similarly-named style. To set 9176 * the property to its default value of <code>undefined</code>, 9177 * use the @Clear() directive in MXML or the <code>undefined</code> 9178 * value in ActionScript code. For example, in MXML code, 9179 * <code>top.s2="@Clear()"</code> unsets the <code>top</code> 9180 * constraint in state s2. Or in ActionScript code, 9181 * <code>button.top = undefined</code> unsets the <code>top</code> 9182 * constraint on <code>button</code>.</p> 9183 * 9184 * @inheritDoc 9185 * 9186 * @langversion 3.0 9187 * @playerversion Flash 9 9188 * @playerversion AIR 1.1 9189 * @productversion Flex 3 9190 */ 9191 public function get top():Object 9192 { 9193 return getConstraintValue("top"); 9194 } 9195 public function set top(value:Object):void 9196 { 9197 setConstraintValue("top", value != null ? value : undefined); 9198 } 9199 9200 [Inspectable(category="General")] 9201 9202 /** 9203 * <p>For components, this layout constraint property is a 9204 * facade on top of the similarly-named style. To set 9205 * the property to its default value of <code>undefined</code>, 9206 * use the @Clear() directive in MXML or the <code>undefined</code> 9207 * value in ActionScript code. For example, in MXML code, 9208 * <code>bottom.s2="@Clear()"</code> unsets the <code>bottom</code> 9209 * constraint in state s2. Or in ActionScript code, 9210 * <code>button.bottom = undefined</code> unsets the <code>bottom</code> 9211 * constraint on <code>button</code>.</p> 9212 * 9213 * @inheritDoc 9214 * 9215 * @langversion 3.0 9216 * @playerversion Flash 9 9217 * @playerversion AIR 1.1 9218 * @productversion Flex 3 9219 */ 9220 public function get bottom():Object 9221 { 9222 return getConstraintValue("bottom"); 9223 } 9224 public function set bottom(value:Object):void 9225 { 9226 setConstraintValue("bottom", value != null ? value : undefined); 9227 } 9228 9229 [Inspectable(category="General")] 9230 9231 /** 9232 * <p>For components, this layout constraint property is a 9233 * facade on top of the similarly-named style. To set 9234 * the property to its default value of <code>undefined</code>, 9235 * use the @Clear() directive in MXML or the <code>undefined</code> 9236 * value in ActionScript code. For example, in MXML code, 9237 * <code>horizontalCenter.s2="@Clear()"</code> unsets the 9238 * <code>horizontalCenter</code> 9239 * constraint in state s2. Or in ActionScript code, 9240 * <code>button.horizontalCenter = undefined</code> unsets the 9241 * <code>horizontalCenter</code> constraint on <code>button</code>.</p> 9242 * 9243 * @inheritDoc 9244 * 9245 * @langversion 3.0 9246 * @playerversion Flash 9 9247 * @playerversion AIR 1.1 9248 * @productversion Flex 3 9249 */ 9250 public function get horizontalCenter():Object 9251 { 9252 return getConstraintValue("horizontalCenter"); 9253 } 9254 public function set horizontalCenter(value:Object):void 9255 { 9256 setConstraintValue("horizontalCenter", value != null ? value : undefined); 9257 } 9258 9259 [Inspectable(category="General")] 9260 9261 /** 9262 * <p>For components, this layout constraint property is a 9263 * facade on top of the similarly-named style. To set 9264 * the property to its default value of <code>undefined</code>, 9265 * use the @Clear() directive in MXML or the <code>undefined</code> 9266 * value in ActionScript code. For example, in MXML code, 9267 * <code>verticalCenter.s2="@Clear()"</code> unsets the <code>verticalCenter</code> 9268 * constraint in state s2. Or in ActionScript code, 9269 * <code>button.verticalCenter = undefined</code> unsets the <code>verticalCenter</code> 9270 * constraint on <code>button</code>.</p> 9271 * 9272 * @inheritDoc 9273 * 9274 * @langversion 3.0 9275 * @playerversion Flash 9 9276 * @playerversion AIR 1.1 9277 * @productversion Flex 3 9278 */ 9279 public function get verticalCenter():Object 9280 { 9281 return getConstraintValue("verticalCenter"); 9282 } 9283 public function set verticalCenter(value:Object):void 9284 { 9285 setConstraintValue("verticalCenter", value != null ? value : undefined); 9286 } 9287 9288 [Inspectable(category="General")] 9289 9290 /** 9291 * <p>For components, this layout constraint property is a 9292 * facade on top of the similarly-named style. To set 9293 * the property to its default value of <code>undefined</code>, 9294 * use the @Clear() directive in MXML or the <code>undefined</code> 9295 * value in ActionScript code. For example, in MXML code, 9296 * <code>baseline.s2="@Clear()"</code> unsets the <code>baseline</code> 9297 * constraint in state s2. Or in ActionScript code, 9298 * <code>button.baseline = undefined</code> unsets the <code>baseline</code> 9299 * constraint on <code>button</code>.</p> 9300 * 9301 * @inheritDoc 9302 * 9303 * @langversion 3.0 9304 * @playerversion Flash 9 9305 * @playerversion AIR 1.1 9306 * @productversion Flex 3 9307 */ 9308 public function get baseline():Object 9309 { 9310 return getConstraintValue("baseline"); 9311 } 9312 public function set baseline(value:Object):void 9313 { 9314 setConstraintValue("baseline", value != null ? value : undefined); 9315 } 9316 9317 //-------------------------------------------------------------------------- 9318 // 9319 // Methods: Drawing 9320 // 9321 //-------------------------------------------------------------------------- 9322 9323 /** 9324 * Returns a box Matrix which can be passed to the 9325 * <code>drawRoundRect()</code> method 9326 * as the <code>rot</code> parameter when drawing a horizontal gradient. 9327 * 9328 * <p>For performance reasons, the Matrix is stored in a static variable 9329 * which is reused by all calls to <code>horizontalGradientMatrix()</code> 9330 * and <code>verticalGradientMatrix()</code>. 9331 * Therefore, pass the resulting Matrix 9332 * to <code>drawRoundRect()</code> before calling 9333 * <code>horizontalGradientMatrix()</code> 9334 * or <code>verticalGradientMatrix()</code> again.</p> 9335 * 9336 * @param x The left coordinate of the gradient, in pixels. 9337 * 9338 * @param y The top coordinate of the gradient, in pixels. 9339 * 9340 * @param width The width of the gradient, in pixels. 9341 * 9342 * @param height The height of the gradient, in pixels. 9343 * 9344 * @return The Matrix for the horizontal gradient. 9345 * 9346 * @langversion 3.0 9347 * @playerversion Flash 9 9348 * @playerversion AIR 1.1 9349 * @productversion Flex 3 9350 */ 9351 public function horizontalGradientMatrix(x:Number, y:Number, 9352 width:Number, 9353 height:Number):Matrix 9354 { 9355 UIComponentGlobals.tempMatrix.createGradientBox(width, height, 0, x, y); 9356 return UIComponentGlobals.tempMatrix; 9357 } 9358 9359 /** 9360 * Returns a box Matrix which can be passed to <code>drawRoundRect()</code> 9361 * as the <code>rot</code> parameter when drawing a vertical gradient. 9362 * 9363 * <p>For performance reasons, the Matrix is stored in a static variable 9364 * which is reused by all calls to <code>horizontalGradientMatrix()</code> 9365 * and <code>verticalGradientMatrix()</code>. 9366 * Therefore, pass the resulting Matrix 9367 * to <code>drawRoundRect()</code> before calling 9368 * <code>horizontalGradientMatrix()</code> 9369 * or <code>verticalGradientMatrix()</code> again.</p> 9370 * 9371 * @param x The left coordinate of the gradient, in pixels. 9372 * 9373 * @param y The top coordinate of the gradient, in pixels. 9374 * 9375 * @param width The width of the gradient, in pixels. 9376 * 9377 * @param height The height of the gradient, in pixels. 9378 * 9379 * @return The Matrix for the vertical gradient. 9380 * 9381 * @langversion 3.0 9382 * @playerversion Flash 9 9383 * @playerversion AIR 1.1 9384 * @productversion Flex 3 9385 */ 9386 public function verticalGradientMatrix(x:Number, y:Number, 9387 width:Number, 9388 height:Number):Matrix 9389 { 9390 UIComponentGlobals.tempMatrix.createGradientBox(width, height, Math.PI / 2, x, y); 9391 return UIComponentGlobals.tempMatrix; 9392 } 9393 9394 /** 9395 * Programmatically draws a rectangle into this skin's Graphics object. 9396 * 9397 * <p>The rectangle can have rounded corners. 9398 * Its edges are stroked with the current line style 9399 * of the Graphics object. 9400 * It can have a solid color fill, a gradient fill, or no fill. 9401 * A solid fill can have an alpha transparency. 9402 * A gradient fill can be linear or radial. You can specify 9403 * up to 15 colors and alpha values at specified points along 9404 * the gradient, and you can specify a rotation angle 9405 * or transformation matrix for the gradient. 9406 * Finally, the rectangle can have a rounded rectangular hole 9407 * carved out of it.</p> 9408 * 9409 * <p>This versatile rectangle-drawing routine is used by many skins. 9410 * It calls the <code>drawRect()</code> or 9411 * <code>drawRoundRect()</code> 9412 * methods (in the flash.display.Graphics class) to draw into this 9413 * skin's Graphics object.</p> 9414 * 9415 * @param x Horizontal position of upper-left corner 9416 * of rectangle within this skin. 9417 * 9418 * @param y Vertical position of upper-left corner 9419 * of rectangle within this skin. 9420 * 9421 * @param w Width of rectangle, in pixels. 9422 * 9423 * @param h Height of rectangle, in pixels. 9424 * 9425 * @param r Corner radius/radii of rectangle. 9426 * Can be <code>null</code>, a Number, or an Object. 9427 * If it is <code>null</code>, it specifies that the corners should be square 9428 * rather than rounded. 9429 * If it is a Number, it specifies the same radius, in pixels, 9430 * for all four corners. 9431 * If it is an Object, it should have properties named 9432 * <code>tl</code>, <code>tr</code>, <code>bl</code>, and 9433 * <code>br</code>, whose values are Numbers specifying 9434 * the radius, in pixels, for the top left, top right, 9435 * bottom left, and bottom right corners. 9436 * For example, you can pass a plain Object such as 9437 * <code>{ tl: 5, tr: 5, bl: 0, br: 0 }</code>. 9438 * The default value is null (square corners). 9439 * 9440 * @param c The RGB color(s) for the fill. 9441 * Can be <code>null</code>, a uint, or an Array. 9442 * If it is <code>null</code>, the rectangle not filled. 9443 * If it is a uint, it specifies an RGB fill color. 9444 * For example, pass <code>0xFF0000</code> to fill with red. 9445 * If it is an Array, it should contain uints 9446 * specifying the gradient colors. 9447 * For example, pass <code>[ 0xFF0000, 0xFFFF00, 0x0000FF ]</code> 9448 * to fill with a red-to-yellow-to-blue gradient. 9449 * You can specify up to 15 colors in the gradient. 9450 * The default value is null (no fill). 9451 * 9452 * @param alpha Alpha value(s) for the fill. 9453 * Can be null, a Number, or an Array. 9454 * This argument is ignored if <code>color</code> is null. 9455 * If <code>color</code> is a uint specifying an RGB fill color, 9456 * then <code>alpha</code> should be a Number specifying 9457 * the transparency of the fill, where 0.0 is completely transparent 9458 * and 1.0 is completely opaque. 9459 * You can also pass null instead of 1.0 in this case 9460 * to specify complete opaqueness. 9461 * If <code>color</code> is an Array specifying gradient colors, 9462 * then <code>alpha</code> should be an Array of Numbers, of the 9463 * same length, that specifies the corresponding alpha values 9464 * for the gradient. 9465 * In this case, the default value is <code>null</code> (completely opaque). 9466 * 9467 * @param rot Matrix object used for the gradient fill. 9468 * The utility methods <code>horizontalGradientMatrix()</code>, 9469 * <code>verticalGradientMatrix()</code>, and 9470 * <code>rotatedGradientMatrix()</code> can be used to create the value for 9471 * this parameter. 9472 * 9473 * @param gradient Type of gradient fill. The possible values are 9474 * <code>GradientType.LINEAR</code> or <code>GradientType.RADIAL</code>. 9475 * (The GradientType class is in the package flash.display.) 9476 * 9477 * @param ratios 9478 * Specifies the distribution of colors. The number of entries must match 9479 * the number of colors defined in the <code>color</code> parameter. 9480 * Each value defines the percentage of the width where the color is 9481 * sampled at 100%. The value 0 represents the left-hand position in 9482 * the gradient box, and 255 represents the right-hand position in the 9483 * gradient box. 9484 * 9485 * @param hole A rounded rectangular hole 9486 * that should be carved out of the middle 9487 * of the otherwise solid rounded rectangle 9488 * { x: #, y: #, w: #, h: #, r: # or { br: #, bl: #, tl: #, tr: # } } 9489 * 9490 * @see flash.display.Graphics#beginGradientFill() 9491 * 9492 * @langversion 3.0 9493 * @playerversion Flash 9 9494 * @playerversion AIR 1.1 9495 * @productversion Flex 3 9496 */ 9497 public function drawRoundRect(x:Number, y:Number, w:Number, h:Number, 9498 r:Object = null, c:Object = null, 9499 alpha:Object = null, rot:Object = null, 9500 gradient:String = null, ratios:Array = null, 9501 hole:Object = null):void 9502 { 9503 var g:Graphics = graphics; 9504 9505 // Quick exit if w or h is zero. This happens when scaling a component 9506 // to a very small value, which then gets rounded to 0. 9507 if (!w || !h) 9508 return; 9509 9510 // If color is an object then allow for complex fills. 9511 if (c !== null) 9512 { 9513 if (c is Array) 9514 { 9515 var alphas:Array; 9516 9517 if (alpha is Array) 9518 alphas = alpha as Array; 9519 else 9520 alphas = [ alpha, alpha ]; 9521 9522 if (!ratios) 9523 ratios = [ 0, 0xFF ]; 9524 9525 var matrix:Matrix = null; 9526 9527 if (rot) 9528 { 9529 if (rot is Matrix) 9530 { 9531 matrix = Matrix(rot); 9532 } 9533 else 9534 { 9535 matrix = new Matrix(); 9536 9537 if (rot is Number) 9538 { 9539 matrix.createGradientBox( 9540 w, h, Number(rot) * Math.PI / 180, x, y); 9541 } 9542 else 9543 { 9544 matrix.createGradientBox( 9545 rot.w, rot.h, rot.r, rot.x, rot.y); 9546 } 9547 } 9548 } 9549 9550 if (gradient == GradientType.RADIAL) 9551 { 9552 g.beginGradientFill(GradientType.RADIAL, 9553 c as Array, alphas, ratios, matrix); 9554 } 9555 else 9556 { 9557 g.beginGradientFill(GradientType.LINEAR, 9558 c as Array, alphas, ratios, matrix); 9559 } 9560 } 9561 else 9562 { 9563 g.beginFill(Number(c), Number(alpha)); 9564 } 9565 } 9566 9567 var ellipseSize:Number; 9568 9569 // Stroke the rectangle. 9570 if (!r) 9571 { 9572 g.drawRect(x, y, w, h); 9573 } 9574 else if (r is Number) 9575 { 9576 ellipseSize = Number(r) * 2; 9577 g.drawRoundRect(x, y, w, h, ellipseSize, ellipseSize); 9578 } 9579 else 9580 { 9581 GraphicsUtil.drawRoundRectComplex(g, x, y, w, h, r.tl, r.tr, r.bl, r.br); 9582 } 9583 9584 // Carve a rectangular hole out of the middle of the rounded rect. 9585 if (hole) 9586 { 9587 var holeR:Object = hole.r; 9588 if (holeR is Number) 9589 { 9590 ellipseSize = Number(holeR) * 2; 9591 g.drawRoundRect(hole.x, hole.y, hole.w, hole.h, 9592 ellipseSize, ellipseSize); 9593 } 9594 else 9595 { 9596 GraphicsUtil.drawRoundRectComplex(g, hole.x, hole.y, hole.w, hole.h, 9597 holeR.tl, holeR.tr, holeR.bl, holeR.br); 9598 } 9599 } 9600 9601 if (c !== null) 9602 g.endFill(); 9603 } 9604 9605 //-------------------------------------------------------------------------- 9606 // 9607 // Methods: Moving and sizing 9608 // 9609 //-------------------------------------------------------------------------- 9610 9611 /** 9612 * Moves the component to a specified position within its parent. 9613 * Calling this method is exactly the same as 9614 * setting the component's <code>x</code> and <code>y</code> properties. 9615 * 9616 * <p>If you are overriding the <code>updateDisplayList()</code> method 9617 * in a custom component, call the <code>move()</code> method 9618 * rather than setting the <code>x</code> and <code>y</code> properties. 9619 * The difference is that the <code>move()</code> method changes the location 9620 * of the component and then dispatches a <code>move</code> event when you 9621 * call the method, while setting the <code>x</code> and <code>y</code> 9622 * properties changes the location of the component and dispatches 9623 * the event on the next screen refresh.</p> 9624 * 9625 * @param x Left position of the component within its parent. 9626 * 9627 * @param y Top position of the component within its parent. 9628 * 9629 * @langversion 3.0 9630 * @playerversion Flash 9 9631 * @playerversion AIR 1.1 9632 * @productversion Flex 3 9633 */ 9634 public function move(x:Number, y:Number):void 9635 { 9636 var changed:Boolean = false; 9637 9638 if (x != this.x) 9639 { 9640 if (_layoutFeatures == null) 9641 super.x = x; 9642 else 9643 _layoutFeatures.layoutX = x; 9644 9645 if (hasEventListener("xChanged")) 9646 dispatchEvent(new Event("xChanged")); 9647 changed = true; 9648 } 9649 9650 if (y != this.y) 9651 { 9652 if (_layoutFeatures == null) 9653 super.y = y; 9654 else 9655 _layoutFeatures.layoutY = y; 9656 9657 if (hasEventListener("yChanged")) 9658 dispatchEvent(new Event("yChanged")); 9659 changed = true; 9660 } 9661 9662 if (changed) 9663 { 9664 invalidateTransform(); 9665 dispatchMoveEvent(); 9666 } 9667 } 9668 9669 /** 9670 * Sizes the object. 9671 * Unlike directly setting the <code>width</code> and <code>height</code> 9672 * properties, calling the <code>setActualSize()</code> method 9673 * does not set the <code>explictWidth</code> and 9674 * <code>explicitHeight</code> properties, so a future layout 9675 * calculation can result in the object returning to its previous size. 9676 * This method is used primarily by component developers implementing 9677 * the <code>updateDisplayList()</code> method, by Effects, 9678 * and by the LayoutManager. 9679 * 9680 * @param w Width of the object. 9681 * 9682 * @param h Height of the object. 9683 * 9684 * @langversion 3.0 9685 * @playerversion Flash 9 9686 * @playerversion AIR 1.1 9687 * @productversion Flex 3 9688 */ 9689 public function setActualSize(w:Number, h:Number):void 9690 { 9691 // trace("setActualSize: " + this + " width = " + w + " height = " + h); 9692 9693 var changed:Boolean = false; 9694 9695 if (_width != w) 9696 { 9697 _width = w; 9698 if(_layoutFeatures) 9699 { 9700 _layoutFeatures.layoutWidth = w; // for the mirror transform 9701 invalidateTransform(); 9702 } 9703 if (hasEventListener("widthChanged")) 9704 dispatchEvent(new Event("widthChanged")); 9705 changed = true; 9706 } 9707 9708 if (_height != h) 9709 { 9710 _height = h; 9711 if (hasEventListener("heightChanged")) 9712 dispatchEvent(new Event("heightChanged")); 9713 changed = true; 9714 } 9715 9716 if (changed) 9717 { 9718 invalidateDisplayList(); 9719 dispatchResizeEvent(); 9720 } 9721 9722 setActualSizeCalled = true; 9723 } 9724 9725 //-------------------------------------------------------------------------- 9726 // 9727 // Methods: Content coordinate transformations 9728 // 9729 //-------------------------------------------------------------------------- 9730 9731 /** 9732 * Converts a <code>Point</code> object from content coordinates to global coordinates. 9733 * Content coordinates specify a pixel position relative to the upper left corner 9734 * of the component's content, and include all of the component's content area, 9735 * including any regions that are currently clipped and must be 9736 * accessed by scrolling the component. 9737 * You use the content coordinate system to set and get the positions of children 9738 * of a container that uses absolute positioning. 9739 * Global coordinates specify a pixel position relative to the upper-left corner 9740 * of the stage, that is, the outermost edge of the application. 9741 * 9742 * @param point A Point object that 9743 * specifies the <i>x</i> and <i>y</i> coordinates in the content coordinate system 9744 * as properties. 9745 * 9746 * @return A Point object with coordinates relative to the Stage. 9747 * 9748 * @see #globalToContent() 9749 * 9750 * @langversion 3.0 9751 * @playerversion Flash 9 9752 * @playerversion AIR 1.1 9753 * @productversion Flex 3 9754 */ 9755 public function contentToGlobal(point:Point):Point 9756 { 9757 return localToGlobal(point); 9758 } 9759 9760 /** 9761 * Converts a <code>Point</code> object from global to content coordinates. 9762 * Global coordinates specify a pixel position relative to the upper-left corner 9763 * of the stage, that is, the outermost edge of the application. 9764 * Content coordinates specify a pixel position relative to the upper left corner 9765 * of the component's content, and include all of the component's content area, 9766 * including any regions that are currently clipped and must be 9767 * accessed by scrolling the component. 9768 * You use the content coordinate system to set and get the positions of children 9769 * of a container that uses absolute positioning. 9770 * 9771 * @param point A Point object that 9772 * specifies the <i>x</i> and <i>y</i> coordinates in the global (Stage) 9773 * coordinate system as properties. 9774 * 9775 * @return Point A Point object with coordinates relative to the component. 9776 * 9777 * @see #contentToGlobal() 9778 * 9779 * @langversion 3.0 9780 * @playerversion Flash 9 9781 * @playerversion AIR 1.1 9782 * @productversion Flex 3 9783 */ 9784 public function globalToContent(point:Point):Point 9785 { 9786 return globalToLocal(point); 9787 } 9788 9789 /** 9790 * Converts a <code>Point</code> object from content to local coordinates. 9791 * Content coordinates specify a pixel position relative to the upper left corner 9792 * of the component's content, and include all of the component's content area, 9793 * including any regions that are currently clipped and must be 9794 * accessed by scrolling the component. 9795 * You use the content coordinate system to set and get the positions of children 9796 * of a container that uses absolute positioning. 9797 * Local coordinates specify a pixel position relative to the 9798 * upper left corner of the component. 9799 * 9800 * @param point A Point object that specifies the <i>x</i> and <i>y</i> 9801 * coordinates in the content coordinate system as properties. 9802 * 9803 * @return Point A Point object with coordinates relative to the 9804 * local coordinate system. 9805 * 9806 * @see #contentToGlobal() 9807 * 9808 * @langversion 3.0 9809 * @playerversion Flash 9 9810 * @playerversion AIR 1.1 9811 * @productversion Flex 3 9812 */ 9813 public function contentToLocal(point:Point):Point 9814 { 9815 return point; 9816 } 9817 9818 /** 9819 * Converts a <code>Point</code> object from local to content coordinates. 9820 * Local coordinates specify a pixel position relative to the 9821 * upper left corner of the component. 9822 * Content coordinates specify a pixel position relative to the upper left corner 9823 * of the component's content, and include all of the component's content area, 9824 * including any regions that are currently clipped and must be 9825 * accessed by scrolling the component. 9826 * You use the content coordinate system to set and get the positions of children 9827 * of a container that uses absolute positioning. 9828 * 9829 * @param point A Point object that specifies the <i>x</i> and <i>y</i> 9830 * coordinates in the local coordinate system as properties. 9831 * 9832 * @return Point A Point object with coordinates relative to the 9833 * content coordinate system. 9834 * 9835 * @see #contentToLocal() 9836 * 9837 * @langversion 3.0 9838 * @playerversion Flash 9 9839 * @playerversion AIR 1.1 9840 * @productversion Flex 3 9841 */ 9842 public function localToContent(point:Point):Point 9843 { 9844 return point; 9845 } 9846 9847 //-------------------------------------------------------------------------- 9848 // 9849 // Methods: Focus 9850 // 9851 //-------------------------------------------------------------------------- 9852 9853 /** 9854 * Gets the object that currently has focus. 9855 * It might not be this object. 9856 * Note that this method does not necessarily return the component 9857 * that has focus. 9858 * It can return the internal subcomponent of the component 9859 * that has focus. 9860 * To get the component that has focus, use the 9861 * <code>focusManager.focus</code> property. 9862 * 9863 * @return Object that has focus. 9864 * 9865 * @langversion 3.0 9866 * @playerversion Flash 9 9867 * @playerversion AIR 1.1 9868 * @productversion Flex 3 9869 */ 9870 public function getFocus():InteractiveObject 9871 { 9872 var sm:ISystemManager = systemManager; 9873 if (!sm) 9874 return null; 9875 9876 if (UIComponentGlobals.nextFocusObject) 9877 return UIComponentGlobals.nextFocusObject; 9878 9879 if (sm.stage) 9880 return sm.stage.focus; 9881 9882 return null; 9883 } 9884 9885 /** 9886 * Sets the focus to this component. 9887 * The component can in turn pass focus to a subcomponent. 9888 * 9889 * <p><b>Note:</b> Only the TextInput and TextArea controls show a highlight 9890 * when this method sets the focus. 9891 * All controls show a highlight when the user tabs to the control.</p> 9892 * 9893 * @langversion 3.0 9894 * @playerversion Flash 9 9895 * @playerversion AIR 1.1 9896 * @productversion Flex 3 9897 */ 9898 public function setFocus():void 9899 { 9900 var sm:ISystemManager = systemManager; 9901 if (sm && (sm.stage || usingBridge)) 9902 { 9903 if (UIComponentGlobals.callLaterDispatcherCount == 0) 9904 { 9905 sm.stage.focus = this; 9906 UIComponentGlobals.nextFocusObject = null; 9907 } 9908 else 9909 { 9910 UIComponentGlobals.nextFocusObject = this; 9911 sm.addEventListener(FlexEvent.ENTER_FRAME, setFocusLater); 9912 } 9913 } 9914 else 9915 { 9916 UIComponentGlobals.nextFocusObject = this; 9917 callLater(setFocusLater); 9918 } 9919 } 9920 9921 /** 9922 * @private 9923 * Returns the focus object 9924 */ 9925 mx_internal function getFocusObject():DisplayObject 9926 { 9927 var fm:IFocusManager = focusManager; 9928 9929 if (!fm || !fm.focusPane) 9930 return null; 9931 9932 return fm.focusPane.numChildren == 0 ? 9933 null : 9934 fm.focusPane.getChildAt(0); 9935 } 9936 9937 /** 9938 * Shows or hides the focus indicator around this component. 9939 * 9940 * <p>UIComponent implements this by creating an instance of the class 9941 * specified by the <code>focusSkin</code> style and positioning it 9942 * appropriately.</p> 9943 * 9944 * @param isFocused Determines if the focus indicator should be displayed. Set to 9945 * <code>true</code> to display the focus indicator. Set to <code>false</code> to hide it. 9946 * 9947 * @langversion 3.0 9948 * @playerversion Flash 9 9949 * @playerversion AIR 1.1 9950 * @productversion Flex 3 9951 */ 9952 public function drawFocus(isFocused:Boolean):void 9953 { 9954 // Gets called by removeChild() after un-parented. 9955 if (!parent) 9956 return; 9957 9958 var focusObj:DisplayObject = getFocusObject(); 9959 var focusPane:Sprite = focusManager ? focusManager.focusPane : null; 9960 9961 if (isFocused && !preventDrawFocus) //&& !isEffectStarted 9962 { 9963 var focusOwner:DisplayObjectContainer = focusPane.parent; 9964 9965 if (focusOwner != parent) 9966 { 9967 if (focusOwner) 9968 { 9969 if (focusOwner is ISystemManager) 9970 ISystemManager(focusOwner).focusPane = null; 9971 else 9972 IUIComponent(focusOwner).focusPane = null; 9973 } 9974 if (parent is ISystemManager) 9975 ISystemManager(parent).focusPane = focusPane; 9976 else 9977 IUIComponent(parent).focusPane = focusPane; 9978 } 9979 9980 var focusClass:Class = getStyle("focusSkin"); 9981 9982 if (!focusClass) 9983 return; 9984 9985 if (focusObj && !(focusObj is focusClass)) 9986 { 9987 focusPane.removeChild(focusObj); 9988 focusObj = null; 9989 } 9990 9991 if (!focusObj) 9992 { 9993 focusObj = new focusClass(); 9994 9995 focusObj.name = "focus"; 9996 9997 focusPane.addChild(focusObj); 9998 } 9999 10000 if (focusObj is ILayoutManagerClient ) 10001 ILayoutManagerClient (focusObj).nestLevel = nestLevel; 10002 10003 if (focusObj is ISimpleStyleClient) 10004 ISimpleStyleClient(focusObj).styleName = this; 10005 10006 addEventListener(MoveEvent.MOVE, focusObj_moveHandler, true); 10007 addEventListener(MoveEvent.MOVE, focusObj_moveHandler); 10008 addEventListener(ResizeEvent.RESIZE, focusObj_resizeHandler, true); 10009 addEventListener(ResizeEvent.RESIZE, focusObj_resizeHandler); 10010 addEventListener(Event.REMOVED, focusObj_removedHandler, true); 10011 10012 focusObj.visible = true; 10013 hasFocusRect = true; 10014 10015 adjustFocusRect(); 10016 } 10017 else if (hasFocusRect) 10018 { 10019 hasFocusRect = false; 10020 10021 if (focusObj) 10022 { 10023 focusObj.visible = false; 10024 10025 if (focusObj is ISimpleStyleClient) 10026 ISimpleStyleClient(focusObj).styleName = null; 10027 } 10028 10029 removeEventListener(MoveEvent.MOVE, focusObj_moveHandler); 10030 removeEventListener(MoveEvent.MOVE, focusObj_moveHandler, true); 10031 removeEventListener(ResizeEvent.RESIZE, focusObj_resizeHandler, true); 10032 removeEventListener(ResizeEvent.RESIZE, focusObj_resizeHandler); 10033 removeEventListener(Event.REMOVED, focusObj_removedHandler, true); 10034 } 10035 } 10036 10037 /** 10038 * Adjust the focus rectangle. 10039 * 10040 * @param The component whose focus rectangle to modify. 10041 * If omitted, the default value is this UIComponent object. 10042 * 10043 * @langversion 3.0 10044 * @playerversion Flash 9 10045 * @playerversion AIR 1.1 10046 * @productversion Flex 3 10047 */ 10048 protected function adjustFocusRect(obj:DisplayObject = null):void 10049 { 10050 if (!obj) 10051 obj = this; 10052 10053 // Make sure that when we calculate the size of the Focus rect we 10054 // work with post-scale width & height. 10055 var width:Number; 10056 var height:Number; 10057 if (obj is UIComponent) 10058 { 10059 width = UIComponent(obj).unscaledWidth * Math.abs(obj.scaleX); 10060 height = UIComponent(obj).unscaledHeight * Math.abs(obj.scaleY); 10061 } 10062 else 10063 { 10064 width = obj.width; 10065 height = obj.height; 10066 } 10067 10068 // Something inside the lisder has a width and height of NaN 10069 if (isNaN(width) || isNaN(height)) 10070 return; 10071 10072 var fm:IFocusManager = focusManager; 10073 if (!fm) 10074 return; // we've been unparented so ignore 10075 10076 var focusObj:IFlexDisplayObject = IFlexDisplayObject(getFocusObject()); 10077 if (focusObj) 10078 { 10079 var rectCol:Number; 10080 var showErrorSkin:Boolean = FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0 || getStyle("showErrorSkin"); 10081 if (errorString && errorString != "" && showErrorSkin) 10082 rectCol = getStyle("errorColor"); 10083 else if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 10084 rectCol = getStyle("themeColor"); 10085 else 10086 rectCol = getStyle("focusColor"); 10087 10088 var thickness:Number = getStyle("focusThickness"); 10089 10090 if (focusObj is IStyleClient) 10091 { 10092 IStyleClient(focusObj).setStyle("focusColor", rectCol); 10093 } 10094 //if (getStyle("focusColor") != rectCol) 10095 // setStyle("focusColor", rectCol); 10096 10097 focusObj.setActualSize(width + 2 * thickness, 10098 height + 2 * thickness); 10099 10100 var pt:Point; 10101 10102 if (rotation) 10103 { 10104 var rotRad:Number = rotation * Math.PI / 180; 10105 pt = new Point(obj.x - thickness * (Math.cos(rotRad) - Math.sin(rotRad)), 10106 obj.y - thickness * (Math.cos(rotRad) + Math.sin(rotRad))); 10107 DisplayObject(focusObj).rotation = rotation; 10108 } 10109 else 10110 { 10111 pt = new Point(obj.x - thickness, obj.y - thickness); 10112 DisplayObject(focusObj).rotation = 0; 10113 } 10114 10115 if (obj.parent == this) 10116 { 10117 // This adjustment only works if obj is a direct child of this. 10118 pt.x += x; 10119 pt.y += y; 10120 } 10121 10122 // If necessary, compenstate for mirroring, if the obj to receive 10123 // focus isn't this component. It is likely to be an icon within 10124 // the component such as a radio button or check box. This works 10125 // as long as the focusObj is symmetric. 10126 // ToDo(cframpto):ProgrammaticSkin implement ILayoutDirectionElement. 10127 if (obj != this) 10128 { 10129 // The focusObj is attached to this component's parent. Assume 10130 // the focusObj is a class which doesn't support layoutDirection 10131 // and will be laid out like the component's parent. If the 10132 // component is being mirrored it means its layout differs from 10133 // its parent and we need to compenstate. 10134 if (_layoutFeatures && _layoutFeatures.mirror) 10135 pt.x += this.width - obj.width; 10136 } 10137 10138 pt = parent.localToGlobal(pt); 10139 pt = parent.globalToLocal(pt); 10140 focusObj.move(pt.x, pt.y); 10141 10142 if (focusObj is IInvalidating) 10143 IInvalidating(focusObj).validateNow(); 10144 10145 else if (focusObj is IProgrammaticSkin) 10146 IProgrammaticSkin(focusObj).validateNow(); 10147 } 10148 } 10149 10150 //-------------------------------------------------------------------------- 10151 // 10152 // Methods: Events 10153 // 10154 //-------------------------------------------------------------------------- 10155 10156 /** 10157 * Helper method for dispatching a PropertyChangeEvent 10158 * when a property is updated. 10159 * 10160 * @param prop Name of the property that changed. 10161 * 10162 * @param oldValue Old value of the property. 10163 * 10164 * @param value New value of the property. 10165 * 10166 * @langversion 3.0 10167 * @playerversion Flash 9 10168 * @playerversion AIR 1.1 10169 * @productversion Flex 3 10170 */ 10171 protected function dispatchPropertyChangeEvent(prop:String, oldValue:*, 10172 value:*):void 10173 { 10174 if (hasEventListener("propertyChange")) 10175 dispatchEvent(PropertyChangeEvent.createUpdateEvent( 10176 this, prop, oldValue, value)); 10177 } 10178 10179 /** 10180 * @private 10181 */ 10182 private function dispatchMoveEvent():void 10183 { 10184 if (hasEventListener(MoveEvent.MOVE)) 10185 { 10186 var moveEvent:MoveEvent = new MoveEvent(MoveEvent.MOVE); 10187 moveEvent.oldX = oldX; 10188 moveEvent.oldY = oldY; 10189 dispatchEvent(moveEvent); 10190 } 10191 10192 oldX = x; 10193 oldY = y; 10194 } 10195 10196 /** 10197 * @private 10198 */ 10199 private function dispatchResizeEvent():void 10200 { 10201 if (hasEventListener(ResizeEvent.RESIZE)) 10202 { 10203 var resizeEvent:ResizeEvent = new ResizeEvent(ResizeEvent.RESIZE); 10204 resizeEvent.oldWidth = oldWidth; 10205 resizeEvent.oldHeight = oldHeight; 10206 dispatchEvent(resizeEvent); 10207 } 10208 10209 oldWidth = width; 10210 oldHeight = height; 10211 } 10212 10213 /** 10214 * @private 10215 * Called when the child transform changes (currently x and y on UIComponent), 10216 * so that the Group has a chance to invalidate the layout. 10217 */ 10218 mx_internal function childXYChanged():void 10219 { 10220 } 10221 10222 /** 10223 * @private 10224 * Typically, Keyboard.LEFT means go left, regardless of the 10225 * layoutDirection, and similiarly for Keyboard.RIGHT. When 10226 * layoutDirection="rtl", rather than duplicating lots of code in the 10227 * switch statement of the keyDownHandler, map Keyboard.LEFT to 10228 * Keyboard.RIGHT, and similiarly for Keyboard.RIGHT. 10229 * 10230 * Optionally, Keyboard.UP can be tied with Keyboard.LEFT and 10231 * Keyboard.DOWN can be tied with Keyboard.RIGHT since some components 10232 * do this. 10233 * 10234 * @return keyCode to use for the layoutDirection if always using ltr 10235 * actions 10236 */ 10237 // TODO(cframpto): change to protected after getting PARB review of name. 10238 mx_internal function mapKeycodeForLayoutDirection( 10239 event:KeyboardEvent, 10240 mapUpDown:Boolean=false):uint 10241 { 10242 var keyCode:uint = event.keyCode; 10243 10244 // If rtl layout, left still means left and right still means right so 10245 // swap the keys to get the correct action. 10246 switch (keyCode) 10247 { 10248 case Keyboard.DOWN: 10249 { 10250 // typically, if ltr, the same as RIGHT 10251 if (mapUpDown && layoutDirection == LayoutDirection.RTL) 10252 keyCode = Keyboard.LEFT; 10253 break; 10254 } 10255 case Keyboard.RIGHT: 10256 { 10257 if (layoutDirection == LayoutDirection.RTL) 10258 keyCode = Keyboard.LEFT; 10259 break; 10260 } 10261 case Keyboard.UP: 10262 { 10263 // typically, if ltr, the same as LEFT 10264 if (mapUpDown && layoutDirection == LayoutDirection.RTL) 10265 keyCode = Keyboard.RIGHT; 10266 break; 10267 } 10268 case Keyboard.LEFT: 10269 { 10270 if (layoutDirection == LayoutDirection.RTL) 10271 keyCode = Keyboard.RIGHT; 10272 break; 10273 } 10274 } 10275 10276 return keyCode; 10277 } 10278 10279 //-------------------------------------------------------------------------- 10280 // 10281 // Methods: States 10282 // 10283 //-------------------------------------------------------------------------- 10284 10285 /** 10286 * Set the current state. 10287 * 10288 * @param stateName The name of the new view state. 10289 * 10290 * @param playTransition If <code>true</code>, play 10291 * the appropriate transition when the view state changes. 10292 * 10293 * @see #currentState 10294 * 10295 * @langversion 3.0 10296 * @playerversion Flash 9 10297 * @playerversion AIR 1.1 10298 * @productversion Flex 3 10299 */ 10300 public function setCurrentState(stateName:String, 10301 playTransition:Boolean = true):void 10302 { 10303 // Flex 4 has no concept of an explicit base state, so ensure we 10304 // fall back to something appropriate. 10305 stateName = isBaseState(stateName) ? getDefaultState() : stateName; 10306 10307 // Only change if the requested state is different. Since the root 10308 // state can be either null or "", we need to add additional check 10309 // to make sure we're not going from null to "" or vice-versa. 10310 if (stateName != currentState && 10311 !(isBaseState(stateName) && isBaseState(currentState))) 10312 { 10313 requestedCurrentState = stateName; 10314 // Don't play transition if we're just getting started 10315 // In Flex4, there is no "base state", so if isBaseState() is true 10316 // then we're just going into our first real state 10317 playStateTransition = 10318 (this is IStateClient2) && isBaseState(currentState) ? 10319 false : 10320 playTransition; 10321 if (initialized) 10322 { 10323 commitCurrentState(); 10324 } 10325 else 10326 { 10327 _currentStateChanged = true; 10328 invalidateProperties(); 10329 } 10330 } 10331 } 10332 10333 /** 10334 * @copy mx.core.IStateClient2#hasState() 10335 * 10336 * @langversion 3.0 10337 * @playerversion Flash 9 10338 * @playerversion AIR 1.1 10339 * @productversion Flex 3 10340 */ 10341 public function hasState(stateName:String):Boolean 10342 { 10343 return (getState(stateName, false) != null); 10344 } 10345 10346 /** 10347 * @private 10348 * Returns true if the passed in state name is the 'base' state, which 10349 * is currently defined as null or "" 10350 */ 10351 private function isBaseState(stateName:String):Boolean 10352 { 10353 return !stateName || stateName == ""; 10354 } 10355 10356 /** 10357 * @private 10358 * Returns the default state. For Flex 4 and later we return the base 10359 * the first defined state, otherwise (Flex 3 and earlier), we return 10360 * the base (null) state. 10361 */ 10362 private function getDefaultState():String 10363 { 10364 return (this is IStateClient2 && (states.length > 0)) ? states[0].name : null; 10365 } 10366 10367 // Used by commitCurrentState() to avoid hard-linking against Effect 10368 private static var effectType:Class; 10369 private static var effectLoaded:Boolean = false; 10370 10371 /** 10372 * @private 10373 * Commit a pending current state change. 10374 */ 10375 private function commitCurrentState():void 10376 { 10377 var nextTransition:Transition = 10378 playStateTransition ? 10379 getTransition(_currentState, requestedCurrentState) : 10380 null; 10381 var commonBaseState:String = findCommonBaseState(_currentState, requestedCurrentState); 10382 var event:StateChangeEvent; 10383 var oldState:String = _currentState ? _currentState : ""; 10384 var destination:State = getState(requestedCurrentState); 10385 var prevTransitionEffect:Object; 10386 var tmpPropertyChanges:Array; 10387 10388 // First, make sure we've loaded the Effect class - some of the logic 10389 // below requires it 10390 if (nextTransition && !effectLoaded) 10391 { 10392 effectLoaded = true; 10393 if (ApplicationDomain.currentDomain.hasDefinition("mx.effects.Effect")) 10394 effectType = Class(ApplicationDomain.currentDomain. 10395 getDefinition("mx.effects.Effect")); 10396 } 10397 10398 // Stop any transition that may still be playing 10399 var prevTransitionFraction:Number; 10400 if (_currentTransition) 10401 { 10402 // Remove the event listener, we don't want to trigger it as it 10403 // dispatches FlexEvent.STATE_CHANGE_COMPLETE and we are 10404 // interrupting _currentTransition instead. 10405 _currentTransition.effect.removeEventListener(EffectEvent.EFFECT_END, transition_effectEndHandler); 10406 10407 // 'stop' interruptions take precedence over autoReverse behavior 10408 if (nextTransition && _currentTransition.interruptionBehavior == "stop") 10409 { 10410 prevTransitionEffect = _currentTransition.effect; 10411 prevTransitionEffect.transitionInterruption = true; 10412 // This logic stops the effect from applying the end values 10413 // so that we can capture the interrupted values correctly 10414 // in captureStartValues() below. Save the values in the 10415 // tmp variable because stop() clears out propertyChangesArray 10416 // from the effect. 10417 tmpPropertyChanges = prevTransitionEffect.propertyChangesArray; 10418 prevTransitionEffect.applyEndValuesWhenDone = false; 10419 prevTransitionEffect.stop(); 10420 prevTransitionEffect.applyEndValuesWhenDone = true; 10421 } 10422 else 10423 { 10424 if (_currentTransition.autoReverse && 10425 transitionFromState == requestedCurrentState && 10426 transitionToState == _currentState) 10427 { 10428 if (_currentTransition.effect.duration == 0) 10429 prevTransitionFraction = 0; 10430 else 10431 prevTransitionFraction = 10432 _currentTransition.effect.playheadTime / 10433 getTotalDuration(_currentTransition.effect); 10434 } 10435 _currentTransition.effect.end(); 10436 } 10437 10438 // The current transition is being interrupted, dispatch an event 10439 if (hasEventListener(FlexEvent.STATE_CHANGE_INTERRUPTED)) 10440 dispatchEvent(new FlexEvent(FlexEvent.STATE_CHANGE_INTERRUPTED)); 10441 _currentTransition = null; 10442 } 10443 10444 // Initialize the state we are going to. 10445 initializeState(requestedCurrentState); 10446 10447 // Capture transition start values 10448 if (nextTransition) 10449 nextTransition.effect.captureStartValues(); 10450 10451 // Now that we've captured the start values, apply the end values of 10452 // the effect as normal. This makes sure that objects unaffected by the 10453 // next transition have their correct end values from the previous 10454 // transition 10455 if (tmpPropertyChanges) 10456 prevTransitionEffect.applyEndValues(tmpPropertyChanges, 10457 prevTransitionEffect.targets); 10458 10459 // Dispatch currentStateChanging event 10460 if (hasEventListener(StateChangeEvent.CURRENT_STATE_CHANGING)) 10461 { 10462 event = new StateChangeEvent(StateChangeEvent.CURRENT_STATE_CHANGING); 10463 event.oldState = oldState; 10464 event.newState = requestedCurrentState ? requestedCurrentState : ""; 10465 dispatchEvent(event); 10466 } 10467 10468 // If we're leaving the base state, send an exitState event 10469 if (isBaseState(_currentState) && hasEventListener(FlexEvent.EXIT_STATE)) 10470 dispatchEvent(new FlexEvent(FlexEvent.EXIT_STATE)); 10471 10472 // Remove the existing state 10473 removeState(_currentState, commonBaseState); 10474 _currentState = requestedCurrentState; 10475 10476 // Check for state specific styles 10477 stateChanged(oldState, _currentState, true); 10478 10479 // If we're going back to the base state, dispatch an 10480 // enter state event, otherwise apply the state. 10481 if (isBaseState(currentState)) 10482 { 10483 if (hasEventListener(FlexEvent.ENTER_STATE)) 10484 dispatchEvent(new FlexEvent(FlexEvent.ENTER_STATE)); 10485 } 10486 else 10487 applyState(_currentState, commonBaseState); 10488 10489 // Dispatch currentStateChange 10490 if (hasEventListener(StateChangeEvent.CURRENT_STATE_CHANGE)) 10491 { 10492 event = new StateChangeEvent(StateChangeEvent.CURRENT_STATE_CHANGE); 10493 event.oldState = oldState; 10494 event.newState = _currentState ? _currentState : ""; 10495 dispatchEvent(event); 10496 } 10497 10498 if (nextTransition) 10499 { 10500 var reverseTransition:Boolean = 10501 nextTransition && nextTransition.autoReverse && 10502 (nextTransition.toState == oldState || 10503 nextTransition.fromState == _currentState); 10504 // Force a validation before playing the transition effect 10505 UIComponentGlobals.layoutManager.validateNow(); 10506 _currentTransition = nextTransition; 10507 transitionFromState = oldState; 10508 transitionToState = _currentState; 10509 // Tell the effect whether it is running in interruption mode, in which 10510 // case it should grab values from the states instead of from current 10511 // property values 10512 Object(nextTransition.effect).transitionInterruption = 10513 (prevTransitionEffect != null); 10514 nextTransition.effect.addEventListener(EffectEvent.EFFECT_END, 10515 transition_effectEndHandler); 10516 nextTransition.effect.play(null, reverseTransition); 10517 if (!isNaN(prevTransitionFraction) && 10518 nextTransition.effect.duration != 0) 10519 nextTransition.effect.playheadTime = (1 - prevTransitionFraction) * 10520 getTotalDuration(nextTransition.effect); 10521 } 10522 else 10523 { 10524 // Dispatch an event that the transition has completed. 10525 if (hasEventListener(FlexEvent.STATE_CHANGE_COMPLETE)) 10526 dispatchEvent(new FlexEvent(FlexEvent.STATE_CHANGE_COMPLETE)); 10527 } 10528 } 10529 10530 // Used by getTotalDuration() to avoid hard-linking against 10531 // CompositeEffect 10532 private static var compositeEffectType:Class; 10533 private static var compositeEffectLoaded:Boolean = false; 10534 10535 /** 10536 * @private 10537 * returns the 'total' duration of an effect. This value 10538 * takes into account any startDelay and repetition data. 10539 * For CompositeEffect objects, it also accounts for the 10540 * total duration of that effect's children. 10541 */ 10542 private function getTotalDuration(effect:IEffect):Number 10543 { 10544 // TODO (chaase): we should add timing properties to some 10545 // interface to avoid these hacks 10546 var duration:Number = 0; 10547 var effectObj:Object = Object(effect); 10548 if (!compositeEffectLoaded) 10549 { 10550 compositeEffectLoaded = true; 10551 if (ApplicationDomain.currentDomain.hasDefinition("mx.effects.CompositeEffect")) 10552 compositeEffectType = Class(ApplicationDomain.currentDomain. 10553 getDefinition("mx.effects.CompositeEffect")); 10554 } 10555 if (compositeEffectType && (effect is compositeEffectType)) 10556 duration = effectObj.compositeDuration; 10557 else 10558 duration = effect.duration; 10559 var repeatDelay:int = ("repeatDelay" in effect) ? 10560 effectObj.repeatDelay : 0; 10561 var repeatCount:int = ("repeatCount" in effect) ? 10562 effectObj.repeatCount : 0; 10563 var startDelay:int = ("startDelay" in effect) ? 10564 effectObj.startDelay : 0; 10565 // Now add in startDelay/repeat info 10566 duration = 10567 duration * repeatCount + 10568 (repeatDelay * (repeatCount - 1)) + 10569 startDelay; 10570 return duration; 10571 } 10572 10573 /** 10574 * @private 10575 */ 10576 private function transition_effectEndHandler(event:EffectEvent):void 10577 { 10578 _currentTransition = null; 10579 10580 // Dispatch an event that the transition has completed. 10581 if (hasEventListener(FlexEvent.STATE_CHANGE_COMPLETE)) 10582 dispatchEvent(new FlexEvent(FlexEvent.STATE_CHANGE_COMPLETE)); 10583 } 10584 10585 /** 10586 * @private 10587 * Returns the state with the specified name, or null if it doesn't exist. 10588 * If multiple states have the same name the first one will be returned. 10589 */ 10590 private function getState(stateName:String, throwOnUndefined:Boolean=true):State 10591 { 10592 if (!states || isBaseState(stateName)) 10593 return null; 10594 10595 // Do a simple linear search for now. This can 10596 // be optimized later if needed. 10597 for (var i:int = 0; i < states.length; i++) 10598 { 10599 if (states[i].name == stateName) 10600 return states[i]; 10601 } 10602 10603 if (throwOnUndefined) 10604 { 10605 var message:String = resourceManager.getString( 10606 "core", "stateUndefined", [ stateName ]); 10607 throw new ArgumentError(message); 10608 } 10609 return null; 10610 } 10611 10612 /** 10613 * @private 10614 * Find the deepest common state between two states. For example: 10615 * 10616 * State A 10617 * State B basedOn A 10618 * State C basedOn A 10619 * 10620 * findCommonBaseState(B, C) returns A 10621 * 10622 * If there are no common base states, the root state ("") is returned. 10623 */ 10624 private function findCommonBaseState(state1:String, state2:String):String 10625 { 10626 var firstState:State = getState(state1); 10627 var secondState:State = getState(state2); 10628 10629 // Quick exit if either state is the base state 10630 if (!firstState || !secondState) 10631 return ""; 10632 10633 // Quick exit if both states are not based on other states 10634 if (isBaseState(firstState.basedOn) && isBaseState(secondState.basedOn)) 10635 return ""; 10636 10637 // Get the base states for each state and walk from the top 10638 // down until we find the deepest common base state. 10639 var firstBaseStates:Array = getBaseStates(firstState); 10640 var secondBaseStates:Array = getBaseStates(secondState); 10641 var commonBase:String = ""; 10642 10643 while (firstBaseStates[firstBaseStates.length - 1] == 10644 secondBaseStates[secondBaseStates.length - 1]) 10645 { 10646 commonBase = firstBaseStates.pop(); 10647 secondBaseStates.pop(); 10648 10649 if (!firstBaseStates.length || !secondBaseStates.length) 10650 break; 10651 } 10652 10653 // Finally, check to see if one of the states is directly based on the other. 10654 if (firstBaseStates.length && 10655 firstBaseStates[firstBaseStates.length - 1] == secondState.name) 10656 { 10657 commonBase = secondState.name; 10658 } 10659 else if (secondBaseStates.length && 10660 secondBaseStates[secondBaseStates.length - 1] == firstState.name) 10661 { 10662 commonBase = firstState.name; 10663 } 10664 10665 return commonBase; 10666 } 10667 10668 /** 10669 * @private 10670 * Returns the base states for a given state. 10671 * This Array is in high-to-low order - the first entry 10672 * is the immediate basedOn state, the last entry is the topmost 10673 * basedOn state. 10674 */ 10675 private function getBaseStates(state:State):Array 10676 { 10677 var baseStates:Array = []; 10678 10679 // Push each basedOn name 10680 while (state && state.basedOn) 10681 { 10682 baseStates.push(state.basedOn); 10683 state = getState(state.basedOn); 10684 } 10685 10686 return baseStates; 10687 } 10688 10689 /** 10690 * @private 10691 * Remove the overrides applied by a state, and any 10692 * states it is based on. 10693 */ 10694 private function removeState(stateName:String, lastState:String):void 10695 { 10696 var state:State = getState(stateName); 10697 10698 if (stateName == lastState) 10699 return; 10700 10701 // Remove existing state overrides. 10702 // This must be done in reverse order 10703 if (state) 10704 { 10705 // Dispatch the "exitState" event 10706 state.dispatchExitState(); 10707 10708 var overrides:Array = state.overrides; 10709 10710 for (var i:int = overrides.length; i; i--) 10711 overrides[i-1].remove(this); 10712 10713 // Remove any basedOn deltas last 10714 if (state.basedOn != lastState) 10715 removeState(state.basedOn, lastState); 10716 } 10717 } 10718 10719 /** 10720 * @private 10721 * Apply the overrides from a state, and any states it 10722 * is based on. 10723 */ 10724 private function applyState(stateName:String, lastState:String):void 10725 { 10726 var state:State = getState(stateName); 10727 10728 if (stateName == lastState) 10729 return; 10730 10731 if (state) 10732 { 10733 // Apply "basedOn" overrides first 10734 if (state.basedOn != lastState) 10735 applyState(state.basedOn, lastState); 10736 10737 // Apply new state overrides 10738 var overrides:Array = state.overrides; 10739 10740 for (var i:int = 0; i < overrides.length; i++) 10741 overrides[i].apply(this); 10742 10743 // Dispatch the "enterState" event 10744 state.dispatchEnterState(); 10745 } 10746 } 10747 10748 /** 10749 * @private 10750 * Initialize the state, and any states it is based on 10751 */ 10752 private function initializeState(stateName:String):void 10753 { 10754 var state:State = getState(stateName); 10755 10756 while (state) 10757 { 10758 state.initialize(); 10759 state = getState(state.basedOn); 10760 } 10761 } 10762 10763 /** 10764 * @private 10765 * Find the appropriate transition to play between two states. 10766 */ 10767 private function getTransition(oldState:String, newState:String):Transition 10768 { 10769 var result:Transition = null; // Current candidate 10770 var priority:int = 0; // Priority fromState toState 10771 // 1 * * 10772 // 2 reverse * 10773 // 3 * reverse 10774 // 4 reverse reverse 10775 // 5 match * 10776 // 6 * match 10777 // 7 match match 10778 10779 if (!transitions) 10780 return null; 10781 10782 if (!oldState) 10783 oldState = ""; 10784 10785 if (!newState) 10786 newState = ""; 10787 10788 for (var i:int = 0; i < transitions.length; i++) 10789 { 10790 var t:Transition = transitions[i]; 10791 10792 if (t.fromState == "*" && t.toState == "*" && priority < 1) 10793 { 10794 result = t; 10795 priority = 1; 10796 } 10797 else if (t.toState == oldState && t.fromState == "*" && t.autoReverse && priority < 2) 10798 { 10799 result = t; 10800 priority = 2; 10801 } 10802 else if (t.toState == "*" && t.fromState == newState && t.autoReverse && priority < 3) 10803 { 10804 result = t; 10805 priority = 3; 10806 } 10807 else if (t.toState == oldState && t.fromState == newState && t.autoReverse && priority < 4) 10808 { 10809 result = t; 10810 priority = 4; 10811 } 10812 else if (t.fromState == oldState && t.toState == "*" && priority < 5) 10813 { 10814 result = t; 10815 priority = 5; 10816 } 10817 else if (t.fromState == "*" && t.toState == newState && priority < 6) 10818 { 10819 result = t; 10820 priority = 6; 10821 } 10822 else if (t.fromState == oldState && t.toState == newState && priority < 7) 10823 { 10824 result = t; 10825 priority = 7; 10826 10827 // Can't get any higher than this, let's go. 10828 break; 10829 } 10830 } 10831 // If Transition does not contain an effect, then don't return it 10832 // because there is no transition effect to run 10833 if (result && !result.effect) 10834 result = null; 10835 10836 return result; 10837 } 10838 10839 //-------------------------------------------------------------------------- 10840 // 10841 // Methods: Styling 10842 // 10843 //-------------------------------------------------------------------------- 10844 10845 /** 10846 * The state to be used when matching CSS pseudo-selectors. By default 10847 * this is the <code>currentState</code>. 10848 * 10849 * @langversion 3.0 10850 * @playerversion Flash 10 10851 * @playerversion AIR 2.5 10852 * @productversion Flex 4.5 10853 */ 10854 protected function get currentCSSState():String 10855 { 10856 return currentState; 10857 } 10858 10859 /** 10860 * A component's parent is used to evaluate descendant selectors. A parent 10861 * must also be an IAdvancedStyleClient to participate in advanced style 10862 * declarations. 10863 * 10864 * @langversion 3.0 10865 * @playerversion Flash 9 10866 * @playerversion AIR 1.1 10867 * @productversion Flex 3 10868 */ 10869 public function get styleParent():IAdvancedStyleClient 10870 { 10871 return parent as IAdvancedStyleClient; 10872 } 10873 10874 public function set styleParent(parent:IAdvancedStyleClient):void 10875 { 10876 10877 } 10878 10879 /** 10880 * @inheritDoc 10881 * 10882 * @langversion 3.0 10883 * @playerversion Flash 9 10884 * @playerversion AIR 1.1 10885 * @productversion Flex 3 10886 */ 10887 public function matchesCSSState(cssState:String):Boolean 10888 { 10889 return currentCSSState == cssState; 10890 } 10891 10892 /** 10893 * @inheritDoc 10894 * 10895 * @langversion 3.0 10896 * @playerversion Flash 9 10897 * @playerversion AIR 1.1 10898 * @productversion Flex 3 10899 */ 10900 public function matchesCSSType(cssType:String):Boolean 10901 { 10902 return StyleProtoChain.matchesCSSType(this, cssType); 10903 } 10904 10905 /** 10906 * @inheritDoc 10907 * 10908 * @langversion 3.0 10909 * @playerversion Flash 10 10910 * @playerversion AIR 2.5 10911 * @productversion Flex 4.6 10912 */ 10913 public function hasCSSState():Boolean 10914 { 10915 return currentCSSState != null; 10916 } 10917 10918 /** 10919 * @private 10920 * Sets up the inheritingStyles and nonInheritingStyles objects 10921 * and their proto chains so that getStyle() can work. 10922 */ 10923 // Note that initProtoChain is 99% copied into DataGridItemRenderer 10924 mx_internal function initProtoChain():void 10925 { 10926 StyleProtoChain.initProtoChain(this); 10927 } 10928 10929 /** 10930 * Finds the type selectors for this UIComponent instance. 10931 * The algorithm walks up the superclass chain. 10932 * For example, suppose that class MyButton extends Button. 10933 * A MyButton instance first looks for a MyButton type selector 10934 * then, it looks for a Button type selector. 10935 * then, it looks for a UIComponent type selector. 10936 * (The superclass chain is considered to stop at UIComponent, not Object.) 10937 * 10938 * @return An Array of type selectors for this UIComponent instance. 10939 * 10940 * @langversion 3.0 10941 * @playerversion Flash 9 10942 * @playerversion AIR 1.1 10943 * @productversion Flex 3 10944 */ 10945 public function getClassStyleDeclarations():Array 10946 { 10947 return StyleProtoChain.getClassStyleDeclarations(this); 10948 } 10949 10950 /** 10951 * Builds or rebuilds the CSS style cache for this component 10952 * and, if the <code>recursive</code> parameter is <code>true</code>, 10953 * for all descendants of this component as well. 10954 * 10955 * <p>The Flex framework calls this method in the following 10956 * situations:</p> 10957 * 10958 * <ul> 10959 * <li>When you add a UIComponent to a parent using the 10960 * <code>addChild()</code> or <code>addChildAt()</code> methods.</li> 10961 * <li>When you change the <code>styleName</code> property 10962 * of a UIComponent.</li> 10963 * <li>When you set a style in a CSS selector using the 10964 * <code>setStyle()</code> method of CSSStyleDeclaration.</li> 10965 * </ul> 10966 * 10967 * <p>Building the style cache is a computation-intensive operation, 10968 * so avoid changing <code>styleName</code> or 10969 * setting selector styles unnecessarily.</p> 10970 * 10971 * <p>This method is not called when you set an instance style 10972 * by calling the <code>setStyle()</code> method of UIComponent. 10973 * Setting an instance style is a relatively fast operation 10974 * compared with setting a selector style.</p> 10975 * 10976 * <p>You do not need to call or override this method.</p> 10977 * 10978 * @param recursive Recursively regenerates the style cache for 10979 * all children of this component. 10980 * 10981 * @langversion 3.0 10982 * @playerversion Flash 9 10983 * @playerversion AIR 1.1 10984 * @productversion Flex 3 10985 */ 10986 public function regenerateStyleCache(recursive:Boolean):void 10987 { 10988 // Regenerate the proto chain for this object 10989 initProtoChain(); 10990 10991 var childList:IChildList = 10992 this is IRawChildrenContainer ? 10993 IRawChildrenContainer(this).rawChildren : 10994 IChildList(this); 10995 10996 // Recursively call this method on each child. 10997 var n:int = childList.numChildren; 10998 10999 for (var i:int = 0; i < n; i++) 11000 { 11001 var child:Object = childList.getChildAt(i); 11002 11003 if (child is IStyleClient) 11004 { 11005 // Does this object already have a proto chain? 11006 // If not, there's no need to regenerate a new one. 11007 if (IStyleClient(child).inheritingStyles != 11008 StyleProtoChain.STYLE_UNINITIALIZED) 11009 { 11010 IStyleClient(child).regenerateStyleCache(recursive); 11011 } 11012 } 11013 else if (child is IUITextField) 11014 { 11015 // Does this object already have a proto chain? 11016 // If not, there's no need to regenerate a new one. 11017 if (IUITextField(child).inheritingStyles) 11018 StyleProtoChain.initTextField(IUITextField(child)); 11019 } 11020 } 11021 11022 // Call this method on each non-visual StyleClient 11023 if (advanceStyleClientChildren != null) 11024 { 11025 for (var styleClient:Object in advanceStyleClientChildren) 11026 { 11027 var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient 11028 as IAdvancedStyleClient; 11029 11030 if (iAdvanceStyleClientChild && 11031 iAdvanceStyleClientChild.inheritingStyles != 11032 StyleProtoChain.STYLE_UNINITIALIZED) 11033 { 11034 iAdvanceStyleClientChild.regenerateStyleCache(recursive); 11035 } 11036 } 11037 } 11038 } 11039 /** 11040 * This method is called when a state changes to check whether 11041 * state-specific styles apply to this component. If there is a chance 11042 * of a matching CSS pseudo-selector for the current state, the style 11043 * cache needs to be regenerated for this instance and, potentially all 11044 * children, if the <code>recursive</code> param is set to <code>true</code>. 11045 * 11046 * @param oldState The name of th eold state. 11047 * 11048 * @param newState The name of the new state. 11049 * 11050 * @param recursive Set to <code>true</code> to perform a recursive check. 11051 * 11052 * @langversion 3.0 11053 * @playerversion Flash 10 11054 * @playerversion AIR 1.5 11055 * @productversion Flex 4 11056 */ 11057 protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void 11058 { 11059 // This test only checks for pseudo conditions on the subject of the selector. 11060 // Pseudo conditions on ancestor selectors are not detected - eg: 11061 // List ScrollBar:inactive #track 11062 // The track styles will not change when the scrollbar is in the inactive state. 11063 if (currentCSSState && oldState != newState && 11064 (styleManager.hasPseudoCondition(oldState) || 11065 styleManager.hasPseudoCondition(newState))) 11066 { 11067 regenerateStyleCache(recursive); 11068 initThemeColor(); 11069 styleChanged(null); 11070 notifyStyleChangeInChildren(null, recursive); 11071 } 11072 } 11073 11074 [Bindable(style="true")] 11075 /** 11076 * Gets a style property that has been set anywhere in this 11077 * component's style lookup chain. 11078 * 11079 * <p>This same method is used to get any kind of style property, 11080 * so the value returned can be a Boolean, String, Number, int, 11081 * uint (for an RGB color), Class (for a skin), or any kind of object. 11082 * Therefore the return type is simply specified as ~~.</p> 11083 * 11084 * <p>If you are getting a particular style property, you 11085 * know its type and often want to store the result in a 11086 * variable of that type. 11087 * No casting from ~~ to that type is necessary.</p> 11088 * 11089 * <p> 11090 * <code> 11091 * var backgroundColor:uint = getStyle("backgroundColor"); 11092 * </code> 11093 * </p> 11094 * 11095 * <p>If the style property has not been set anywhere in the 11096 * style lookup chain, the value returned by <code>getStyle()</code> 11097 * is <code>undefined</code>. 11098 * Note that <code>undefined</code> is a special value that is 11099 * not the same as <code>false</code>, <code>""</code>, 11100 * <code>NaN</code>, <code>0</code>, or <code>null</code>. 11101 * No valid style value is ever <code>undefined</code>. 11102 * You can use the method 11103 * <code>IStyleManager2.isValidStyleValue()</code> 11104 * to test whether the value was set.</p> 11105 * 11106 * @param styleProp Name of the style property. 11107 * 11108 * @return Style value. 11109 * 11110 * @langversion 3.0 11111 * @playerversion Flash 9 11112 * @playerversion AIR 1.1 11113 * @productversion Flex 3 11114 */ 11115 public function getStyle(styleProp:String):* 11116 { 11117 // If a moduleFactory has not be set yet, first check for any deferred 11118 // styles. If there are no deferred styles or the styleProp is not in 11119 // the deferred styles, the look in the proto chain. 11120 if (!moduleFactory) 11121 { 11122 if (deferredSetStyles && deferredSetStyles[styleProp] !== undefined) 11123 return deferredSetStyles[styleProp]; 11124 } 11125 11126 return styleManager.inheritingStyles[styleProp] ? 11127 _inheritingStyles[styleProp] : 11128 _nonInheritingStyles[styleProp]; 11129 } 11130 11131 /** 11132 * Sets a style property on this component instance. 11133 * 11134 * <p>This can override a style that was set globally.</p> 11135 * 11136 * <p>Calling the <code>setStyle()</code> method can result in decreased performance. 11137 * Use it only when necessary.</p> 11138 * 11139 * @param styleProp Name of the style property. 11140 * 11141 * @param newValue New value for the style. 11142 * 11143 * @langversion 3.0 11144 * @playerversion Flash 9 11145 * @playerversion AIR 1.1 11146 * @productversion Flex 3 11147 */ 11148 public function setStyle(styleProp:String, newValue:*):void 11149 { 11150 // If there is no module factory then defer the set 11151 // style until a module factory is set. 11152 if (moduleFactory) 11153 { 11154 StyleProtoChain.setStyle(this, styleProp, newValue); 11155 } 11156 else 11157 { 11158 if (!deferredSetStyles) 11159 deferredSetStyles = new Object(); 11160 deferredSetStyles[styleProp] = newValue; 11161 } 11162 } 11163 11164 11165 /** 11166 * @private 11167 * Set styles that were deferred because a module factory was not 11168 * set yet. 11169 */ 11170 private function setDeferredStyles():void 11171 { 11172 if (!deferredSetStyles) 11173 return; 11174 11175 for (var styleProp:String in deferredSetStyles) 11176 StyleProtoChain.setStyle(this, styleProp, deferredSetStyles[styleProp]); 11177 11178 deferredSetStyles = null; 11179 } 11180 11181 /** 11182 * Deletes a style property from this component instance. 11183 * 11184 * <p>This does not necessarily cause the <code>getStyle()</code> method 11185 * to return <code>undefined</code>.</p> 11186 * 11187 * @param styleProp The name of the style property. 11188 * 11189 * @langversion 3.0 11190 * @playerversion Flash 9 11191 * @playerversion AIR 1.1 11192 * @productversion Flex 3 11193 */ 11194 public function clearStyle(styleProp:String):void 11195 { 11196 setStyle(styleProp, undefined); 11197 } 11198 11199 /** 11200 * @private 11201 */ 11202 mx_internal var advanceStyleClientChildren:Dictionary = null; 11203 11204 /** 11205 * Adds a non-visual style client to this component instance. Once 11206 * this method has been called, the style client will inherit style 11207 * changes from this component instance. Style clients that are 11208 * DisplayObjects must use the <code>addChild</code> or 11209 * <code>addChildAt</code> methods to be added to a 11210 * <code>UIComponent</code>. 11211 * 11212 * As a side effect, this method will set the <code>styleParent</code> 11213 * property of the <code>styleClient</code> parameter to reference 11214 * this instance of the <code>UIComponent</code>. 11215 * 11216 * If the <code>styleClient</code> parameter already has a 11217 * <code>styleParent</code>, this method will call 11218 * <code>removeStyleClient</code> from this previous 11219 * <code>styleParent</code>. 11220 * 11221 * 11222 * @param styleClient The <code>IAdvancedStyleClient</code> to 11223 * add to this component's list of non-visual style clients. 11224 * 11225 * @throws ArgumentError if the <code>styleClient</code> parameter 11226 * is a <code>DisplayObject</code>. 11227 * 11228 * @see removeStyleClient 11229 * @see mx.styles.IAdvancedStyleClient 11230 * 11231 * @langversion 3.0 11232 * @playerversion Flash 9 11233 * @playerversion AIR 1.1 11234 * @productversion Flex 4.5 11235 */ 11236 public function addStyleClient(styleClient:IAdvancedStyleClient):void 11237 { 11238 if(!(styleClient is DisplayObject)) 11239 { 11240 if(styleClient.styleParent!=null) 11241 { 11242 var parentComponent:UIComponent = styleClient.styleParent as UIComponent; 11243 if (parentComponent) 11244 parentComponent.removeStyleClient(styleClient); 11245 } 11246 // Create a dictionary with weak references to the key 11247 if (advanceStyleClientChildren == null) 11248 advanceStyleClientChildren = new Dictionary(true); 11249 // Add the styleClient as a key in the dictionary. 11250 // The value assigned to this key entry is currently not used. 11251 advanceStyleClientChildren[styleClient] = true; 11252 styleClient.styleParent=this; 11253 11254 styleClient.regenerateStyleCache(true); 11255 11256 styleClient.styleChanged(null); 11257 } 11258 else 11259 { 11260 var message:String = resourceManager.getString( 11261 "core", "badParameter", [ styleClient ]); 11262 throw new ArgumentError(message); 11263 } 11264 } 11265 11266 /** 11267 * Removes a non-visual style client from this component instance. 11268 * Once this method has been called, the non-visual style client will 11269 * no longer inherit style changes from this component instance. 11270 * 11271 * As a side effect, this method will set the 11272 * <code>styleParent</code> property of the <code>styleClient</code> 11273 * parameter to <code>null</code>. 11274 * 11275 * If the <code>styleClient</code> has not been added to this 11276 * component instance, no action will be taken. 11277 * 11278 * @param styleClient The <code>IAdvancedStyleClient</code> to remove 11279 * from this component's list of non-visual style clients. 11280 * 11281 * @return The non-visual style client that was passed in as the 11282 * <code>styleClient</code> parameter. 11283 * 11284 * @see addStyleClient 11285 * @see mx.styles.IAdvancedStyleClient 11286 * 11287 * @langversion 3.0 11288 * @playerversion Flash 9 11289 * @playerversion AIR 1.1 11290 * @productversion Flex 4.5 11291 */ 11292 public function removeStyleClient(styleClient:IAdvancedStyleClient):void 11293 { 11294 if(advanceStyleClientChildren && 11295 advanceStyleClientChildren[styleClient]) 11296 { 11297 delete advanceStyleClientChildren[styleClient]; 11298 11299 styleClient.styleParent = null; 11300 11301 styleClient.regenerateStyleCache(true); 11302 11303 styleClient.styleChanged(null); 11304 } 11305 } 11306 11307 /** 11308 * Propagates style changes to the children. 11309 * You typically never need to call this method. 11310 * 11311 * @param styleProp String specifying the name of the style property. 11312 * 11313 * @param recursive Recursivly notify all children of this component. 11314 * 11315 * @langversion 3.0 11316 * @playerversion Flash 9 11317 * @playerversion AIR 1.1 11318 * @productversion Flex 3 11319 */ 11320 public function notifyStyleChangeInChildren( 11321 styleProp:String, recursive:Boolean):void 11322 { 11323 cachedTextFormat = null; 11324 11325 var n:int = numChildren; 11326 for (var i:int = 0; i < n; i++) 11327 { 11328 var child:ISimpleStyleClient = getChildAt(i) as ISimpleStyleClient; 11329 11330 if (child) 11331 { 11332 child.styleChanged(styleProp); 11333 11334 // Always recursively call this function because of my 11335 // descendants might have a styleName property that points 11336 // to this object. The recursive flag is respected in 11337 // Container.notifyStyleChangeInChildren. 11338 if (child is IStyleClient) 11339 IStyleClient(child).notifyStyleChangeInChildren(styleProp, recursive); 11340 } 11341 } 11342 11343 if (advanceStyleClientChildren != null) 11344 { 11345 for (var styleClient:Object in advanceStyleClientChildren) 11346 { 11347 var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient 11348 as IAdvancedStyleClient; 11349 11350 if (iAdvanceStyleClientChild) 11351 { 11352 iAdvanceStyleClientChild.styleChanged(styleProp); 11353 } 11354 } 11355 } 11356 } 11357 11358 /** 11359 * @private 11360 * If this object has a themeColor style, which is not inherited, 11361 * then set it inline. 11362 */ 11363 mx_internal function initThemeColor():Boolean 11364 { 11365 if (FlexVersion.compatibilityVersion >= FlexVersion.VERSION_4_0) 11366 return true; 11367 11368 var styleName:Object /* String or UIComponent */ = _styleName; 11369 11370 var tc:Object; // Can be number or string 11371 var rc:Number; 11372 var sc:Number; 11373 var i:int; 11374 11375 // First look for locally-declared styles 11376 if (_styleDeclaration) 11377 { 11378 tc = _styleDeclaration.getStyle("themeColor"); 11379 rc = _styleDeclaration.getStyle("rollOverColor"); 11380 sc = _styleDeclaration.getStyle("selectionColor"); 11381 } 11382 11383 if (styleManager.hasAdvancedSelectors()) 11384 { 11385 // Next look for matching selectors (working backwards, starting 11386 // with the most specific selector) 11387 if (tc === null || !styleManager.isValidStyleValue(tc)) 11388 { 11389 var styleDeclarations:Array = StyleProtoChain.getMatchingStyleDeclarations(this); 11390 for (i = styleDeclarations.length - 1; i >= 0; i--) 11391 { 11392 var decl:CSSStyleDeclaration = styleDeclarations[i]; 11393 if (decl) 11394 { 11395 tc = decl.getStyle("themeColor"); 11396 rc = decl.getStyle("rollOverColor"); 11397 sc = decl.getStyle("selectionColor"); 11398 } 11399 11400 if (tc !== null && styleManager.isValidStyleValue(tc)) 11401 break; 11402 } 11403 } 11404 } 11405 else 11406 { 11407 // Next look for class selectors 11408 if ((tc === null || !styleManager.isValidStyleValue(tc)) && 11409 (styleName && !(styleName is ISimpleStyleClient))) 11410 { 11411 var classSelector:Object = 11412 styleName is String ? 11413 styleManager.getMergedStyleDeclaration("." + styleName) : 11414 styleName; 11415 11416 if (classSelector) 11417 { 11418 tc = classSelector.getStyle("themeColor"); 11419 rc = classSelector.getStyle("rollOverColor"); 11420 sc = classSelector.getStyle("selectionColor"); 11421 } 11422 } 11423 11424 // Finally look for type selectors 11425 if (tc === null || !styleManager.isValidStyleValue(tc)) 11426 { 11427 var typeSelectors:Array = getClassStyleDeclarations(); 11428 11429 for (i = 0; i < typeSelectors.length; i++) 11430 { 11431 var typeSelector:CSSStyleDeclaration = typeSelectors[i]; 11432 11433 if (typeSelector) 11434 { 11435 tc = typeSelector.getStyle("themeColor"); 11436 rc = typeSelector.getStyle("rollOverColor"); 11437 sc = typeSelector.getStyle("selectionColor"); 11438 } 11439 11440 if (tc !== null && styleManager.isValidStyleValue(tc)) 11441 break; 11442 } 11443 } 11444 } 11445 11446 // If we have a themeColor but no rollOverColor or selectionColor, call 11447 // setThemeColor here which will calculate rollOver/selectionColor based 11448 // on the themeColor. 11449 if (tc !== null && styleManager.isValidStyleValue(tc) && isNaN(rc) && isNaN(sc)) 11450 { 11451 setThemeColor(tc); 11452 return true; 11453 } 11454 11455 return (tc !== null && styleManager.isValidStyleValue(tc)) && !isNaN(rc) && !isNaN(sc); 11456 } 11457 11458 /** 11459 * @private 11460 * Calculate and set new roll over and selection colors based on theme color. 11461 */ 11462 mx_internal function setThemeColor(value:Object /* Number or String */):void 11463 { 11464 var newValue:Number; 11465 11466 if (newValue is String) 11467 newValue = parseInt(String(value)); 11468 else 11469 newValue = Number(value); 11470 11471 if (isNaN(newValue)) 11472 newValue = styleManager.getColorName(value); 11473 11474 var newValueS:Number = ColorUtil.adjustBrightness2(newValue, 50); 11475 11476 var newValueR:Number = ColorUtil.adjustBrightness2(newValue, 70); 11477 11478 setStyle("selectionColor", newValueS); 11479 setStyle("rollOverColor", newValueR); 11480 } 11481 11482 /** 11483 * Returns a UITextFormat object corresponding to the text styles 11484 * for this UIComponent. 11485 * 11486 * @return UITextFormat object corresponding to the text styles 11487 * for this UIComponent. 11488 * 11489 * @langversion 3.0 11490 * @playerversion Flash 9 11491 * @playerversion AIR 1.1 11492 * @productversion Flex 3 11493 */ 11494 public function determineTextFormatFromStyles():UITextFormat 11495 { 11496 var textFormat:UITextFormat = cachedTextFormat; 11497 11498 if (!textFormat) 11499 { 11500 var font:String = 11501 StringUtil.trimArrayElements(_inheritingStyles.fontFamily, ","); 11502 textFormat = new UITextFormat(getNonNullSystemManager(), font); 11503 textFormat.moduleFactory = moduleFactory; 11504 11505 // Not all flex4 textAlign values are valid so convert to a valid one. 11506 var align:String = _inheritingStyles.textAlign; 11507 if (align == "start") 11508 align = TextFormatAlign.LEFT; 11509 else if (align == "end") 11510 align = TextFormatAlign.RIGHT; 11511 textFormat.align = align; 11512 textFormat.bold = _inheritingStyles.fontWeight == "bold"; 11513 textFormat.color = enabled ? 11514 _inheritingStyles.color : 11515 _inheritingStyles.disabledColor; 11516 textFormat.font = font; 11517 textFormat.indent = _inheritingStyles.textIndent; 11518 textFormat.italic = _inheritingStyles.fontStyle == "italic"; 11519 textFormat.kerning = _inheritingStyles.kerning; 11520 textFormat.leading = _nonInheritingStyles.leading; 11521 textFormat.leftMargin = _nonInheritingStyles.paddingLeft; 11522 textFormat.letterSpacing = _inheritingStyles.letterSpacing; 11523 textFormat.rightMargin = _nonInheritingStyles.paddingRight; 11524 textFormat.size = _inheritingStyles.fontSize; 11525 textFormat.underline = 11526 _nonInheritingStyles.textDecoration == "underline"; 11527 11528 textFormat.antiAliasType = _inheritingStyles.fontAntiAliasType; 11529 textFormat.gridFitType = _inheritingStyles.fontGridFitType; 11530 textFormat.sharpness = _inheritingStyles.fontSharpness; 11531 textFormat.thickness = _inheritingStyles.fontThickness; 11532 11533 textFormat.useFTE = 11534 getTextFieldClassName() == "mx.core::UIFTETextField" || 11535 getTextInputClassName() == "mx.controls::MXFTETextInput"; 11536 11537 if (textFormat.useFTE) 11538 { 11539 textFormat.direction = _inheritingStyles.direction; 11540 textFormat.locale = _inheritingStyles.locale; 11541 } 11542 11543 cachedTextFormat = textFormat; 11544 } 11545 11546 return textFormat; 11547 } 11548 11549 11550 //-------------------------------------------------------------------------- 11551 // 11552 // Methods: Binding 11553 // 11554 //-------------------------------------------------------------------------- 11555 11556 /** 11557 * Executes all the bindings for which the UIComponent object is the destination. 11558 * 11559 * @param recurse Recursively execute bindings for children of this component. 11560 * 11561 * @langversion 3.0 11562 * @playerversion Flash 9 11563 * @playerversion AIR 1.1 11564 * @productversion Flex 3 11565 */ 11566 public function executeBindings(recurse:Boolean = false):void 11567 { 11568 var bindingsHost:Object = descriptor && descriptor.document ? descriptor.document : parentDocument; 11569 BindingManager.executeBindings(bindingsHost, id, this); 11570 } 11571 11572 //-------------------------------------------------------------------------- 11573 // 11574 // Methods: Effects 11575 // 11576 //-------------------------------------------------------------------------- 11577 11578 /** 11579 * For each effect event, registers the EffectManager 11580 * as one of the event listeners. 11581 * You typically never need to call this method. 11582 * 11583 * @param effects The names of the effect events. 11584 * 11585 * @langversion 3.0 11586 * @playerversion Flash 9 11587 * @playerversion AIR 1.1 11588 * @productversion Flex 3 11589 */ 11590 public function registerEffects(effects:Array /* of String */):void 11591 { 11592 var n:int = effects.length; 11593 for (var i:int = 0; i < n; i++) 11594 { 11595 // Ask the EffectManager for the event associated with this effectTrigger 11596 var event:String = EffectManager.getEventForEffectTrigger(effects[i]); 11597 11598 if (event != null && event != "") 11599 { 11600 addEventListener(event, EffectManager.eventHandler, 11601 false, EventPriority.EFFECT); 11602 } 11603 } 11604 } 11605 11606 /** 11607 * @private 11608 * 11609 * Adds an overlay object that's always on top of our children. 11610 * Calls createOverlay(), which returns the overlay object. 11611 * Currently used by the Dissolve and Resize effects. 11612 * 11613 * Returns the overlay object. 11614 */ 11615 mx_internal function addOverlay(color:uint, 11616 targetArea:RoundedRectangle = null):void 11617 { 11618 if (!effectOverlay) 11619 { 11620 effectOverlayColor = color; 11621 effectOverlay = new UIComponent(); 11622 effectOverlay.name = "overlay"; 11623 // Have to set visibility immediately 11624 // to make sure we avoid flicker 11625 effectOverlay.$visible = true; 11626 11627 fillOverlay(effectOverlay, color, targetArea); 11628 11629 attachOverlay(); 11630 11631 if (!targetArea) 11632 addEventListener(ResizeEvent.RESIZE, overlay_resizeHandler); 11633 11634 effectOverlay.x = 0; 11635 effectOverlay.y = 0; 11636 11637 invalidateDisplayList(); 11638 11639 effectOverlayReferenceCount = 1; 11640 } 11641 else 11642 { 11643 effectOverlayReferenceCount++; 11644 } 11645 11646 dispatchEvent(new ChildExistenceChangedEvent(ChildExistenceChangedEvent.OVERLAY_CREATED, true, false, effectOverlay)); 11647 } 11648 11649 /** 11650 * This is an internal method used by the Flex framework 11651 * to support the Dissolve effect. 11652 * You do not have to call it or override it. 11653 * 11654 * @langversion 3.0 11655 * @playerversion Flash 9 11656 * @playerversion AIR 1.1 11657 * @productversion Flex 3 11658 */ 11659 protected function attachOverlay():void 11660 { 11661 addChild(effectOverlay); 11662 } 11663 11664 /** 11665 * @private 11666 * Fill an overlay object which is always the topmost child. 11667 * Used by the Dissolve effect. 11668 * Never call this function directly. 11669 * It is called internally by addOverlay(). 11670 * 11671 * The overlay object is filled with a solid rectangle that has the 11672 * same width and height as the component. 11673 */ 11674 mx_internal function fillOverlay(overlay:UIComponent, color:uint, 11675 targetArea:RoundedRectangle = null):void 11676 { 11677 if (!targetArea) 11678 targetArea = new RoundedRectangle(0, 0, unscaledWidth, unscaledHeight, 0); 11679 11680 var g:Graphics = overlay.graphics; 11681 g.clear(); 11682 g.beginFill(color); 11683 11684 g.drawRoundRect(targetArea.x, targetArea.y, 11685 targetArea.width, targetArea.height, 11686 targetArea.cornerRadius * 2, 11687 targetArea.cornerRadius * 2); 11688 g.endFill(); 11689 } 11690 11691 /** 11692 * @private 11693 * Removes the overlay object added by addOverlay(). 11694 */ 11695 mx_internal function removeOverlay():void 11696 { 11697 if (effectOverlayReferenceCount > 0 && --effectOverlayReferenceCount == 0 && effectOverlay) 11698 { 11699 removeEventListener(ResizeEvent.RESIZE, overlay_resizeHandler); 11700 11701 if (super.getChildByName("overlay")) 11702 $removeChild(effectOverlay); 11703 11704 effectOverlay = null; 11705 } 11706 } 11707 /** 11708 * @private 11709 * Resize the overlay when the components size changes 11710 * 11711 */ 11712 private function overlay_resizeHandler(event:Event):void 11713 { 11714 fillOverlay(effectOverlay, effectOverlayColor, null); 11715 } 11716 11717 /** 11718 * @private 11719 */ 11720 mx_internal var _effectsStarted:Array = []; 11721 11722 /** 11723 * @private 11724 */ 11725 mx_internal var _affectedProperties:Object = {}; 11726 11727 /** 11728 * Contains <code>true</code> if an effect is currently playing on the component. 11729 * 11730 * @langversion 3.0 11731 * @playerversion Flash 9 11732 * @playerversion AIR 1.1 11733 * @productversion Flex 3 11734 */ 11735 private var _isEffectStarted:Boolean = false; 11736 mx_internal function get isEffectStarted():Boolean 11737 { 11738 return _isEffectStarted; 11739 } 11740 mx_internal function set isEffectStarted(value:Boolean):void 11741 { 11742 _isEffectStarted = value; 11743 } 11744 11745 private var preventDrawFocus:Boolean = false; 11746 11747 /** 11748 * Called by the effect instance when it starts playing on the component. 11749 * You can use this method to perform a modification to the component as part 11750 * of an effect. You can use the <code>effectFinished()</code> method 11751 * to restore the modification when the effect ends. 11752 * 11753 * @param effectInst The effect instance object playing on the component. 11754 * 11755 * @langversion 3.0 11756 * @playerversion Flash 9 11757 * @playerversion AIR 1.1 11758 * @productversion Flex 3 11759 */ 11760 public function effectStarted(effectInst:IEffectInstance):void 11761 { 11762 // Check that the instance isn't already in our list 11763 _effectsStarted.push(effectInst); 11764 11765 var aProps:Array = effectInst.effect.getAffectedProperties(); 11766 for (var j:int = 0; j < aProps.length; j++) 11767 { 11768 var propName:String = aProps[j]; 11769 if (_affectedProperties[propName] == undefined) 11770 { 11771 _affectedProperties[propName] = []; 11772 } 11773 11774 _affectedProperties[propName].push(effectInst); 11775 } 11776 11777 isEffectStarted = true; 11778 // Hide the focus ring if the target already has one drawn 11779 if (effectInst.hideFocusRing) 11780 { 11781 preventDrawFocus = true; 11782 drawFocus(false); 11783 } 11784 } 11785 11786 11787 private var _endingEffectInstances:Array = []; 11788 11789 /** 11790 * Called by the effect instance when it stops playing on the component. 11791 * You can use this method to restore a modification to the component made 11792 * by the <code>effectStarted()</code> method when the effect started, 11793 * or perform some other action when the effect ends. 11794 * 11795 * @param effectInst The effect instance object playing on the component. 11796 * 11797 * @langversion 3.0 11798 * @playerversion Flash 9 11799 * @playerversion AIR 1.1 11800 * @productversion Flex 3 11801 */ 11802 public function effectFinished(effectInst:IEffectInstance):void 11803 { 11804 _endingEffectInstances.push(effectInst); 11805 invalidateProperties(); 11806 11807 // weak reference 11808 UIComponentGlobals.layoutManager.addEventListener( 11809 FlexEvent.UPDATE_COMPLETE, updateCompleteHandler, false, 0, true); 11810 } 11811 11812 /** 11813 * Ends all currently playing effects on the component. 11814 * 11815 * @langversion 3.0 11816 * @playerversion Flash 9 11817 * @playerversion AIR 1.1 11818 * @productversion Flex 3 11819 */ 11820 public function endEffectsStarted():void 11821 { 11822 var len:int = _effectsStarted.length; 11823 for (var i:int = 0; i < len; i++) 11824 { 11825 _effectsStarted[i].end(); 11826 } 11827 } 11828 11829 /** 11830 * @private 11831 */ 11832 private function updateCompleteHandler(event:FlexEvent):void 11833 { 11834 UIComponentGlobals.layoutManager.removeEventListener( 11835 FlexEvent.UPDATE_COMPLETE, updateCompleteHandler); 11836 processEffectFinished(_endingEffectInstances); 11837 _endingEffectInstances = []; 11838 } 11839 11840 /** 11841 * @private 11842 */ 11843 private function processEffectFinished(effectInsts:Array):void 11844 { 11845 // Find the instance in our list. 11846 for (var i:int = _effectsStarted.length - 1; i >= 0; i--) 11847 { 11848 for (var j:int = 0; j < effectInsts.length; j++) 11849 { 11850 var effectInst:IEffectInstance = effectInsts[j]; 11851 if (effectInst == _effectsStarted[i]) 11852 { 11853 // Remove the effect from our array. 11854 var removedInst:IEffectInstance = _effectsStarted[i]; 11855 _effectsStarted.splice(i, 1); 11856 11857 // Remove the affected properties from our internal object 11858 var aProps:Array = removedInst.effect.getAffectedProperties(); 11859 for (var k:int = 0; k < aProps.length; k++) 11860 { 11861 var propName:String = aProps[k]; 11862 if (_affectedProperties[propName] != undefined) 11863 { 11864 for (var l:int = 0; l < _affectedProperties[propName].length; l++) 11865 { 11866 if (_affectedProperties[propName][l] == effectInst) 11867 { 11868 _affectedProperties[propName].splice(l, 1); 11869 break; 11870 } 11871 } 11872 11873 if (_affectedProperties[propName].length == 0) 11874 delete _affectedProperties[propName]; 11875 } 11876 } 11877 break; 11878 } 11879 } 11880 } 11881 11882 isEffectStarted = _effectsStarted.length > 0 ? true : false; 11883 if (effectInst && effectInst.hideFocusRing) 11884 { 11885 preventDrawFocus = false; 11886 } 11887 } 11888 11889 /** 11890 * @private 11891 */ 11892 mx_internal function getEffectsForProperty(propertyName:String):Array 11893 { 11894 return _affectedProperties[propertyName] != undefined ? 11895 _affectedProperties[propertyName] : 11896 []; 11897 } 11898 11899 //-------------------------------------------------------------------------- 11900 // 11901 // Methods: Repeater 11902 // 11903 //-------------------------------------------------------------------------- 11904 11905 /** 11906 * @inheritDoc 11907 * 11908 * @langversion 3.0 11909 * @playerversion Flash 9 11910 * @playerversion AIR 1.1 11911 * @productversion Flex 3 11912 */ 11913 public function createReferenceOnParentDocument( 11914 parentDocument:IFlexDisplayObject):void 11915 { 11916 if (id && id != "") 11917 { 11918 var indices:Array = _instanceIndices; 11919 if (!indices) 11920 { 11921 parentDocument[id] = this; 11922 } 11923 else 11924 { 11925 var r:Object = parentDocument[id]; 11926 11927 if (! (r is Array)) 11928 { 11929 r = parentDocument[id] = []; 11930 } 11931 11932 var n:int = indices.length; 11933 for (var i:int = 0; i < n - 1; i++) 11934 { 11935 var s:Object = r[indices[i]]; 11936 11937 if (!(s is Array)) 11938 s = r[indices[i]] = []; 11939 11940 r = s; 11941 } 11942 11943 r[indices[n - 1]] = this; 11944 11945 if (parentDocument.hasEventListener("propertyChange")) 11946 { 11947 var event:PropertyChangeEvent = 11948 PropertyChangeEvent.createUpdateEvent(parentDocument, 11949 id, 11950 parentDocument[id], 11951 parentDocument[id]); 11952 parentDocument.dispatchEvent(event); 11953 } 11954 } 11955 } 11956 } 11957 11958 /** 11959 * @inheritDoc 11960 * 11961 * @langversion 3.0 11962 * @playerversion Flash 9 11963 * @playerversion AIR 1.1 11964 * @productversion Flex 3 11965 */ 11966 public function deleteReferenceOnParentDocument( 11967 parentDocument:IFlexDisplayObject):void 11968 { 11969 if (id && id != "") 11970 { 11971 var indices:Array = _instanceIndices; 11972 if (!indices) 11973 { 11974 parentDocument[id] = null; 11975 } 11976 else 11977 { 11978 var r:Object = parentDocument[id]; 11979 11980 if (!r) 11981 return; 11982 11983 var stack:Array = []; 11984 stack.push(r); 11985 11986 var n:int = indices.length; 11987 for (var i:int = 0; i < n - 1; i++) 11988 { 11989 var s:Object = r[indices[i]]; 11990 11991 if (!s) 11992 return; 11993 11994 r = s; 11995 stack.push(r); 11996 } 11997 11998 r.splice(indices[n - 1], 1); 11999 12000 for (var j:int = stack.length - 1; j > 0; j--) 12001 { 12002 if (stack[j].length == 0) 12003 stack[j - 1].splice(indices[j], 1); 12004 } 12005 12006 if ((stack.length > 0) && (stack[0].length == 0)) 12007 { 12008 parentDocument[id] = null; 12009 } 12010 else 12011 { 12012 if (parentDocument.hasEventListener("propertyChange")) 12013 { 12014 var event:PropertyChangeEvent = 12015 PropertyChangeEvent.createUpdateEvent(parentDocument, 12016 id, 12017 parentDocument[id], 12018 parentDocument[id]); 12019 parentDocument.dispatchEvent(event); 12020 } 12021 } 12022 } 12023 } 12024 } 12025 12026 /** 12027 * Returns the item in the <code>dataProvider</code> that was used 12028 * by the specified Repeater to produce this Repeater, or 12029 * <code>null</code> if this Repeater isn't repeated. 12030 * The argument <code>whichRepeater</code> is 0 for the outermost 12031 * Repeater, 1 for the next inner Repeater, and so on. 12032 * If <code>whichRepeater</code> is not specified, 12033 * the innermost Repeater is used. 12034 * 12035 * @param whichRepeater Number of the Repeater, 12036 * counting from the outermost one, starting at 0. 12037 * 12038 * @return The requested repeater item. 12039 * 12040 * @langversion 3.0 12041 * @playerversion Flash 9 12042 * @playerversion AIR 1.1 12043 * @productversion Flex 3 12044 */ 12045 public function getRepeaterItem(whichRepeater:int = -1):Object 12046 { 12047 var repeaterArray:Array = repeaters; 12048 12049 // If repeaterArray has no items the caller is not 12050 // in a repeater. Return null. 12051 if (repeaterArray.length == 0) 12052 return null; 12053 12054 // If whichRepeater isn't specified, assume the 12055 // innermost Repeater. This lets authors simply write 12056 // myRepeater.getRepeaterItem() 12057 if (whichRepeater == -1) 12058 whichRepeater = repeaterArray.length - 1; 12059 12060 return repeaterArray[whichRepeater]. 12061 getItemAt(repeaterIndices[whichRepeater]); 12062 } 12063 12064 //-------------------------------------------------------------------------- 12065 // 12066 // Methods: Resources 12067 // 12068 //-------------------------------------------------------------------------- 12069 12070 /** 12071 * This method is called when a UIComponent is constructed, 12072 * and again whenever the ResourceManager dispatches 12073 * a <code>"change"</code> Event to indicate 12074 * that the localized resources have changed in some way. 12075 * 12076 * <p>This event is dispatched when you set the ResourceManager's 12077 * <code>localeChain</code> property, when a resource module 12078 * has finished loading, and when you call the ResourceManager's 12079 * <code>update()</code> method.</p> 12080 * 12081 * <p>Subclasses should override this method and, after calling 12082 * <code>super.resourcesChanged()</code>, do whatever is appropriate 12083 * in response to having new resource values.</p> 12084 * 12085 * @langversion 3.0 12086 * @playerversion Flash 9 12087 * @playerversion AIR 1.1 12088 * @productversion Flex 3 12089 */ 12090 protected function resourcesChanged():void 12091 { 12092 } 12093 12094 //-------------------------------------------------------------------------- 12095 // 12096 // Methods: Printing 12097 // 12098 //-------------------------------------------------------------------------- 12099 12100 /** 12101 * Prepares an IFlexDisplayObject for printing. 12102 * For the UIComponent class, the method performs no action. 12103 * Flex containers override the method to prepare for printing; 12104 * for example, by removing scroll bars from the printed output. 12105 * 12106 * <p>This method is normally not used by application developers. </p> 12107 * 12108 * @param target The component to be printed. 12109 * It can be the current component or one of its children. 12110 * 12111 * @return Object containing the properties of the current component 12112 * required by the <code>finishPrint()</code> method 12113 * to restore it to its previous state. 12114 * 12115 * @see mx.printing.FlexPrintJob 12116 * 12117 * @langversion 3.0 12118 * @playerversion Flash 9 12119 * @playerversion AIR 1.1 12120 * @productversion Flex 3 12121 */ 12122 public function prepareToPrint(target:IFlexDisplayObject):Object 12123 { 12124 return null; 12125 } 12126 12127 /** 12128 * Called after printing is complete. 12129 * For the UIComponent class, the method performs no action. 12130 * Flex containers override the method to restore the container after printing. 12131 * 12132 * <p>This method is normally not used by application developers. </p> 12133 * 12134 * @param obj Contains the properties of the component that 12135 * restore it to its state before printing. 12136 * 12137 * @param target The component that just finished printing. 12138 * It can be the current component or one of its children. 12139 * 12140 * @see mx.printing.FlexPrintJob 12141 * 12142 * @langversion 3.0 12143 * @playerversion Flash 9 12144 * @playerversion AIR 1.1 12145 * @productversion Flex 3 12146 */ 12147 public function finishPrint(obj:Object, target:IFlexDisplayObject):void 12148 { 12149 } 12150 12151 //-------------------------------------------------------------------------- 12152 // 12153 // Event handlers: Invalidation 12154 // 12155 //-------------------------------------------------------------------------- 12156 12157 /** 12158 * @private 12159 * Callback that then calls queued functions. 12160 */ 12161 private function callLaterDispatcher(event:Event):void 12162 { 12163 // trace(">>calllaterdispatcher " + this); 12164 UIComponentGlobals.callLaterDispatcherCount++; 12165 12166 // At run-time, callLaterDispatcher2() is called 12167 // without a surrounding try-catch. 12168 if (!UIComponentGlobals.catchCallLaterExceptions) 12169 { 12170 callLaterDispatcher2(event); 12171 } 12172 12173 // At design-time, callLaterDispatcher2() is called 12174 // with a surrounding try-catch. 12175 else 12176 { 12177 try 12178 { 12179 callLaterDispatcher2(event); 12180 } 12181 catch(e:Error) 12182 { 12183 // Dispatch a callLaterError dynamic event for Design View. 12184 var callLaterErrorEvent:DynamicEvent = new DynamicEvent("callLaterError"); 12185 callLaterErrorEvent.error = e; 12186 callLaterErrorEvent.source = this; 12187 systemManager.dispatchEvent(callLaterErrorEvent); 12188 } 12189 } 12190 // trace("<<calllaterdispatcher"); 12191 UIComponentGlobals.callLaterDispatcherCount--; 12192 } 12193 12194 /** 12195 * @private 12196 * Callback that then calls queued functions. 12197 */ 12198 private function callLaterDispatcher2(event:Event):void 12199 { 12200 if (UIComponentGlobals.callLaterSuspendCount > 0) 12201 return; 12202 12203 // trace(" >>calllaterdispatcher2"); 12204 var sm:ISystemManager = systemManager; 12205 12206 // Stage can be null when an untrusted application is loaded by an application 12207 // that isn't on stage yet. 12208 if (sm && (sm.stage || usingBridge) && listeningForRender) 12209 { 12210 // trace(" removed"); 12211 sm.removeEventListener(FlexEvent.RENDER, callLaterDispatcher); 12212 sm.removeEventListener(FlexEvent.ENTER_FRAME, callLaterDispatcher); 12213 listeningForRender = false; 12214 } 12215 12216 // Move the method queue off to the side, so that subsequent 12217 // calls to callLater get added to a new queue that'll get handled 12218 // next time. 12219 var queue:Array = methodQueue; 12220 methodQueue = []; 12221 12222 // Call each method currently in the method queue. 12223 // These methods can call callLater(), causing additional 12224 // methods to be queued, but these will get called the next 12225 // time around. 12226 var n:int = queue.length; 12227 // trace(" queue length " + n); 12228 for (var i:int = 0; i < n; i++) 12229 { 12230 var mqe:MethodQueueElement = MethodQueueElement(queue[i]); 12231 12232 mqe.method.apply(null, mqe.args); 12233 } 12234 12235 // trace(" <<calllaterdispatcher2 " + this); 12236 } 12237 12238 //-------------------------------------------------------------------------- 12239 // 12240 // Event handlers: Keyboard 12241 // 12242 //-------------------------------------------------------------------------- 12243 12244 /** 12245 * The event handler called for a <code>keyDown</code> event. 12246 * If you override this method, make sure to call the base class version. 12247 * 12248 * @param event The event object. 12249 * 12250 * @langversion 3.0 12251 * @playerversion Flash 9 12252 * @playerversion AIR 1.1 12253 * @productversion Flex 3 12254 */ 12255 protected function keyDownHandler(event:KeyboardEvent):void 12256 { 12257 // You must override this function if your component accepts focus 12258 } 12259 12260 /** 12261 * The event handler called for a <code>keyUp</code> event. 12262 * If you override this method, make sure to call the base class version. 12263 * 12264 * @param event The event object. 12265 * 12266 * @langversion 3.0 12267 * @playerversion Flash 9 12268 * @playerversion AIR 1.1 12269 * @productversion Flex 3 12270 */ 12271 protected function keyUpHandler(event:KeyboardEvent):void 12272 { 12273 // You must override this function if your component accepts focus 12274 } 12275 12276 /** 12277 * Typically overridden by components containing UITextField objects, 12278 * where the UITextField object gets focus. 12279 * 12280 * @param target A UIComponent object containing a UITextField object 12281 * that can receive focus. 12282 * 12283 * @return Returns <code>true</code> if the UITextField object has focus. 12284 * 12285 * @langversion 3.0 12286 * @playerversion Flash 9 12287 * @playerversion AIR 1.1 12288 * @productversion Flex 3 12289 */ 12290 protected function isOurFocus(target:DisplayObject):Boolean 12291 { 12292 return target == this; 12293 } 12294 12295 /** 12296 * The event handler called when a UIComponent object gets focus. 12297 * If you override this method, make sure to call the base class version. 12298 * 12299 * @param event The event object. 12300 * 12301 * @langversion 3.0 12302 * @playerversion Flash 9 12303 * @playerversion AIR 1.1 12304 * @productversion Flex 3 12305 */ 12306 protected function focusInHandler(event:FocusEvent):void 12307 { 12308 if (isOurFocus(DisplayObject(event.target))) 12309 { 12310 var fm:IFocusManager = focusManager; 12311 if (fm && fm.showFocusIndicator) 12312 drawFocus(true); 12313 12314 ContainerGlobals.checkFocus(event.relatedObject, this); 12315 } 12316 } 12317 12318 /** 12319 * The event handler called when a UIComponent object loses focus. 12320 * If you override this method, make sure to call the base class version. 12321 * 12322 * @param event The event object. 12323 * 12324 * @langversion 3.0 12325 * @playerversion Flash 9 12326 * @playerversion AIR 1.1 12327 * @productversion Flex 3 12328 */ 12329 protected function focusOutHandler(event:FocusEvent):void 12330 { 12331 // We don't need to remove our event listeners here because we 12332 // won't receive keyboard events. 12333 if (isOurFocus(DisplayObject(event.target))) 12334 drawFocus(false); 12335 } 12336 12337 /** 12338 * @private 12339 * The player dispatches an "added" event when the addChild() 12340 * or addChildAt() method of DisplayObjectContainer is called, 12341 * but handling this event at that time can be dangerous 12342 * so we prevent the event dispatched then from propagating; 12343 * we'll dispatch another "added" event later when it is safe. 12344 * The reason the timing of this player event is dangerous 12345 * is that the Flex framework overrides addChild() and addChildAt(), 12346 * to perform important additional work after calling the super 12347 * method, such as setting _parent to skip over the contentPane 12348 * of a Container. So if an "added" handler executes too early, 12349 * the child is in an inconsistent state. (For example, its 12350 * toString() can be wrong because the contentPane is wrongly 12351 * included when traversing the parent chain.) Our overrides 12352 * delay dispatching the "added" event until the end of the 12353 * override, as opposed to in the middle when super.addChild() 12354 * is called. 12355 * Note: This event handler is registered by the UIComponent 12356 * constructor, which means it is registered before any 12357 * other handlers for an "added" event. 12358 * Therefore it can prevent all others from being called. 12359 */ 12360 private function addedHandler(event:Event):void 12361 { 12362 //reset systemManager in case we've been reparented to a new Window. 12363 //systemManager will be set on get systemManager() 12364 if (event.eventPhase != EventPhase.AT_TARGET) 12365 return; 12366 12367 try 12368 { 12369 if (parent is IContainer && IContainer(parent).creatingContentPane) 12370 { 12371 event.stopImmediatePropagation(); 12372 return; 12373 } 12374 } 12375 catch (error:SecurityError) 12376 { 12377 12378 } 12379 } 12380 12381 /** 12382 * @private 12383 * See the comments for addedHandler() above. 12384 */ 12385 private function removedHandler(event:Event):void 12386 { 12387 if (event.eventPhase != EventPhase.AT_TARGET) 12388 return; 12389 12390 try 12391 { 12392 if (parent is IContainer && IContainer(parent).creatingContentPane) 12393 { 12394 event.stopImmediatePropagation(); 12395 return; 12396 } 12397 } 12398 catch (error:SecurityError) 12399 { 12400 12401 } 12402 } 12403 12404 /** 12405 * @private 12406 */ 12407 private function removedFromStageHandler(event:Event):void 12408 { 12409 _systemManagerDirty = true; 12410 } 12411 12412 /** 12413 * @private 12414 * There is a bug (139390) where setting focus from within callLaterDispatcher 12415 * screws up the ActiveX player. We defer focus until enterframe. 12416 */ 12417 private function setFocusLater(event:Event = null):void 12418 { 12419 var sm:ISystemManager = systemManager; 12420 if (sm && sm.stage) 12421 { 12422 sm.stage.removeEventListener(Event.ENTER_FRAME, setFocusLater); 12423 if (UIComponentGlobals.nextFocusObject) 12424 sm.stage.focus = UIComponentGlobals.nextFocusObject; 12425 UIComponentGlobals.nextFocusObject = null; 12426 } 12427 } 12428 12429 /** 12430 * @private 12431 * Called when this component moves. Adjust the focus rect. 12432 */ 12433 private function focusObj_scrollHandler(event:Event):void 12434 { 12435 adjustFocusRect(); 12436 } 12437 12438 /** 12439 * @private 12440 * Called when this component moves. Adjust the focus rect. 12441 */ 12442 private function focusObj_moveHandler(event:MoveEvent):void 12443 { 12444 adjustFocusRect(); 12445 } 12446 12447 /** 12448 * @private 12449 * Called when this component resizes. Adjust the focus rect. 12450 */ 12451 private function focusObj_resizeHandler(event:Event):void 12452 { 12453 if (event is ResizeEvent) 12454 adjustFocusRect(); 12455 } 12456 12457 /** 12458 * @private 12459 * Called when this component is unloaded. Hide the focus rect. 12460 */ 12461 private function focusObj_removedHandler(event:Event):void 12462 { 12463 // ignore if we captured on a child 12464 if (event.target != this) 12465 return; 12466 12467 var focusObject:DisplayObject = getFocusObject(); 12468 12469 if (focusObject) 12470 focusObject.visible = false; 12471 } 12472 12473 /** 12474 * @private 12475 * Called when our associated layer parent needs to inform us of 12476 * a change to it's visibility or alpha. 12477 */ 12478 protected function layer_PropertyChange(event:PropertyChangeEvent):void 12479 { 12480 switch (event.property) 12481 { 12482 case "effectiveVisibility": 12483 { 12484 var newValue:Boolean = (event.newValue && _visible); 12485 if (newValue != $visible) 12486 $visible = newValue; 12487 break; 12488 } 12489 case "effectiveAlpha": 12490 { 12491 var newAlpha:Number = Number(event.newValue) * _alpha; 12492 if (newAlpha != $alpha) 12493 $alpha = newAlpha; 12494 break; 12495 } 12496 } 12497 } 12498 12499 //-------------------------------------------------------------------------- 12500 // 12501 // Event handlers: Validation 12502 // 12503 //-------------------------------------------------------------------------- 12504 12505 /** 12506 * Handles both the <code>valid</code> and <code>invalid</code> events from a 12507 * validator assigned to this component. 12508 * 12509 * <p>You typically handle the <code>valid</code> and <code>invalid</code> events 12510 * dispatched by a validator by assigning event listeners to the validators. 12511 * If you want to handle validation events directly in the component that is being validated, 12512 * you can override this method to handle the <code>valid</code> 12513 * and <code>invalid</code> events. You typically call 12514 * <code>super.validationResultHandler(event)</code> in your override.</p> 12515 * 12516 * @param event The event object for the validation. 12517 * 12518 * @see mx.events.ValidationResultEvent 12519 * 12520 * @langversion 3.0 12521 * @playerversion Flash 9 12522 * @playerversion AIR 1.1 12523 * @productversion Flex 3 12524 */ 12525 public function validationResultHandler(event:ValidationResultEvent):void 12526 { 12527 if (errorObjectArray === null) 12528 { 12529 errorObjectArray = new Array(); 12530 errorArray = new Array(); 12531 } 12532 12533 var validatorIndex:int = errorObjectArray.indexOf(event.target); 12534 // If we are valid, then clear the error string 12535 if (event.type == ValidationResultEvent.VALID) 12536 { 12537 if (validatorIndex != -1) 12538 { 12539 errorObjectArray.splice(validatorIndex, 1); 12540 errorArray.splice(validatorIndex, 1); 12541 errorString = errorArray.join("\n"); 12542 if (errorArray.length == 0) 12543 dispatchEvent(new FlexEvent(FlexEvent.VALID)); 12544 } 12545 } 12546 else // If we get an invalid event 12547 { 12548 var msg:String; 12549 var result:ValidationResult; 12550 12551 // We are associated with a subfield 12552 if (validationSubField != null && validationSubField != "" && event.results) 12553 { 12554 for (var i:int = 0; i < event.results.length; i++) 12555 { 12556 result = event.results[i]; 12557 // Find the result that is meant for us 12558 if (result.subField == validationSubField) 12559 { 12560 if (result.isError) 12561 { 12562 msg = result.errorMessage; 12563 } 12564 else 12565 { 12566 if (validatorIndex != -1) 12567 { 12568 errorObjectArray.splice(validatorIndex, 1); 12569 errorArray.splice(validatorIndex, 1); 12570 errorString = errorArray.join("\n"); 12571 if (errorArray.length == 0) 12572 dispatchEvent(new FlexEvent(FlexEvent.VALID)); 12573 } 12574 } 12575 break; 12576 } 12577 } 12578 } 12579 else if (event.results && event.results.length > 0) 12580 { 12581 msg = event.results[0].errorMessage; 12582 } 12583 12584 if (msg && validatorIndex != -1) 12585 { 12586 // Handle the case where this target already had this invalid 12587 // event and the errorString has been cleared. 12588 errorArray[validatorIndex] = msg; 12589 errorString = errorArray.join("\n"); 12590 dispatchEvent(new FlexEvent(FlexEvent.INVALID)); 12591 } 12592 else if (msg && validatorIndex == -1) 12593 { 12594 errorObjectArray.push(event.target); 12595 errorArray.push(msg); 12596 errorString = errorArray.join("\n"); 12597 dispatchEvent(new FlexEvent(FlexEvent.INVALID)); 12598 } 12599 } 12600 } 12601 12602 //-------------------------------------------------------------------------- 12603 // 12604 // Event handlers: Resources 12605 // 12606 //-------------------------------------------------------------------------- 12607 12608 /** 12609 * @private 12610 */ 12611 private function resourceManager_changeHandler(event:Event):void 12612 { 12613 resourcesChanged(); 12614 } 12615 12616 //-------------------------------------------------------------------------- 12617 // 12618 // Event handlers: Filters 12619 // 12620 //-------------------------------------------------------------------------- 12621 12622 /** 12623 * @private 12624 */ 12625 private function filterChangeHandler(event:Event):void 12626 { 12627 filters = _filters; 12628 } 12629 12630 //-------------------------------------------------------------------------- 12631 // 12632 // IUIComponent 12633 // 12634 //-------------------------------------------------------------------------- 12635 12636 /** 12637 * Returns <code>true</code> if the chain of <code>owner</code> properties 12638 * points from <code>child</code> to this UIComponent. 12639 * 12640 * @param child A UIComponent. 12641 * 12642 * @return <code>true</code> if the child is parented or owned by this UIComponent. 12643 * 12644 * @langversion 3.0 12645 * @playerversion Flash 9 12646 * @playerversion AIR 1.1 12647 * @productversion Flex 3 12648 */ 12649 public function owns(child:DisplayObject):Boolean 12650 { 12651 var childList:IChildList = 12652 this is IRawChildrenContainer ? 12653 IRawChildrenContainer(this).rawChildren : 12654 IChildList(this); 12655 12656 if (childList.contains(child)) 12657 return true; 12658 12659 try 12660 { 12661 while (child && child != this) 12662 { 12663 // do a parent walk 12664 if (child is IUIComponent) 12665 child = IUIComponent(child).owner; 12666 else 12667 child = child.parent; 12668 } 12669 } 12670 catch (e:SecurityError) 12671 { 12672 // You can't own what you don't have access to. 12673 return false; 12674 } 12675 12676 return child == this; 12677 } 12678 12679 /** 12680 * @private 12681 * Finds a module factory that can create a TextField 12682 * that can display the given font. 12683 * This is important for embedded fonts, not for system fonts. 12684 * 12685 * @param fontName The name of the fontFamily. 12686 * 12687 * @param bold A flag which true if the font weight is bold, 12688 * and false otherwise. 12689 * 12690 * @param italic A flag which is true if the font style is italic, 12691 * and false otherwise. 12692 * 12693 * @return The IFlexModuleFactory that represents the context 12694 * where an object wanting to use the font should be created. 12695 */ 12696 mx_internal function getFontContext(fontName:String, bold:Boolean, 12697 italic:Boolean, embeddedCff:*=undefined):IFlexModuleFactory 12698 { 12699 if (noEmbeddedFonts) 12700 return null; 12701 12702 var registry:IEmbeddedFontRegistry = embeddedFontRegistry; 12703 12704 return registry ? registry.getAssociatedModuleFactory( 12705 fontName, bold, italic, this, moduleFactory, systemManager, 12706 embeddedCff) : null; 12707 } 12708 12709 /** 12710 * Creates a new object using a context 12711 * based on the embedded font being used. 12712 * 12713 * <p>This method is used to solve a problem 12714 * with access to fonts embedded in an application SWF 12715 * when the framework is loaded as an RSL 12716 * (the RSL has its own SWF context). 12717 * Embedded fonts can only be accessed from the SWF file context 12718 * in which they were created. 12719 * By using the context of the application SWF, 12720 * the RSL can create objects in the application SWF context 12721 * that has access to the application's embedded fonts.</p> 12722 * 12723 * <p>Call this method only after the font styles 12724 * for this object are set.</p> 12725 * 12726 * @param class The class to create. 12727 * 12728 * @return The instance of the class created in the context 12729 * of the SWF owning the embedded font. 12730 * If this object is not using an embedded font, 12731 * the class is created in the context of this object. 12732 * 12733 * @langversion 3.0 12734 * @playerversion Flash 9 12735 * @playerversion AIR 1.1 12736 * @productversion Flex 3 12737 */ 12738 protected function createInFontContext(classObj:Class):Object 12739 { 12740 hasFontContextBeenSaved = true; 12741 12742 var fontName:String = StringUtil.trimArrayElements(getStyle("fontFamily"), ","); 12743 var fontWeight:String = getStyle("fontWeight"); 12744 var fontStyle:String = getStyle("fontStyle"); 12745 var bold:Boolean = (fontWeight == "bold"); 12746 var italic:Boolean = (fontStyle == "italic"); 12747 12748 var className:String = getQualifiedClassName(classObj); 12749 12750 // If the caller requests a UITextField, 12751 // we may actually return a UITLFTextField, 12752 // depending on the version number 12753 // and the value of the textFieldClass style. 12754 if (className == "mx.core::UITextField") 12755 { 12756 className = getTextFieldClassName(); 12757 if (className == "mx.core::UIFTETextField") 12758 classObj = Class(ApplicationDomain.currentDomain. 12759 getDefinition(className)); 12760 } 12761 12762 // Save for hasFontContextChanged(). 12763 oldEmbeddedFontContext = getFontContext(fontName, bold, italic, 12764 className == "mx.core::UIFTETextField"); 12765 12766 var moduleContext:IFlexModuleFactory = oldEmbeddedFontContext ? 12767 oldEmbeddedFontContext : 12768 moduleFactory; 12769 12770 // Not in font registry, so create in this font context. 12771 var obj:Object = createInModuleContext(moduleContext, className); 12772 12773 if (obj == null) 12774 obj = new classObj(); 12775 12776 // If we just created a UITLFTextField, set its fontContext property 12777 // so that it knows what module to use for creating its TextLines. 12778 if (className == "mx.core::UIFTETextField") 12779 obj.fontContext = moduleContext; 12780 12781 return obj; 12782 } 12783 12784 /** 12785 * @private 12786 * Returns either "mx.core::UITextField" or "mx.core::UIFTETextField", 12787 * based on the version number and the textFieldClass style. 12788 */ 12789 private function getTextFieldClassName():String 12790 { 12791 var c:Class = getStyle("textFieldClass"); 12792 12793 if (!c || FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 12794 return "mx.core::UITextField"; 12795 12796 return getQualifiedClassName(c); 12797 } 12798 12799 /** 12800 * @private 12801 * Returns either "mx.core::TextInput" or "mx.core::MXFTETextInput", 12802 * based on the version number and the textInputClass style. 12803 */ 12804 private function getTextInputClassName():String 12805 { 12806 var c:Class = getStyle("textInputClass"); 12807 12808 if (!c || FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) 12809 return "mx.core::TextInput"; 12810 12811 return getQualifiedClassName(c); 12812 } 12813 12814 /** 12815 * Creates the object using a given moduleFactory. 12816 * If the moduleFactory is null or the object 12817 * cannot be created using the module factory, 12818 * then fall back to creating the object using a systemManager. 12819 * 12820 * @param moduleFactory The moduleFactory to create the class in; 12821 * can be null. 12822 * 12823 * @param className The name of the class to create. 12824 * 12825 * @return The object created in the context of the moduleFactory. 12826 * 12827 * @langversion 3.0 12828 * @playerversion Flash 9 12829 * @playerversion AIR 1.1 12830 * @productversion Flex 3 12831 */ 12832 protected function createInModuleContext(moduleFactory:IFlexModuleFactory, 12833 className:String):Object 12834 { 12835 var newObject:Object = null; 12836 12837 if (moduleFactory) 12838 newObject = moduleFactory.create(className); 12839 12840 return newObject; 12841 } 12842 12843 /** 12844 * @private 12845 * 12846 * Tests if the current font context has changed 12847 * since that last time createInFontContext() was called. 12848 */ 12849 public function hasFontContextChanged():Boolean 12850 { 12851 12852 // If the font has not been set yet, then return false; 12853 // the font has not changed. 12854 if (!hasFontContextBeenSaved) 12855 return false; 12856 12857 // Check if the module factory has changed. 12858 var fontName:String = 12859 StringUtil.trimArrayElements(getStyle("fontFamily"), ","); 12860 var fontWeight:String = getStyle("fontWeight"); 12861 var fontStyle:String = getStyle("fontStyle"); 12862 var bold:Boolean = fontWeight == "bold"; 12863 var italic:Boolean = fontStyle == "italic"; 12864 var fontContext:IFlexModuleFactory = noEmbeddedFonts ? null : 12865 embeddedFontRegistry.getAssociatedModuleFactory( 12866 fontName, bold, italic, this, moduleFactory, 12867 systemManager); 12868 return fontContext != oldEmbeddedFontContext; 12869 } 12870 12871 /** 12872 * @inheritDoc 12873 * 12874 * @langversion 3.0 12875 * @playerversion Flash 9 12876 * @playerversion AIR 1.1 12877 * @productversion Flex 3 12878 */ 12879 public function createAutomationIDPart(child:IAutomationObject):Object 12880 { 12881 if (automationDelegate) 12882 return automationDelegate.createAutomationIDPart(child); 12883 return null; 12884 } 12885 12886 /** 12887 * @inheritDoc 12888 * 12889 * @langversion 3.0 12890 * @playerversion Flash 10 12891 * @playerversion AIR 1.5 12892 * @productversion Flex 4 12893 */ 12894 public function createAutomationIDPartWithRequiredProperties(child:IAutomationObject, 12895 properties:Array):Object 12896 { 12897 if (automationDelegate) 12898 return automationDelegate.createAutomationIDPartWithRequiredProperties(child, properties); 12899 return null; 12900 } 12901 12902 /** 12903 * @inheritDoc 12904 * 12905 * @langversion 3.0 12906 * @playerversion Flash 9 12907 * @playerversion AIR 1.1 12908 * @productversion Flex 3 12909 */ 12910 public function resolveAutomationIDPart(criteria:Object):Array 12911 { 12912 if (automationDelegate) 12913 return automationDelegate.resolveAutomationIDPart(criteria); 12914 return []; 12915 } 12916 12917 /** 12918 * @inheritDoc 12919 * 12920 * @langversion 3.0 12921 * @playerversion Flash 9 12922 * @playerversion AIR 1.1 12923 * @productversion Flex 3 12924 */ 12925 public function getAutomationChildAt(index:int):IAutomationObject 12926 { 12927 if (automationDelegate) 12928 return automationDelegate.getAutomationChildAt(index); 12929 return null; 12930 } 12931 12932 /** 12933 * @inheritDoc 12934 * 12935 * @langversion 3.0 12936 * @playerversion Flash 10 12937 * @playerversion AIR 1.5 12938 * @productversion Flex 4 12939 */ 12940 public function getAutomationChildren():Array 12941 { 12942 if (automationDelegate) 12943 return automationDelegate.getAutomationChildren(); 12944 return null; 12945 } 12946 12947 /** 12948 * @inheritDoc 12949 * 12950 * @langversion 3.0 12951 * @playerversion Flash 9 12952 * @playerversion AIR 1.1 12953 * @productversion Flex 3 12954 */ 12955 public function get numAutomationChildren():int 12956 { 12957 if (automationDelegate) 12958 return automationDelegate.numAutomationChildren; 12959 return 0; 12960 } 12961 12962 /** 12963 * @inheritDoc 12964 * 12965 * @langversion 3.0 12966 * @playerversion Flash 9 12967 * @playerversion AIR 1.1 12968 * @productversion Flex 3 12969 */ 12970 public function get automationTabularData():Object 12971 { 12972 if (automationDelegate) 12973 return automationDelegate.automationTabularData; 12974 return null; 12975 } 12976 12977 //---------------------------------- 12978 // automationOwner 12979 //---------------------------------- 12980 12981 /** 12982 * @inheritDoc 12983 * 12984 * @langversion 3.0 12985 * @playerversion Flash 9 12986 * @playerversion AIR 1.1 12987 * @productversion Flex 4 12988 */ 12989 public function get automationOwner():DisplayObjectContainer 12990 { 12991 return owner; 12992 } 12993 12994 //---------------------------------- 12995 // automationParent 12996 //---------------------------------- 12997 12998 /** 12999 * @inheritDoc 13000 * 13001 * @langversion 3.0 13002 * @playerversion Flash 9 13003 * @playerversion AIR 1.1 13004 * @productversion Flex 4 13005 */ 13006 public function get automationParent():DisplayObjectContainer 13007 { 13008 return parent; 13009 } 13010 13011 //---------------------------------- 13012 // automationEnabled 13013 //---------------------------------- 13014 13015 /** 13016 * @inheritDoc 13017 * 13018 * @langversion 3.0 13019 * @playerversion Flash 9 13020 * @playerversion AIR 1.1 13021 * @productversion Flex 4 13022 */ 13023 public function get automationEnabled():Boolean 13024 { 13025 return enabled; 13026 } 13027 13028 //---------------------------------- 13029 // automationVisible 13030 //---------------------------------- 13031 13032 /** 13033 * @inheritDoc 13034 * 13035 * @langversion 3.0 13036 * @playerversion Flash 9 13037 * @playerversion AIR 1.1 13038 * @productversion Flex 4 13039 */ 13040 public function get automationVisible():Boolean 13041 { 13042 return visible; 13043 } 13044 13045 /** 13046 * @inheritDoc 13047 * 13048 * @langversion 3.0 13049 * @playerversion Flash 9 13050 * @playerversion AIR 1.1 13051 * @productversion Flex 3 13052 */ 13053 public function replayAutomatableEvent(event:Event):Boolean 13054 { 13055 if (automationDelegate) 13056 return automationDelegate.replayAutomatableEvent(event); 13057 return false; 13058 } 13059 13060 13061 /** 13062 * @private 13063 * 13064 * Get the bounds of this object that are visible to the user 13065 * on the screen. 13066 * 13067 * @param targetParent The parent to stop at when calculating the visible 13068 * bounds. If null, this object's system manager will be used as 13069 * the parent. 13070 * 13071 * @return a <code>Rectangle</code> including the visible portion of the this 13072 * object. The rectangle is in global coordinates. 13073 */ 13074 public function getVisibleRect(targetParent:DisplayObject = null):Rectangle 13075 { 13076 if (!targetParent) 13077 targetParent = DisplayObject(systemManager); 13078 13079 var thisParent:DisplayObject = $parent ? $parent : parent; 13080 13081 // If the object is not on the display list then it is not visible. 13082 if (!thisParent) 13083 return new Rectangle(); 13084 13085 var pt:Point = new Point(x, y); 13086 pt = thisParent.localToGlobal(pt); 13087 13088 // bounds of this object to return. Keep in global coordinates 13089 // until the end and set back to targetParent coordinates. 13090 var bounds:Rectangle = new Rectangle(pt.x, pt.y, width, height); 13091 var current:DisplayObject = this; 13092 var currentRect:Rectangle = new Rectangle(); 13093 13094 do 13095 { 13096 if (current is UIComponent) 13097 { 13098 if (UIComponent(current).$parent) 13099 current = UIComponent(current).$parent; 13100 else 13101 current = UIComponent(current).parent; 13102 } 13103 else 13104 current = current.parent; 13105 13106 if (current && current.scrollRect) 13107 { 13108 // clip the bounds by the scroll rect 13109 currentRect = current.scrollRect.clone(); 13110 pt = current.localToGlobal(currentRect.topLeft); 13111 currentRect.x = pt.x; 13112 currentRect.y = pt.y; 13113 bounds = bounds.intersection(currentRect); 13114 } 13115 } while (current && current != targetParent); 13116 13117 return bounds; 13118 } 13119 13120 //-------------------------------------------------------------------------- 13121 // 13122 // Diagnostics 13123 // 13124 //-------------------------------------------------------------------------- 13125 13126 mx_internal static var dispatchEventHook:Function; 13127 13128 /** 13129 * Dispatches an event into the event flow. 13130 * The event target is the EventDispatcher object upon which 13131 * the <code>dispatchEvent()</code> method is called. 13132 * 13133 * @param event The Event object that is dispatched into the event flow. 13134 * If the event is being redispatched, a clone of the event is created automatically. 13135 * After an event is dispatched, its <code>target</code> property cannot be changed, 13136 * so you must create a new copy of the event for redispatching to work. 13137 * 13138 * @return A value of <code>true</code> if the event was successfully dispatched. 13139 * A value of <code>false</code> indicates failure or that 13140 * the <code>preventDefault()</code> method was called on the event. 13141 * 13142 * @langversion 3.0 13143 * @playerversion Flash 9 13144 * @playerversion AIR 1.1 13145 * @productversion Flex 3 13146 */ 13147 override public function dispatchEvent(event:Event):Boolean 13148 { 13149 if (dispatchEventHook != null) 13150 dispatchEventHook(event, this); 13151 13152 return super.dispatchEvent(event); 13153 } 13154 13155 private static var fakeMouseX:QName = new QName(mx_internal, "_mouseX"); 13156 private static var fakeMouseY:QName = new QName(mx_internal, "_mouseY"); 13157 13158 /** 13159 * @private 13160 */ 13161 override public function get mouseX():Number 13162 { 13163 if (!root || root is Stage || root[fakeMouseX] === undefined) 13164 return super.mouseX; 13165 return globalToLocal(new Point(root[fakeMouseX], 0)).x; 13166 } 13167 13168 /** 13169 * @private 13170 */ 13171 override public function get mouseY():Number 13172 { 13173 if (!root || root is Stage || root[fakeMouseY] === undefined) 13174 return super.mouseY; 13175 return globalToLocal(new Point(0, root[fakeMouseY])).y; 13176 } 13177 13178 13179 /** 13180 * Initializes the implementation and storage of some of the less frequently 13181 * used advanced layout features of a component. 13182 * 13183 * Call this function before attempting to use any of the features implemented 13184 * by the AdvancedLayoutFeatures object. 13185 * 13186 * @langversion 3.0 13187 * @playerversion Flash 10 13188 * @playerversion AIR 1.5 13189 * @productversion Flex 4 13190 */ 13191 protected function initAdvancedLayoutFeatures():void 13192 { 13193 internal_initAdvancedLayoutFeatures(); 13194 } 13195 13196 13197 /** 13198 * @private 13199 */ 13200 mx_internal function transformRequiresValidations():Boolean 13201 { 13202 return (_layoutFeatures != null); 13203 } 13204 13205 /** 13206 * @private 13207 */ 13208 mx_internal function clearAdvancedLayoutFeatures():void 13209 { 13210 if (_layoutFeatures) 13211 { 13212 // Make sure the matrix is validated before we free the 13213 // layout features. 13214 validateMatrix(); 13215 _layoutFeatures = null; 13216 } 13217 } 13218 13219 /** 13220 * Passed to TransformUtil to create the layout features when performing 13221 * transformation operations. 13222 */ 13223 private function internal_initAdvancedLayoutFeatures():AdvancedLayoutFeatures 13224 { 13225 var features:AdvancedLayoutFeatures = new AdvancedLayoutFeatures(); 13226 13227 _hasComplexLayoutMatrix = true; 13228 13229 features.layoutScaleX = scaleX; 13230 features.layoutScaleY = scaleY; 13231 features.layoutScaleZ = scaleZ; 13232 features.layoutRotationX = rotationX; 13233 features.layoutRotationY = rotationY; 13234 features.layoutRotationZ = rotation; 13235 features.layoutX = x; 13236 features.layoutY = y; 13237 features.layoutZ = z; 13238 features.layoutWidth = width; // for the mirror transform 13239 _layoutFeatures = features; 13240 invalidateTransform(); 13241 return features; 13242 } 13243 13244 /** 13245 * @private 13246 * Helper function to update the storage vairable _transform. 13247 * Also updates the <code>target</code> property of the new and the old 13248 * values. 13249 */ 13250 private function setTransform(value:flash.geom.Transform):void 13251 { 13252 // Clean up the old transform 13253 var oldTransform:mx.geom.Transform = _transform as mx.geom.Transform; 13254 if (oldTransform) 13255 oldTransform.target = null; 13256 13257 var newTransform:mx.geom.Transform = value as mx.geom.Transform; 13258 13259 if (newTransform) 13260 newTransform.target = this; 13261 13262 _transform = value; 13263 } 13264 13265 /** 13266 * @private 13267 * Documentation is not currently available 13268 */ 13269 mx_internal function get $transform():flash.geom.Transform 13270 { 13271 return super.transform; 13272 } 13273 13274 /** 13275 * @private 13276 * 13277 * @langversion 3.0 13278 * @playerversion Flash 9 13279 * @playerversion AIR 1.1 13280 * @productversion Flex 3 13281 */ 13282 override public function get transform():flash.geom.Transform 13283 { 13284 if (_transform == null) 13285 { 13286 setTransform(new mx.geom.Transform(this)); 13287 } 13288 return _transform; 13289 } 13290 13291 /** 13292 * An object with properties pertaining to a display object's matrix, color transform, 13293 * and pixel bounds. The specific properties — matrix, colorTransform, and three read-only 13294 * properties (<code>concatenatedMatrix</code>, <code>concatenatedColorTransform</code>, and <code>pixelBounds</code>) — 13295 * are described in the entry for the <code>Transform</code> class. 13296 * 13297 * <p>Each of the transform object's properties is itself an object. This concept is 13298 * important because the only way to set new values for the matrix or colorTransform 13299 * objects is to create a new object and copy that object into the transform.matrix or 13300 * transform.colorTransform property.</p> 13301 * 13302 * <p>For example, to increase the tx value of a display object's matrix, you must make a copy 13303 * of the entire matrix object, then copy the new object into the matrix property of the 13304 * transform object:</p> 13305 * 13306 * <pre> 13307 * var myMatrix:Matrix = myUIComponentObject.transform.matrix; 13308 * myMatrix.tx += 10; 13309 * myUIComponent.transform.matrix = myMatrix; 13310 * </pre> 13311 * 13312 * You cannot directly set the tx property. The following code has no effect on myUIComponent: 13313 * 13314 * <pre> 13315 * myUIComponent.transform.matrix.tx += 10; 13316 * </pre> 13317 * 13318 * <p>Note that for <code>UIComponent</code>, unlike <code>DisplayObject</code>, the <code>transform</code> 13319 * keeps the <code>matrix</code> and <code>matrix3D</code> values in sync and <code>matrix3D</code> is not null 13320 * even when the component itself has no 3D properties set. Developers should use the <code>is3D</code> property 13321 * to check if the component has 3D propertis set. If the component has 3D properties, the transform's 13322 * <code>matrix3D</code> should be used instead of transform's <code>matrix</code>.</p> 13323 * 13324 * @see #setLayoutMatrix 13325 * @see #setLayoutMatrix3D 13326 * @see #getLayoutMatrix 13327 * @see #getLayoutMatrix3D 13328 * @see #is3D 13329 * @see mx.geom.Transform 13330 * 13331 * @langversion 3.0 13332 * @playerversion Flash 9 13333 * @playerversion AIR 1.1 13334 * @productversion Flex 3 13335 */ 13336 override public function set transform(value:flash.geom.Transform):void 13337 { 13338 var m:Matrix = value.matrix; 13339 var m3:Matrix3D = value.matrix3D; 13340 var ct:ColorTransform = value.colorTransform; 13341 var pp:PerspectiveProjection = value.perspectiveProjection; 13342 13343 // validateMatrix when switching between 2D/3D, works around player bug 13344 // see sdk-23421 13345 var was3D:Boolean = is3D; 13346 13347 var mxTransform:mx.geom.Transform = value as mx.geom.Transform; 13348 if (mxTransform) 13349 { 13350 if (!mxTransform.applyMatrix) 13351 m = null; 13352 13353 if (!mxTransform.applyMatrix3D) 13354 m3 = null; 13355 } 13356 13357 setTransform(value); 13358 13359 if (m != null) 13360 setLayoutMatrix(m.clone(), true /*triggerLayoutPass*/); 13361 else if (m3 != null) 13362 setLayoutMatrix3D(m3.clone(), true /*triggerLayoutPass*/); 13363 13364 super.transform.colorTransform = ct; 13365 super.transform.perspectiveProjection = pp; 13366 if (maintainProjectionCenter) 13367 invalidateDisplayList(); 13368 if (was3D != is3D) 13369 validateMatrix(); 13370 } 13371 13372 /** 13373 * @copy mx.core.IVisualElement#postLayoutTransformOffsets 13374 * 13375 * @langversion 3.0 13376 * @playerversion Flash 10 13377 * @playerversion AIR 1.5 13378 * @productversion Flex 4 13379 */ 13380 public function get postLayoutTransformOffsets():TransformOffsets 13381 { 13382 return (_layoutFeatures != null)? _layoutFeatures.postLayoutTransformOffsets:null; 13383 } 13384 13385 /** 13386 * @private 13387 */ 13388 public function set postLayoutTransformOffsets(value:TransformOffsets):void 13389 { 13390 // validateMatrix when switching between 2D/3D, works around player bug 13391 // see sdk-23421 13392 var was3D:Boolean = is3D; 13393 13394 if (_layoutFeatures == null) 13395 initAdvancedLayoutFeatures(); 13396 13397 if (_layoutFeatures.postLayoutTransformOffsets != null) 13398 _layoutFeatures.postLayoutTransformOffsets.removeEventListener(Event.CHANGE,transformOffsetsChangedHandler); 13399 _layoutFeatures.postLayoutTransformOffsets = value; 13400 if (_layoutFeatures.postLayoutTransformOffsets != null) 13401 _layoutFeatures.postLayoutTransformOffsets.addEventListener(Event.CHANGE,transformOffsetsChangedHandler); 13402 if (was3D != is3D) 13403 validateMatrix(); 13404 13405 invalidateTransform(); 13406 } 13407 13408 /** 13409 * @private 13410 */ 13411 private var _maintainProjectionCenter:Boolean = false; 13412 13413 /** 13414 * When true, the component keeps its projection matrix centered on the 13415 * middle of its bounding box. If no projection matrix is defined on the 13416 * component, one is added automatically. 13417 * 13418 * @langversion 3.0 13419 * @playerversion Flash 10 13420 * @playerversion AIR 1.5 13421 * @productversion Flex 4 13422 */ 13423 public function set maintainProjectionCenter(value:Boolean):void 13424 { 13425 _maintainProjectionCenter = value; 13426 if (value && super.transform.perspectiveProjection == null) 13427 { 13428 super.transform.perspectiveProjection = new PerspectiveProjection(); 13429 } 13430 invalidateDisplayList(); 13431 } 13432 /** 13433 * @private 13434 */ 13435 public function get maintainProjectionCenter():Boolean 13436 { 13437 return _maintainProjectionCenter; 13438 } 13439 13440 /** 13441 * @inheritDoc 13442 * 13443 * @langversion 3.0 13444 * @playerversion Flash 10 13445 * @playerversion AIR 1.5 13446 * @productversion Flex 4 13447 */ 13448 public function setLayoutMatrix(value:Matrix, invalidateLayout:Boolean):void 13449 { 13450 var previousMatrix:Matrix = _layoutFeatures ? 13451 _layoutFeatures.layoutMatrix : super.transform.matrix; 13452 13453 // validateMatrix when switching between 2D/3D, works around player bug 13454 // see sdk-23421 13455 var was3D:Boolean = is3D; 13456 _hasComplexLayoutMatrix = true; 13457 13458 if (_layoutFeatures == null) 13459 { 13460 // flash will make a copy of this on assignment. 13461 super.transform.matrix = value; 13462 } 13463 else 13464 { 13465 // layout features will internally make a copy of this matrix rather than 13466 // holding onto a reference to it. 13467 _layoutFeatures.layoutMatrix = value; 13468 invalidateTransform(); 13469 } 13470 13471 // Early exit if possible. We don't want to invalidate unnecessarily. 13472 // We need to do the check here, after our new value has been applied 13473 // because our matrix components are rounded upon being applied to a 13474 // DisplayObject. 13475 if (MatrixUtil.isEqual(previousMatrix, _layoutFeatures ? 13476 _layoutFeatures.layoutMatrix : super.transform.matrix)) 13477 { 13478 return; 13479 } 13480 13481 invalidateProperties(); 13482 13483 if (invalidateLayout) 13484 invalidateParentSizeAndDisplayList(); 13485 13486 if (was3D != is3D) 13487 validateMatrix(); 13488 } 13489 13490 /** 13491 * @inheritDoc 13492 * 13493 * @langversion 3.0 13494 * @playerversion Flash 10 13495 * @playerversion AIR 1.5 13496 * @productversion Flex 4 13497 */ 13498 public function setLayoutMatrix3D(value:Matrix3D, invalidateLayout:Boolean):void 13499 { 13500 // Early exit if possible. We don't want to invalidate unnecessarily. 13501 if (_layoutFeatures && MatrixUtil.isEqual3D(_layoutFeatures.layoutMatrix3D, value)) 13502 return; 13503 13504 // validateMatrix when switching between 2D/3D, works around player bug 13505 // see sdk-23421 13506 var was3D:Boolean = is3D; 13507 13508 if (_layoutFeatures == null) 13509 initAdvancedLayoutFeatures(); 13510 // layout features will internally make a copy of this matrix rather than 13511 // holding onto a reference to it. 13512 _layoutFeatures.layoutMatrix3D = value; 13513 invalidateTransform(); 13514 13515 invalidateProperties(); 13516 13517 if (invalidateLayout) 13518 invalidateParentSizeAndDisplayList(); 13519 13520 if (was3D != is3D) 13521 validateMatrix(); 13522 } 13523 13524 /** 13525 * @copy mx.core.ILayoutElement#transformAround() 13526 * 13527 * @langversion 3.0 13528 * @playerversion Flash 10 13529 * @playerversion AIR 1.5 13530 * @productversion Flex 4 13531 */ 13532 public function transformAround(transformCenter:Vector3D, 13533 scale:Vector3D = null, 13534 rotation:Vector3D = null, 13535 translation:Vector3D = null, 13536 postLayoutScale:Vector3D = null, 13537 postLayoutRotation:Vector3D = null, 13538 postLayoutTranslation:Vector3D = null, 13539 invalidateLayout:Boolean = true):void 13540 { 13541 // Make sure that no transform setters will trigger parent invalidation. 13542 // Reset the flag at the end of the method. 13543 var oldIncludeInLayout:Boolean; 13544 if (!invalidateLayout) 13545 { 13546 oldIncludeInLayout = _includeInLayout; 13547 _includeInLayout = false; 13548 } 13549 13550 var prevX:Number = x; 13551 var prevY:Number = y; 13552 var prevZ:Number = z; 13553 13554 TransformUtil.transformAround(this, 13555 transformCenter, 13556 scale, 13557 rotation, 13558 translation, 13559 postLayoutScale, 13560 postLayoutRotation, 13561 postLayoutTranslation, 13562 _layoutFeatures, 13563 internal_initAdvancedLayoutFeatures); 13564 13565 if (_layoutFeatures != null) 13566 { 13567 invalidateTransform(); 13568 13569 // Will not invalidate parent if we have set _includeInLayout to false 13570 // in the beginning of the method 13571 invalidateParentSizeAndDisplayList(); 13572 13573 if (prevX != _layoutFeatures.layoutX) 13574 dispatchEvent(new Event("xChanged")); 13575 if (prevY != _layoutFeatures.layoutY) 13576 dispatchEvent(new Event("yChanged")); 13577 if (prevZ != _layoutFeatures.layoutZ) 13578 dispatchEvent(new Event("zChanged")); 13579 } 13580 13581 if (!invalidateLayout) 13582 _includeInLayout = oldIncludeInLayout; 13583 } 13584 13585 /** 13586 * A utility method to transform a point specified in the local 13587 * coordinates of this object to its location in the object's parent's 13588 * coordinates. The pre-layout and post-layout result is set on 13589 * the <code>position</code> and <code>postLayoutPosition</code> 13590 * parameters, if they are non-null. 13591 * 13592 * @param localPosition The point to be transformed, specified in the 13593 * local coordinates of the object. 13594 * 13595 * @param position A Vector3D point that holds the pre-layout 13596 * result. If null, the parameter is ignored. 13597 * 13598 * @param postLayoutPosition A Vector3D point that holds the post-layout 13599 * result. If null, the parameter is ignored. 13600 * 13601 * @langversion 3.0 13602 * @playerversion Flash 10 13603 * @playerversion AIR 1.5 13604 * @productversion Flex 4 13605 */ 13606 public function transformPointToParent(localPosition:Vector3D, 13607 position:Vector3D, 13608 postLayoutPosition:Vector3D):void 13609 { 13610 TransformUtil.transformPointToParent(this, 13611 localPosition, 13612 position, 13613 postLayoutPosition, 13614 _layoutFeatures); 13615 } 13616 13617 /** 13618 * The transform matrix that is used to calculate a component's layout 13619 * relative to its siblings. This matrix is defined by the component's 13620 * 3D properties (which include the 2D properties such as <code>x</code>, 13621 * <code>y</code>, <code>rotation</code>, <code>scaleX</code>, 13622 * <code>scaleY</code>, <code>transformX</code>, and 13623 * <code>transformY</code>, as well as <code>rotationX</code>, 13624 * <code>rotationY</code>, <code>scaleZ</code>, <code>z</code>, and 13625 * <code>transformZ</code>. 13626 * 13627 * <p>Most components do not have any 3D transform properties set on them.</p> 13628 * 13629 * <p>This layout matrix is combined with the values of the 13630 * <code>postLayoutTransformOffsets</code> property to determine the 13631 * component's final, computed matrix.</p> 13632 * 13633 * @see #postLayoutTransformOffsets 13634 * 13635 * @langversion 3.0 13636 * @playerversion Flash 10 13637 * @playerversion AIR 1.5 13638 * @productversion Flex 4 13639 */ 13640 public function set layoutMatrix3D(value:Matrix3D):void 13641 { 13642 setLayoutMatrix3D(value, true /*invalidateLayout*/); 13643 } 13644 13645 //---------------------------------- 13646 // depth 13647 //---------------------------------- 13648 13649 /** 13650 * @inheritDoc 13651 * 13652 * @langversion 3.0 13653 * @playerversion Flash 10 13654 * @playerversion AIR 1.5 13655 * @productversion Flex 4 13656 */ 13657 public function get depth():Number 13658 { 13659 return (_layoutFeatures == null) ? 0 : _layoutFeatures.depth; 13660 } 13661 13662 /** 13663 * @private 13664 */ 13665 public function set depth(value:Number):void 13666 { 13667 if (value == depth) 13668 return; 13669 if (_layoutFeatures == null) 13670 initAdvancedLayoutFeatures(); 13671 13672 _layoutFeatures.depth = value; 13673 if (parent is UIComponent) 13674 UIComponent(parent).invalidateLayering(); 13675 } 13676 13677 /** 13678 * Called by a component's items to indicate that their <code>depth</code> 13679 * property has changed. Note that while this function is defined on 13680 * <code>UIComponent</code>, it is up to subclasses to implement support 13681 * for complex layering. 13682 * 13683 * By default, only <code>Group</code> and <code>DataGroup</code> support 13684 * arbitrary layering of their children. 13685 * 13686 * @see #depth 13687 * 13688 * @langversion 3.0 13689 * @playerversion Flash 10 13690 * @playerversion AIR 1.4 13691 * @productversion Flex 4 13692 */ 13693 public function invalidateLayering():void 13694 { 13695 } 13696 13697 /** 13698 * Commits the computed matrix built from the combination of the layout 13699 * matrix and the transform offsets to the flash displayObject's transform. 13700 * 13701 * @langversion 3.0 13702 * @playerversion Flash 10 13703 * @playerversion AIR 1.5 13704 * @productversion Flex 4 13705 */ 13706 protected function applyComputedMatrix():void 13707 { 13708 _layoutFeatures.updatePending = false; 13709 if (_layoutFeatures.is3D) 13710 { 13711 super.transform.matrix3D = _layoutFeatures.computedMatrix3D; 13712 } 13713 else 13714 { 13715 super.transform.matrix = _layoutFeatures.computedMatrix; 13716 } 13717 } 13718 13719 mx_internal function get computedMatrix():Matrix 13720 { 13721 return (_layoutFeatures) ? _layoutFeatures.computedMatrix : transform.matrix; 13722 } 13723 13724 /** 13725 * Specifies a transform stretch factor in the horizontal and vertical direction. 13726 * The stretch factor is applied to the computed matrix before any other transformation. 13727 * @param stretchX The horizontal component of the stretch factor. 13728 * @param stretchY The vertical component of the stretch factor. 13729 * 13730 * @langversion 3.0 13731 * @playerversion Flash 10 13732 * @playerversion AIR 1.5 13733 * @productversion Flex 4 13734 */ 13735 protected function setStretchXY(stretchX:Number, stretchY:Number):void 13736 { 13737 if (_layoutFeatures == null) 13738 initAdvancedLayoutFeatures(); 13739 if (stretchX != _layoutFeatures.stretchX || 13740 stretchY != _layoutFeatures.stretchY) 13741 { 13742 _layoutFeatures.stretchX = stretchX; 13743 _layoutFeatures.stretchY = stretchY; 13744 invalidateTransform(); 13745 } 13746 } 13747 13748 //-------------------------------------------------------------------------- 13749 // 13750 // Methods 13751 // 13752 //-------------------------------------------------------------------------- 13753 13754 13755 //-------------------------------------------------------------------------- 13756 // 13757 // ILayoutElement 13758 // 13759 //-------------------------------------------------------------------------- 13760 13761 /** 13762 * @inheritDoc 13763 * 13764 * @langversion 3.0 13765 * @playerversion Flash 10 13766 * @playerversion AIR 1.5 13767 * @productversion Flex 4 13768 */ 13769 public function getPreferredBoundsWidth(postLayoutTransform:Boolean=true):Number 13770 { 13771 return LayoutElementUIComponentUtils.getPreferredBoundsWidth(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13772 } 13773 13774 /** 13775 * @inheritDoc 13776 * 13777 * @langversion 3.0 13778 * @playerversion Flash 10 13779 * @playerversion AIR 1.5 13780 * @productversion Flex 4 13781 */ 13782 public function getPreferredBoundsHeight(postLayoutTransform:Boolean=true):Number 13783 { 13784 return LayoutElementUIComponentUtils.getPreferredBoundsHeight(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13785 } 13786 13787 /** 13788 * @inheritDoc 13789 * 13790 * @langversion 3.0 13791 * @playerversion Flash 10 13792 * @playerversion AIR 1.5 13793 * @productversion Flex 4 13794 */ 13795 public function getMinBoundsWidth(postLayoutTransform:Boolean=true):Number 13796 { 13797 return LayoutElementUIComponentUtils.getMinBoundsWidth(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13798 } 13799 13800 /** 13801 * @inheritDoc 13802 * 13803 * @langversion 3.0 13804 * @playerversion Flash 10 13805 * @playerversion AIR 1.5 13806 * @productversion Flex 4 13807 */ 13808 public function getMinBoundsHeight(postLayoutTransform:Boolean=true):Number 13809 { 13810 return LayoutElementUIComponentUtils.getMinBoundsHeight(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13811 } 13812 13813 /** 13814 * @inheritDoc 13815 * 13816 * @langversion 3.0 13817 * @playerversion Flash 10 13818 * @playerversion AIR 1.5 13819 * @productversion Flex 4 13820 */ 13821 public function getMaxBoundsWidth(postLayoutTransform:Boolean=true):Number 13822 { 13823 return LayoutElementUIComponentUtils.getMaxBoundsWidth(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13824 } 13825 13826 /** 13827 * @inheritDoc 13828 * 13829 * @langversion 3.0 13830 * @playerversion Flash 10 13831 * @playerversion AIR 1.5 13832 * @productversion Flex 4 13833 */ 13834 public function getMaxBoundsHeight(postLayoutTransform:Boolean=true):Number 13835 { 13836 return LayoutElementUIComponentUtils.getMaxBoundsHeight(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13837 } 13838 13839 /** 13840 * @inheritDoc 13841 * 13842 * @langversion 3.0 13843 * @playerversion Flash 10 13844 * @playerversion AIR 1.5 13845 * @productversion Flex 4 13846 */ 13847 public function getBoundsXAtSize(width:Number, height:Number, postLayoutTransform:Boolean = true):Number 13848 { 13849 return LayoutElementUIComponentUtils.getBoundsXAtSize(this, width, height, 13850 postLayoutTransform ? nonDeltaLayoutMatrix() : null); 13851 } 13852 13853 /** 13854 * @inheritDoc 13855 * 13856 * @langversion 3.0 13857 * @playerversion Flash 10 13858 * @playerversion AIR 1.5 13859 * @productversion Flex 4 13860 */ 13861 public function getBoundsYAtSize(width:Number, height:Number, postLayoutTransform:Boolean = true):Number 13862 { 13863 return LayoutElementUIComponentUtils.getBoundsYAtSize(this, width, height, 13864 postLayoutTransform ? nonDeltaLayoutMatrix() : null); 13865 } 13866 13867 /** 13868 * @inheritDoc 13869 * 13870 * @langversion 3.0 13871 * @playerversion Flash 10 13872 * @playerversion AIR 1.5 13873 * @productversion Flex 4 13874 */ 13875 public function getLayoutBoundsWidth(postLayoutTransform:Boolean=true):Number 13876 { 13877 return LayoutElementUIComponentUtils.getLayoutBoundsWidth(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13878 } 13879 13880 /** 13881 * @inheritDoc 13882 * 13883 * @langversion 3.0 13884 * @playerversion Flash 10 13885 * @playerversion AIR 1.5 13886 * @productversion Flex 4 13887 */ 13888 public function getLayoutBoundsHeight(postLayoutTransform:Boolean=true):Number 13889 { 13890 return LayoutElementUIComponentUtils.getLayoutBoundsHeight(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13891 } 13892 13893 /** 13894 * @inheritDoc 13895 * 13896 * @langversion 3.0 13897 * @playerversion Flash 10 13898 * @playerversion AIR 1.5 13899 * @productversion Flex 4 13900 */ 13901 public function getLayoutBoundsX(postLayoutTransform:Boolean=true):Number 13902 { 13903 return LayoutElementUIComponentUtils.getLayoutBoundsX(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13904 } 13905 13906 /** 13907 * @inheritDoc 13908 * 13909 * @langversion 3.0 13910 * @playerversion Flash 10 13911 * @playerversion AIR 1.5 13912 * @productversion Flex 4 13913 */ 13914 public function getLayoutBoundsY(postLayoutTransform:Boolean=true):Number 13915 { 13916 return LayoutElementUIComponentUtils.getLayoutBoundsY(this,postLayoutTransform? nonDeltaLayoutMatrix():null); 13917 } 13918 13919 /** 13920 * @inheritDoc 13921 * 13922 * @langversion 3.0 13923 * @playerversion Flash 10 13924 * @playerversion AIR 1.5 13925 * @productversion Flex 4 13926 */ 13927 public function setLayoutBoundsPosition(x:Number, y:Number, postLayoutTransform:Boolean=true):void 13928 { 13929 LayoutElementUIComponentUtils.setLayoutBoundsPosition(this,x,y,postLayoutTransform? nonDeltaLayoutMatrix():null); 13930 } 13931 13932 /** 13933 * @inheritDoc 13934 * 13935 * @langversion 3.0 13936 * @playerversion Flash 10 13937 * @playerversion AIR 1.5 13938 * @productversion Flex 4 13939 */ 13940 public function setLayoutBoundsSize(width:Number, 13941 height:Number, 13942 postLayoutTransform:Boolean = true):void 13943 { 13944 LayoutElementUIComponentUtils.setLayoutBoundsSize(this,width,height,postLayoutTransform? nonDeltaLayoutMatrix():null); 13945 } 13946 13947 /** 13948 * @inheritDoc 13949 * 13950 * @langversion 3.0 13951 * @playerversion Flash 10 13952 * @playerversion AIR 1.5 13953 * @productversion Flex 4 13954 */ 13955 public function getLayoutMatrix():Matrix 13956 { 13957 if (_layoutFeatures != null || super.transform.matrix == null) 13958 { 13959 // TODO: this is a workaround for a situation in which the 13960 // object is in 2D, but used to be in 3D and the player has not 13961 // yet cleaned up the matrices. So the matrix property is null, but 13962 // the matrix3D property is non-null. layoutFeatures can deal with 13963 // that situation, so we allocate it here and let it handle it for 13964 // us. The downside is that we have now allocated layoutFeatures 13965 // forever and will continue to use it for future situations that 13966 // might not have required it. Eventually, we should recognize 13967 // situations when we can de-allocate layoutFeatures and back off 13968 // to letting the player handle transforms for us. 13969 if (_layoutFeatures == null) 13970 initAdvancedLayoutFeatures(); 13971 13972 // esg: _layoutFeatures keeps a single internal copy of the layoutMatrix. 13973 // since this is an internal class, we don't need to worry about developers 13974 // accidentally messing with this matrix, _unless_ we hand it out. Instead, 13975 // we hand out a clone. 13976 return _layoutFeatures.layoutMatrix.clone(); 13977 } 13978 else 13979 { 13980 // flash also returns copies. 13981 return super.transform.matrix; 13982 } 13983 } 13984 13985 /** 13986 * @inheritDoc 13987 * 13988 * @langversion 3.0 13989 * @playerversion Flash 10 13990 * @playerversion AIR 1.5 13991 * @productversion Flex 4 13992 */ 13993 public function get hasLayoutMatrix3D():Boolean 13994 { 13995 return _layoutFeatures ? _layoutFeatures.layoutIs3D : false; 13996 } 13997 13998 /** 13999 * @inheritDoc 14000 * 14001 * @langversion 3.0 14002 * @playerversion Flash 10 14003 * @playerversion AIR 1.5 14004 * @productversion Flex 4 14005 */ 14006 public function get is3D():Boolean 14007 { 14008 return _layoutFeatures ? _layoutFeatures.is3D : false; 14009 } 14010 14011 /** 14012 * @inheritDoc 14013 * 14014 * @langversion 3.0 14015 * @playerversion Flash 10 14016 * @playerversion AIR 1.5 14017 * @productversion Flex 4 14018 */ 14019 public function getLayoutMatrix3D():Matrix3D 14020 { 14021 if (_layoutFeatures == null) 14022 initAdvancedLayoutFeatures(); 14023 // esg: _layoutFeatures keeps a single internal copy of the layoutMatrix. 14024 // since this is an internal class, we don't need to worry about developers 14025 // accidentally messing with this matrix, _unless_ we hand it out. Instead, 14026 // we hand out a clone. 14027 return _layoutFeatures.layoutMatrix3D.clone(); 14028 } 14029 14030 /** 14031 * @private 14032 */ 14033 protected function nonDeltaLayoutMatrix():Matrix 14034 { 14035 if (!hasComplexLayoutMatrix) 14036 return null; 14037 if (_layoutFeatures != null) 14038 { 14039 return _layoutFeatures.layoutMatrix; 14040 } 14041 else 14042 { 14043 return super.transform.matrix; 14044 } 14045 } 14046} 14047 14048} 14049 14050//////////////////////////////////////////////////////////////////////////////// 14051// 14052// Helper class: MethodQueueElement 14053// 14054//////////////////////////////////////////////////////////////////////////////// 14055 14056/** 14057 * @private 14058 * An element of the methodQueue array. 14059 */ 14060class MethodQueueElement 14061{ 14062 //-------------------------------------------------------------------------- 14063 // 14064 // Constructor 14065 // 14066 //-------------------------------------------------------------------------- 14067 14068 /** 14069 * Constructor. 14070 * 14071 * @langversion 3.0 14072 * @playerversion Flash 9 14073 * @playerversion AIR 1.1 14074 * @productversion Flex 3 14075 */ 14076 public function MethodQueueElement(method:Function, 14077 args:Array /* of Object */ = null) 14078 { 14079 super(); 14080 14081 this.method = method; 14082 this.args = args; 14083 } 14084 14085 //-------------------------------------------------------------------------- 14086 // 14087 // Properties 14088 // 14089 //-------------------------------------------------------------------------- 14090 14091 //---------------------------------- 14092 // method 14093 //---------------------------------- 14094 14095 /** 14096 * A reference to the method to be called. 14097 * 14098 * @langversion 3.0 14099 * @playerversion Flash 9 14100 * @playerversion AIR 1.1 14101 * @productversion Flex 3 14102 */ 14103 public var method:Function; 14104 14105 //---------------------------------- 14106 // args 14107 //---------------------------------- 14108 14109 /** 14110 * The arguments to be passed to the method. 14111 * 14112 * @langversion 3.0 14113 * @playerversion Flash 9 14114 * @playerversion AIR 1.1 14115 * @productversion Flex 3 14116 */ 14117 public var args:Array /* of Object */; 14118} 14119