开发者

I'm getting a instantiation error in Flex 4

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 = getS开发者_StackOverflowtyle("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 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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜