Calculates the default size of the element. This is an advanced method that you might override when creating a subclass of GraphicElement. You do not call this method directly.
Flex calls the measure method when the element is added to an IGraphicElementContainer container such as Group using the addElement method, and when the element's invalidateSize method is called. By default you set both explicit height and explicit width of an element, Flex does not call the measure method, even if you explicitly call the invalidateSize method. To override this behavior, override skipMeasure method.
In your override of this method, you must set the measuredWidth and measuredHeight properties to define the default size. You can optionally set the measuredX and measuredY properties to define the default measured bounds top-left corner relative to the origin of the element.
The conceptual point of measure is for the element to provide its own natural or intrinsic bounds as a default. Therefore, the measuredWidth and measuredHeight properties should be determined by factors such as:. In some cases, there is no intrinsic way to determine default values. In other cases, such as a TextArea, an appropriate computation such as finding the right width and height that would just display all the text and have the aspect ratio of a Golden Rectangle might be too time-consuming to be worthwhile.
The default implementation of measure sets the values of the measuredWidth , measuredHeight , measuredX , and measuredY properties to 0. Package spark. View the examples See also mx. Hide Inherited Public Properties. Show Inherited Public Properties.
Specifies that this GraphicElement is to be associated with and be rendered to its own DisplayObject. The vertical distance in pixels from the anchor target to the control's baseline position. A value from the BlendMode class that specifies which blend mode to use. The vertical distance in pixels from the bottom edge of the component to the anchor target's bottom edge. Determines the order in which items inside of containers are rendered.
Specifies the optional DesignLayer instance associated with this visual element. Indicates the association between this IGraphicElement and its display objects. Number that specifies the explicit height of the component, in pixels, in the component's coordinates. The maximum recommended height of the component to be considered by the parent during layout. The maximum recommended width of the component to be considered by the parent during layout.
The minimum recommended height of the component to be considered by the parent during layout. The minimum recommended width of the component to be considered by the parent during layout. Number that specifies the explicit width of the component, in pixels, in the component's coordinates.
An indexed array that contains each filter object currently associated with the graphic element. The horizontal distance in pixels from the center of the component to the center of the anchor target's content area. Specifies whether this element is included in the layout of the parent.
Specifies the desired layout direction for an element: one of LayoutDirection. LTR left to right , LayoutDirection. RTL right to left , or null inherit. The horizontal distance in pixels from the left edge of the component to the anchor target's left edge. However, after using addChild to add these children to ObjectHolder , its width and height remain zero.
Is it possible for the UIComponent to automatically expand to the size of its containing children components? To change the component's size you should implement measure method. But you should also follow other recommendations on creating custom components. In your case you should create and add child component in createChildren method. The formal answer is no. A component is never responsible for setting it's own height and width values; it is only responsible for sizing and positioning it's children based on the values set by that component's parent.
If you implement a measure method in your component, you can use it to set the measuredWidth and measuredHeight of your component. This will, in essence, be a suggestion that you provide to your parent's container on what is the ideal size you need to position and size all your child elements properly.
Your own components should be sized and positioned in updateDisplayList based on the unscaledWidth and unscaledHeight values passed in. Most of the time the Flex default containers will honor these sizing values; although there are situations where they will not be.
For example, if the size the child container needs is more than the size of the parent. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 10 years, 2 months ago. Active 10 years, 2 months ago. We can position and size the children using move x,y and setActualSize width, height methods. We can set x and y positions separately, but it will dispatch dataChange event for both operations.
So it dispatches the event twice. We can ignore this by calling move x,y method so that it dispatches the event only once and the performance will be improved. Same way we do it for size to improve performance.
This method will be executed in a top down approach. First it executes for the parent, sets the size for its children, then it goes to its children and again their respective updateDisplayList is called. This method will be used to create children. As soon as we call addChild method on some display object, flex calls createChildren method in response to that call.
While implementing custom components it is suggested to override this method and to call its super method implementation.
This method is only used to add children to the present component. But positioning and sizing of children is not recommended to do in this method. We have updateDisplayList method to take care of this.
This is an advanced method that you might override when creating a subclass of UIComponent. The default implementation of measure sets measuredWidth, measuredHeight, measuredMinWidth, and measuredMinHeight to 0. In this method it calculates the measuredWidth and measuredHeight of a parent depending on its children size.
It is not recommended to calculate the size of the parent or its children in this method. This method will be executed in a bottom up approach. First it executes for its children, sets the measured size and then it executes for its parent.
0コメント