MACROMEDIA FLEX-CREATING ADVANCED COMPONENTS Manual - page 17
Compiling components
17
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()
Indicates that one of the
_measured
properties have changed. This results in a
call to the
measure()
method. If the
measure()
method changes the value of one of the
_measured
properties, it calls the
layoutChildren()
method.
invalidateLayout()
Indicates that the position and/or size of one of the subobjects have
changed, but the
_measured
properties have not been affected. This results in a call to the
layoutChildren()
method. If you change a subobject in the
layoutChildren()
method, call
the
invalidate()
method.
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
draw()
method. You typically call this
method from your implementation of the
init()
method.
invalidateProperties()
Indicates that you have changed properties. This method calls the
commitProperties()
method.
You should call the
invalidateSize()
method infrequently, because it measures and redraws
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
createChildren()
or
layoutChildren()
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
child tag in the flex-config.xml file. SWC files must be stored at the
top level of the user_classes directory or the directory specified by the
element. You
cannot store SWC files in subdirectories.
For more information on using the compc utility, see Developing Flex Applications.