How about creating a simple custom canvas with both components (textinput and combo) with two states. You display the textinput in one state and the combo in the other state?
.comboBoxWithArrow {
up-skin: Embed(source="graphics.swf",symbol="comboArrowUp");
down-skin: Embed(source="graphics.swf",symbol="comboArrowDown");
over-skin: Embed(source="graphics.swf",symbol="comboArrowOver");
disabled-skin: Embed(source="graphics.swf",symbol="comboArrowDisabled");
/* and any other skin states you want to support */
}
.comboBoxWithoutArrow {
up-skin: Embed(source="graphics.swf",symbol="comboNoArrowUp");
down-skin: Embed(source="graphics.swf",symbol="comboNoArrowDown");
over-skin: Embed(source="graphics.swf",symbol="comboNoArrowOver");
disabled-skin: Embed(source="graphics.swf",symbol="comboNoArrowDisabled");
/* and any other skin states you want to support */
}
如果您的条件允许,请将 styleName 设置为显示箭头的名称,否则将其设置为不显示箭头的名称。
You could also provide a custom button skin for either case, which would be accessible by changing the styleName. This would potentially be lighter weight than user294702's solution.
For example, using dummy names for source and symbols:
.comboBoxWithArrow {
up-skin: Embed(source="graphics.swf",symbol="comboArrowUp");
down-skin: Embed(source="graphics.swf",symbol="comboArrowDown");
over-skin: Embed(source="graphics.swf",symbol="comboArrowOver");
disabled-skin: Embed(source="graphics.swf",symbol="comboArrowDisabled");
/* and any other skin states you want to support */
}
.comboBoxWithoutArrow {
up-skin: Embed(source="graphics.swf",symbol="comboNoArrowUp");
down-skin: Embed(source="graphics.swf",symbol="comboNoArrowDown");
over-skin: Embed(source="graphics.swf",symbol="comboNoArrowOver");
disabled-skin: Embed(source="graphics.swf",symbol="comboNoArrowDisabled");
/* and any other skin states you want to support */
}
If your conditions warrant it, set the styleName to the one that shows the arrow, otherwise set it to the one that shows no arrow.
发布评论
评论(3)
我找到了一个简单的方法来做到这一点:
setStyle("arrowButtonWidth", 0);
在我的自定义组合框中,我将箭头按钮的初始宽度设置为0。
然后在List更改事件中,
如果dataprovider的大小大于1,则将箭头宽度设置回(比如说)20
这种方法很多比上述方法更简单。如果您知道我的方法有任何陷阱,请分享。
I found out an easy way to do this:
setStyle("arrowButtonWidth", 0);
In my custom combobox, I set the initial width of the arrow button to 0.
Then in the List change event,
if the size of the dataprovider is greater than 1, the arrow width is set back to (say) 20
This approach is much simpler than the above approaches. If you know any pitfall of my approach, please share.
如何使用具有两种状态的两个组件(文本输入和组合)创建一个简单的自定义画布。
您在一种状态下显示文本输入,在另一种状态下显示组合?
How about creating a simple custom canvas with both components (textinput and combo) with two states.
You display the textinput in one state and the combo in the other state?
您还可以为这两种情况提供自定义按钮外观,可以通过更改 styleName 来访问该外观。这可能比 user294702 的解决方案更轻。
例如,对源和符号使用虚拟名称:
如果您的条件允许,请将 styleName 设置为显示箭头的名称,否则将其设置为不显示箭头的名称。
You could also provide a custom button skin for either case, which would be accessible by changing the styleName. This would potentially be lighter weight than user294702's solution.
For example, using dummy names for source and symbols:
If your conditions warrant it, set the styleName to the one that shows the arrow, otherwise set it to the one that shows no arrow.