我有一个具有以下状态的元素渲染器:
<s:states>
<s:State name="normal"/>
<s:State name="hovered"/>
<s:State name="selected"/>
</s:states>
我试图在悬停和选中时更改元素的背景颜色。我将以下行添加到元素渲染器开始标记中:
contentBackgroundColor.hovered="0xff0018"
contentBackgroundColor.selected="0xffff11"
除了默认元素渲染器行为(灰色)外,悬停或选择时没有任何反应。如果我让说在以下范围内增加图像的宽度:
width.hovered="100"
图像按预期调整大小,我怎样才能达到我想要的效果?
编辑:
<效果:脚本>
<![CDATA[
导入事件.MyEventDispatcher;
导入 mx.events.FlexEvent;
私有(private)函数 itemrenderer1_creationCompleteHandler(事件:FlexEvent):void
{
//this.parentApplication.MyEventDispatcher.Dispatcher.addEventListener(CastUpdateEvent.UPDATED, refreshView);
刷新 View ();
}
公共(public)功能 refreshView():void
{
var profileImage:File = File.userDirectory.resolvePath("电影管理器设置\\配置文件\\"+ data.@id + ".jpg");
如果(profileImage.exists)
{
personImage.source = profileImage.nativePath as String;
}
别的
{
personImage.source = embImages.portrait;
}
}
]]>
最佳答案
将其放入 CSS 中:
s|ItemRenderer:hovered {
contentBackgroundColor: #ff0018;
}
关于css - Flex 4 元素渲染器背景颜色 - 状态不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8052856/