User Guide
Table Of Contents
- Contents
- Working with Flash MX 2004
- Creating Basic Components in Flash MX 2004
- Creating Advanced Components in Flash MX 2004
- Contents
- About Creating components
- Writing the component’s ActionScript code
- Simple example of a class file
- General process for writing a class file
- Selecting a parent class
- Identifying the class, symbol, and owner names
- About the component instantiation life cycle
- Writing the constructor
- Specifying clip parameters
- Implementing the constructObject2() method
- Implementing the init() method
- Implementing the createChildren() method
- Implementing the commitProperties() method
- Implementing the measure() method
- Implementing the layoutChildren() method
- Implementing the draw() method
- Defining getters and setters
- Component metadata
- Defining component parameters
- Handling events
- Using the Event metadata
- About invalidation
- Skinning custom controls
- Adding styles
- Making components accessible
- Improving component usability
- Best practices when designing a component
- Using the ModalText example
- Troubleshooting
- Index

78 Chapter 3: Creating Advanced Components in Flash MX 2004
static function bar():Number
{
return mx.example.A.foo();
}
static var z = B.bar();
// Dependency
static var ADependency = mx.example.A;
}
The component is instantiated properly but does not show up (#2)
Verify that the _measuredPreferredWidth and _measuredPreferredHeight properties are
nonzero. If they are zero, ensure that you implemented the
measure() method correctly.
Sometimes you have to ensure that subobjects are created in order to get the correct
measurements.
You can also check the values of the
preferredWidth and preferredHeight properties. Other
code might have set those values to 0. If so, set a breakpoint in the setters for the
width, height,
preferredWidth, and preferredHeight properties to see what is setting them.
You can also verify that the
visible property and the _visible property are set to true. The
_visible property is an internal property used by Flash Player. If visible=true and
_visible=false, ensure that your component called the invalidate() method in its
measure() or layoutChildren() methods.
The system does not call the
invalidate() method unless you explicitly do so. All components
must call the
invalidate() method at least once, because their layout changes as they are given
their correct size during the layout process.
The component is instantiated properly but does not show up (#3)
It is possible that there is another class or SWC file that overrides your custom class or the
symbols used in your component. Check the ActionScript classes and SWC files in the
flex_app_root/WEB-INF/flex/user_classes directory to ensure that there are no naming conflicts.