Troubleshooting
23
One possible remedy is to add a static variable dependency to the class definition. Flex knows that
all static variable dependencies must be ready before the class is initialized, so it orders the class
loading correctly.
The following example adds a static variable to tell the linker that class A must be initialized
before class B:
class mx.example.A {
static function foo():Number {
return 5;
}
}
class mx.example.B {
static function bar():Number {
return mx.example.A.foo();
}
static var z = B.bar();
// Dependency
static var ADependency:mx.example.A = 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 zero. 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.
Содержание FLEX-CREATING ADVANCED COMPONENTS
Страница 1: ...Creating Advanced Components...
Страница 4: ...4 Contents...
Страница 24: ...24 Creating Advanced Components...