我有一个具有以下状态的项目渲染器:
<s:states>
<s:State name="normal"/>
<s:State name="hovered"/>
<s:State name="selected"/>
</s:states>
我试图在悬停和选择时更改项目的背景颜色。我在 Item 渲染器开始标记中添加了以下几行:
contentBackgroundColor.hovered="0xff0018"
contentBackgroundColor.selected="0xffff11"
除了默认项目渲染器行为(灰色)之外,悬停或选择时不会发生任何事情。如果我说增加图像的宽度:
width.hovered="100"
图像按预期调整大小,我怎样才能达到我想要的效果?
编辑:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer 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:objects="objects.*"
creationComplete="itemrenderer1_creationCompleteHandler(event)"
width="100%" height="100%"
contentBackgroundColor.hover="0xff0018" focusColor="0xff00ff" contentBackgroundAlpha="0.8"
dataChange="refreshView()">
<s:states>
<s:State name="normal"/>
<s:State name="hovered"/>
<s:State name="selected"/>
</s:states>
<fx:Declarations>
<objects:EmbededImages id="embImages"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import events.MyEventDispatcher;
import mx.events.FlexEvent;
private function itemrenderer1_creationCompleteHandler(event:FlexEvent):void
{
//this.parentApplication.MyEventDispatcher.Dispatcher.addEventListener(CastUpdateEvent.UPDATED, refreshView);
refreshView();
}
public function refreshView():void
{
var profileImage:File = File.userDirectory.resolvePath("Movie Manager Settings\\profiles\\" + data.@id + ".jpg");
if(profileImage.exists)
{
personImage.source = profileImage.nativePath as String;
}
else
{
personImage.source = embImages.portrait;
}
}
]]>
</fx:Script>
<s:Image id="personImage" top="7" bottom="7" left="7" height="70" width="50"/>
<s:RichText left="70" height="100%" width="100" text="{data.@name}" textAlign="left" verticalAlign="middle" paddingRight="5"/>
<s:RichText right="10" height="100%" width="100" text="{data.@character}" textAlign="left" verticalAlign="middle"/>
</s:ItemRenderer>