如何扩展不是容器的 Flex 组件(例如 RadioButton)?
我想扩展 Flex 3 中的 RadioButton 组件,向其添加文本输入行来代替标签。 是否有可能做到这一点?
或者,是否可以有一个容器(例如 HBox)将所有属性委托给内部组件(例如 RadioButton),以便我可以创建一个“类似于”单选按钮的复合组件?
I want to extend the RadioButton component in Flex 3, adding a text input line to it in place of the label. Is it possible to do this?
Alternately, is it possible to have a container -- such as an HBox -- delegate all properties to an internal component -- such as a RadioButton -- so that I could create a composite component that 'acts like' a radio button?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在 Actionscript 类中扩展 RadioButton 类(而不是 mxml 文件 - 有更好的方法吗?),您应该能够添加文本输入,即:
您可能会发现这个 - http://www.adobe.com/devnet/flex/quickstart/building_components_in_as/ 的帮助,特别是标题为创建复合动作脚本组件的部分。 如果这是您的第一个自定义组件,您可能还需要阅读 Flex 组件生命周期 (http://weblog.mrinalwadhwa.com/2009/02/17/understanding-the-flex-component-lifecycle/ - 虽然我永远找不到好的那个东西的链接)。 Flex 组件的生命周期有点复杂,您需要确保自己理解它,这样您的组件就不会不必要地不断地重绘事物。
您需要在创建子函数中添加 textInput,textField 本身是在 Button(RadioButton 的子类)的 createChildren() 方法中创建的。
If you extend the RadioButton class in an Actionscript class, (rather than an mxml file - is there a better way of saying that?), you should be able to add a text input, ie:
You might find this - http://www.adobe.com/devnet/flex/quickstart/building_components_in_as/ of help, particularly the section titled creating composite actionscript components. If this is your first custom component, you'll also probably want to read up on the Flex Component Lifecycle (http://weblog.mrinalwadhwa.com/2009/02/17/understanding-the-flex-component-lifecycle/ - although i can never find a good link for that stuff). The flex component lifecycle is a bit complex and you'll want to make sure you understand it so your component isn't needlessly redrawing things constantly.
You'll want to add the textInput in the create children function, the textField itself is created in Button's (which RadioButton subclasses) createChildren() method.