我有一個項目渲染以下狀態:的Flex 4項目渲染器的背景顏色 - 狀態不工作
<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"
的形象得到調整預期,我如何能實現我期待的效果?
編輯:
<?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\\" + [email protected] + ".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="{[email protected]}" textAlign="left" verticalAlign="middle" paddingRight="5"/>
<s:RichText right="10" height="100%" width="100" text="{[email protected]haracter}" textAlign="left" verticalAlign="middle"/>
</s:ItemRenderer>
contentBackgroundColor是一個樣式,寬度是一個屬性。我想知道這是否有所作爲?也就是說,你應該發佈完整的itemRenderer代碼。你到底在設置contentBackgroundColor的是什麼? – JeffryHouser
我添加了完整的項目渲染器代碼,這些樣式在組件中完美工作,所以看起來很奇怪,但它在項目渲染器中不起作用。 – DominicM