By default, Flex sets the values of _
to the values of the current height and width, but you should override them. The following
example of the
measure()
the label text field is empty:
function measure(Void):Void {
var myTF = _getTextFormat();
var txt = text;
if (txt == undefined || txt.length < 2) {
txt = "Wj";
}
var textExt = myTF.getTextExtent2(txt);
var textW = textExt.width + 4;
var textH = textExt.height + 4;
if (textW == undefined) {
textW = 20;
}
if (textH == undefined) {
textH = 8;
}
trace("Label:
_measuredPreferredWidth = textW;
_measuredPreferredHeight = textH;
}
Implementing the layoutChildren() method
The
layoutChildren()
and
layoutWidth
implement this method. The
is used primarily by Flash designers to perform the same function.
Use the width and height properties of the child controls when changing the size of the children.
These properties are scaled for use inside the component. Use the
properties when changing the size of the component itself. These properties are
layoutHeight
not scaled because the component is at the top level.
The
layoutChildren()
method. Flex only calls the
previously called. For more information, see
The following example checks for the value of the
mode_mc object accordingly:
function layoutChildren():Void {
text_mc.setSize(layoutWidth - mode_mc.width, layoutHeight);
if (labelPlacement == "left")
measuredPreferredWidth
method from the Label component sets a default width and height if
" + textW + " " + textH);
method positions subobjects within the confines set by the
properties of your component. Each component should
layoutHeight
layoutChildren()
method does not update the screen unless you call an invalidation
layoutChildren()
and _
method deprecates the
layoutWidth
method if the
invalidateLayout()
"About invalidation" on page
labelPlacement
Writing the component's ActionScript code
measuredPreferredHeight
method, which
size()
and
method was
68.
property and lays out the
57
Need help?
Do you have a question about the FLEX - DEVELOPING COMPONENTS AND THEMES and is the answer not in the manual?