简体   繁体   中英

Extending TextItem Class in Flex 4

I am trying to extend the TextItem class in Flex 4 but I keep getting the following error:

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

My txtIdNumber.as is as follows

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. Your namespace should be relative to "src".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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