在 Flex 4 中扩展 TextItem 类
我正在尝试扩展 Flex 4 中的 TextItem 类,但不断收到以下错误:
无法解析
我的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;
}
}
}
,我想在其中使用它的模块看起来像这样
<?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>
最初我认为我可能以错误的方式扩展类,但我发现的所有例子看起来都是一样的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不知道源代码树结构的情况下,我的预感是编译器无法解析您为自定义设置的命名空间。尝试不使用“../”,如果仍然不起作用,请发布有关源树结构的更多详细信息,特别是您的自定义组件所在的位置以及模块代码相对于顶级“src”包的位置。您的命名空间应该相对于“src”。
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".