Without checking this before I write it, wouldn't something like this work?
private function changeStyle(event:Event):void{
var vbox:VBox = event.currentTarget as VBox;
vbox.setStyle('borderColor',0xfff000);
}
and then in the MXML tag you would have:
<mx:VBox verticalGap="2" width="100%"
styleName="results" mouseOver="changeStyle(event)">
That way you don't have to try to reference the item of a repeater by
id. Seems a little cleaner to me (although I haven't tested to make sure
it works).
Doug
Tracy Spratt wrote:
You need to refer to the individual repeater elements using the id array:
resultsBox[n].setStyle('borderColor',0xfff000);
Tracy
------------------------------------------------------------------------
*From:* [email protected] [mailto:[EMAIL PROTECTED]
*On Behalf Of *Joe
*Sent:* Friday, January 19, 2007 12:55 PM
*To:* [email protected]
*Subject:* [flexcoders] Change style on repeater item
I am having a hard time changing the style of an item inside of a
repeater. I can not seem to communicate to it. setStyle does not seem
to work either. Is there syntax that I am missing to communicate to
something inside a repeater?
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml>" width="100%"
height="100%" verticalScrollPolicy="off" horizontalScrollPolicy="off"
horizontalCenter="1">
<mx:Script>
<![CDATA[
private function changeStyle():void{
resultsBox.setStyle('borderColor',0xfff000);
}
]]>
</mx:Script>
<mx:Style>
.results {backgroundColor:#ffffff;
borderStyle:solid;
borderColor:#dcdcdc;
borderThickness:1;
padding-bottom:5;
padding-top:5;
padding-right:5;
padding-left:5;
cornerRadius: 6;}
.resultsov {backgroundColor:#ffffff;
borderStyle:solid;
borderColor:#fff000;
borderThickness:2;
padding-bottom:5;
padding-top:5;
padding-right:5;
padding-left:5;}
</mx:Style>
<mx:Tile id="empTile" styleName="results" width="100%"
height="100%" paddingLeft="5" paddingRight="5" paddingTop="5"
paddingBottom="5"
verticalGap="5" horizontalScrollPolicy="off"
horizontalAlign="center" horizontalCenter="1">
<mx:Repeater id="empResults" horizontalCenter="1" >
<mx:VBox id="resultsBox" verticalGap="2" width="100%"
styleName="results" mouseOver="changeStyle()">
<mx:Label text="Employee Name : " fontWeight="bold"/>
<mx:Label text="Employee No : " />
</mx:VBox>
</mx:Repeater>
</mx:Tile>
</mx:Canvas>