简体   繁体   English

在Flex 4中扩展TextItem类

[英]Extending TextItem Class in Flex 4

I am trying to extend the TextItem class in Flex 4 but I keep getting the following error: 我正在尝试在Flex 4中扩展TextItem类,但始终出现以下错误:

Could not resolve <custom:txtIdNumber> to a component implementation.

My txtIdNumber.as is as follows 我的txtIdNumber.as如下

package custom {

    import spark.components.TextInput;

    public class txtIdNumber extends TextInput {

        public function txtIdNumber()
        {
            super();
        }

        override protected function width():void
        {
            super.width();

            this.width = 100;
        }
    }
}

and the module I want to use it in looks like this 我想在其中使用的模块如下所示

<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx"
           xmlns:custom="../custom.*"
           layout="absolute" width="100%" height="100%">

    <s:BorderContainer width="100%" height="100%" >
        <custom:txtIdNumber />
    </s:BorderContainer>
</mx:Module>

Initially I thought that I might be extending the class in the wrong way, but all the examples I found look the same. 最初我以为我可能会以错误的方式扩展该类,但是我发现的所有示例看起来都一样。

Without knowing the structure of your source tree, my hunch is that the compiler is not able to parse the namespace you set for custom. 不知道源代码树的结构,我的直觉是编译器无法解析您为自定义设置的名称空间。 Try it without the "../" and if that still doesn't work, post more details about your source tree structure, specifically where does your custom component live and where does the module code live relative to the top level "src" package. 在没有“ ../”的情况下尝试使用它,如果仍然不起作用,请发布有关源树结构的更多详细信息,尤其是相对于顶级“ src”包而言,自定义组件位于何处以及模块代码位于何处。 Your namespace should be relative to "src". 您的名称空间应相对于“ src”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM