About Invalidation; Compiling Components - MACROMEDIA FLEX-CREATING ADVANCED COMPONENTS Manual

Creating advanced components
Table of Contents

Advertisement

About invalidation

Macromedia recommends that a component not update itself immediately in most cases, but
instead save a copy of the new property value, set a flag indicating what changed, and call one of
the invalidation methods.
The following are the invalidation methods:
invalidateSize()
call to the
measure()
properties, it calls the
_measured
invalidateLayout()
changed, but the
layoutChildren()
the
invalidate()
invalidate()
Indicates that just the visuals for the object have changed, but the size and position
of subobjects have not changed. This method calls the
method from your implementation of the
invalidateProperties()
commitProperties()
You should call the
everything on the screen, and this can be a computationally expensive action. Sometimes you
need to call more than one of these methods to force a layout, even though the computed sizes
did not change.
You must call an invalidation method at least once during the instantiation of your component.
The most common place for you to do this is in the
method.

Compiling components

When you finish writing the ActionScript classes and designing the embedded assets that
comprise your component, you compile it into a SWC file using the compc utility.
The following example compiles the MyComponent component into the MyComponent.swc
file:
compc –root .. –o MyComponent.swc MyComponent.as
After you generate a SWC file, you can use it in your Flex applications by copying it to the
flex_app_root/WEB-INF/flex/user_classes directory. You can also copy SWC files to a directory
specified by the
<lib-path>
top level of the user_classes directory or the directory specified by the
cannot store SWC files in subdirectories.
For more information on using the compc utility, see Developing Flex Applications.
Indicates that one of the
method. If the
measure()
layoutChildren()
Indicates that the position and/or size of one of the subobjects have
properties have not been affected. This results in a call to the
_measured
method. If you change a subobject in the
method.
Indicates that you have changed properties. This method calls the
method.
invalidateSize()
child tag in the flex-config.xml file. SWC files must be stored at the
properties have changed. This results in a
_measured
method changes the value of one of the
method.
draw()
method.
init()
method infrequently, because it measures and redraws
createChildren()
method, call
layoutChildren()
method. You typically call this
or
layoutChildren()
element. You
<lib-path>

Compiling components

17

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents