我在 Flex 4 中遇到实例化错误

发布于 2024-10-21 03:15:00 字数 1480 浏览 2 评论 0原文

我正在尝试调用自定义组件,但它一直告诉我:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尘世孤行 2024-10-28 03:15:00

我也有同样的问题。我必须为 WindowShade 的 headerClass 添加一个样式,该样式是对按钮的 ClassReference。尝试在您的项目中添加类似这样的样式:

@namespace flcont "http://code.google.com/p/flexlib/";
flcont|WindowShade {
    headerClass:ClassReference("mx.controls.Button");
}

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:

@namespace flcont "http://code.google.com/p/flexlib/";
flcont|WindowShade {
    headerClass:ClassReference("mx.controls.Button");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文