Implementing The Layoutchildren() Method; Implementing The Draw() Method - MACROMEDIA FLEX-CREATING ADVANCED COMPONENTS Manual

Creating advanced components
Table of Contents

Advertisement

Implementing the layoutChildren() method

The
layoutChildren()
UIObject.layoutWidth
component should implement this method. Use the
method, which is used primarily by Macromedia Flash designers to perform the same
size()
function.
Use the
UIObject.width
the size of the children. These properties are scaled for use inside the component. Use the
and
layoutWidth
These properties are 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")
{
mode_mc.move(layoutWidth - mode_mc.width, 0);
text_mc.move(0, 0);
}
else {
mode_mc.move(0, 0);
text_mc.move(mode_mc.width, 0);
}
}

Implementing the draw() method

The
method displays objects on the screen. Whenever the component needs to draw an
draw()
interface element, it calls a
elements that are subject to change.
Everything is made visible in the
until its
draw()
measuring are invisible until the
Do not call the
draw()
calls the
draw()
However, Flex calls the
call an invalidation method if you want Flex to invoke the
do not call an invalidation method, the component remains invisible unless you set its visibility
property to
true
Flex also calls the
12
Creating Advanced Components
method positions subobjects within the confines set by the
and
UIObject.layoutHeight
and
UIObject.height
properties when changing the size of the component itself.
layoutHeight
method does not update the screen unless you call an invalidation
layoutChildren()
method. You use the
draw()
draw()
method is called. Any graphical assets that you bring in for the purposes of
draw()
method directly. Instead, call one of the invalidation methods, which then
method. Flex also calls the
method only if the object is invalidated, so you should actually
redraw()
in MXML. For more information, see
method after the
draw()
properties of your component. Each
layoutChildren()
properties of the child controls when changing
method if the
invalidateLayout()
"About invalidation" on page
labelPlacement
draw()
method. A border does not actually call the drawing API
method is called.
method from the
draw()
draw()
"About invalidation" on page
layoutChildren()
method rather than the
method was
17.
property and lays out the
method to create or modify
method.
redraw()
or
method. If you
redraw()
method.
17.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents