Flex:HSlider - 为不同的拇指设置不同的皮肤?
我将使用 HSlider 来设置一系列值。 我希望左手拇指看起来像 ( ,而右手拇指看起来像 ) 这样它们看起来就包含了像 (range) 这样的范围而不是|范围|。 我只知道如何设置 SliderThumb 的皮肤,这将为两者设置皮肤。 有谁知道如何为每个拇指设置不同的皮肤?
谢谢。
更新
我现在有这个代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:HSlider xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Style>
.thumbTickLeft
{
disabledSkin: Embed(source="skins.swf", symbol="thumbTickLeft_disabledSkin");
downSkin: Embed(source="skins.swf", symbol="thumbTickLeft_downSkin");
overSkin: Embed(source="skins.swf", symbol="thumbTickLeft_overSkin");
upSkin: Embed(source="skins.swf", symbol="thumbTickLeft_upSkin");
}
.thumbTickRight
{
disabledSkin: Embed(source="skins.swf", symbol="thumbTickRight_disabledSkin");
downSkin: Embed(source="skins.swf", symbol="thumbTickRight_downSkin");
overSkin: Embed(source="skins.swf", symbol="thumbTickRight_overSkin");
upSkin: Embed(source="skins.swf", symbol="thumbTickRight_upSkin");
}
</mx:Style>
<mx:Script>
<![CDATA[
override protected function commitProperties():void
{
super.commitProperties();
updateThumbSkins();
}
private function updateThumbSkins():void
{
this.getThumbAt(0).setStyle('styleName','thumbTickLeft');
this.getThumbAt(1).setStyle('styleName','thumbTickRight');
}
]]>
</mx:Script>
</mx:HSlider>
拇指刻度根本不显示? 顺便说一句,我已经确保皮肤正确加载,因为我可以将它们设置为如下按钮:
<mx:Button styleName="thumbTickRight"/>
I am going to use a HSlider to set a range of values. I would like the left thumb to look like ( and the right thumb to lok like ) so they appear to encompass the range like (range) instead of |range|. I only know how to set the skin for SliderThumb which will set the skin for both. Does anyone know of a way to set a different skin for each thumb?
Thanks.
UPDATE
I have this code now:
<?xml version="1.0" encoding="utf-8"?>
<mx:HSlider xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Style>
.thumbTickLeft
{
disabledSkin: Embed(source="skins.swf", symbol="thumbTickLeft_disabledSkin");
downSkin: Embed(source="skins.swf", symbol="thumbTickLeft_downSkin");
overSkin: Embed(source="skins.swf", symbol="thumbTickLeft_overSkin");
upSkin: Embed(source="skins.swf", symbol="thumbTickLeft_upSkin");
}
.thumbTickRight
{
disabledSkin: Embed(source="skins.swf", symbol="thumbTickRight_disabledSkin");
downSkin: Embed(source="skins.swf", symbol="thumbTickRight_downSkin");
overSkin: Embed(source="skins.swf", symbol="thumbTickRight_overSkin");
upSkin: Embed(source="skins.swf", symbol="thumbTickRight_upSkin");
}
</mx:Style>
<mx:Script>
<![CDATA[
override protected function commitProperties():void
{
super.commitProperties();
updateThumbSkins();
}
private function updateThumbSkins():void
{
this.getThumbAt(0).setStyle('styleName','thumbTickLeft');
this.getThumbAt(1).setStyle('styleName','thumbTickRight');
}
]]>
</mx:Script>
</mx:HSlider>
The thumb ticks just dont show at all? By the way I have made sure that the skins are loading in correctly because I can set them to a button like this:
<mx:Button styleName="thumbTickRight"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我能够让它以这种方式工作......不确定这是否是最好的方法。
Well I was able to get it to work this way..not sure if this is the best way or not.
你可能不会再读到这篇文章,但为了其他人的利益,他们和我试图操纵多个拇指以使其具有不同的皮肤一样痛苦,我想我会指出你在原始代码中出错的地方。 我按照您的原始代码示例进行操作,但也无法渲染拇指,然后我明白了为什么您的最终解决方案有效。
问题是,在原始代码中,您使用的是样式属性 upSkin、downSkin 等,而在有效的代码中,您使用的是thumbUpSkin、thumbDownSkin 等。细微的变化,但它带来了所有的不同!
希望这可以帮助某人挽救一天的生命......;-)
干杯
德鲁
you may not read this again, but for the benefit of others who are having as much pain as I am trying to manipulate multiple thumbs to each have different skins, I thought I'd point out where you went wrong in your original code. I followed your original code example and also could not get the thumbs to render, then it dawned on me why your final solution worked.
The problem is that in the original code you are using style properties upSkin, downSkin, etc, whereas in the code which works you are using thumbUpSkin, thumbDownSkin, etc. Subtle change but it makes all the difference!
Hope this helps someone save a day of their lives down the track... ;-)
Cheers
Drew
我认为您可以通过子类化 Slider 类(或 HSlider)并添加一种方法来将皮肤单独应用于每个拇指来实现此目的。
在 Slider.as 中有一个名为
createThumbs
的方法。 如果你查一下,你会发现当创建一个拇指时,它的皮肤是根据为thumbUpSkin
设置的内容分配给它的,等等。因此,你可以创建一个名为
skinThumbs
并让它覆盖createThumbs
中应用的皮肤设置。 您可以通过调用 getThumbAt(int) 来获取每个拇指。 如果您需要帮助覆盖皮肤设置,请给我留言。我将覆盖
commitProperties
方法并从那里调用skinThumbs
- 只需确保在调用super 之后调用
。 顺便说一句,skinThumbs
.commitPropertiescreateThumbs
方法仅从commitProperties
调用,并且仅从commitProperties
中的一个位置调用,因此您不必担心关于处理您的修改被另一个内部调用createThumbs
替换的情况。I think you could do this by subclassing the Slider class (or HSlider), and adding a method to apply skins to each thumb individually.
In Slider.as there is a method called
createThumbs
. If you look it up, you'll see that when a thumb is created, its skins are assigned to it based on whatever is set forthumbUpSkin
, etc.So, you could create a method called
skinThumbs
and have it override the skin settings that are applied increateThumbs
. You can get each thumb by callinggetThumbAt(int)
. If you need a hand with overriding the skin settings, leave me a comment.I would override the
commitProperties
method and callskinThumbs
from there - just make sure you put the call theskinThumbs
after the call tosuper.commitProperties
. Incidentally, thecreateThumbs
method is called only fromcommitProperties
, and is only called from one location incommitProperties
, so you don't have to worry about dealing with your modification being replaced by another internal call tocreateThumbs
.