我在 Flex 4 中遇到实例化错误
我正在尝试调用自定义组件,但它一直告诉我:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at flexlib.containers::WindowShade/createOrReplaceHeaderButton()[C:\Users\user\Adobe Flash Builder 4\flexlib\src\flexlib\containers\WindowShade.as:205]
at flexlib.containers::WindowShade/createChildren()[C:\Users\user\Adobe Flash Builder 4\flexlib\src\flexlib\containers\WindowShade.as:320]
这是我正在调用的组件,它不断给我错误:
<flcont:WindowShade>
<!-- this gives an error -->
</flcont:WindowShade>
以下是上面错误中的方法:
protected function createOrReplaceHeaderButton():void {
if(_headerButton) {
_headerButton.removeEventListener(MouseEvent.CLICK, headerButton_clickHandler);
if(rawChildren.contains(_headerButton)) {
rawChildren.removeChild(_headerButton);
}
}
if(_headerRenderer) {
_headerButton = _headerRenderer.newInstance() as Button;
}
else {
var headerClass:Class = getStyle("headerClass");
_headerButton = new headerClass();//error here
}
applyHeaderButtonStyles(_headerButton);
_headerButton.addEventListener(MouseEvent.CLICK, headerButton_clickHandler);
rawChildren.addChild(_headerButton);
}
override protected function createChildren():void {
super.createChildren();
createOrReplaceHeaderButton();
}
I am trying to call a custom component but it keeps telling me this:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at flexlib.containers::WindowShade/createOrReplaceHeaderButton()[C:\Users\user\Adobe Flash Builder 4\flexlib\src\flexlib\containers\WindowShade.as:205]
at flexlib.containers::WindowShade/createChildren()[C:\Users\user\Adobe Flash Builder 4\flexlib\src\flexlib\containers\WindowShade.as:320]
and here is the component i'm calling that keeps giving me the error:
<flcont:WindowShade>
<!-- this gives an error -->
</flcont:WindowShade>
And here are the methods from the error above:
protected function createOrReplaceHeaderButton():void {
if(_headerButton) {
_headerButton.removeEventListener(MouseEvent.CLICK, headerButton_clickHandler);
if(rawChildren.contains(_headerButton)) {
rawChildren.removeChild(_headerButton);
}
}
if(_headerRenderer) {
_headerButton = _headerRenderer.newInstance() as Button;
}
else {
var headerClass:Class = getStyle("headerClass");
_headerButton = new headerClass();//error here
}
applyHeaderButtonStyles(_headerButton);
_headerButton.addEventListener(MouseEvent.CLICK, headerButton_clickHandler);
rawChildren.addChild(_headerButton);
}
override protected function createChildren():void {
super.createChildren();
createOrReplaceHeaderButton();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题。我必须为 WindowShade 的 headerClass 添加一个样式,该样式是对按钮的 ClassReference。尝试在您的项目中添加类似这样的样式:
I had the same problem. I had to add a style for the WindowShade's headerClass that was a ClassReference to a Button. Try adding a style something like this to your project: