Hi All

I've run into a small problem I was wondering it any of you have run into.

I'm overriding some state style in my mxml document depending on when what
kind of data I'm receiving. here's the function:

protected function decideColour(event:FlexEvent, money:Money):void
{
 if(money.debitOrCredit == "credit")
{
 // do nothing
} else
 {
 // just setting it with normal setstlyle also because otherwise doesn't
redraw the itemrenderer and none of the invalidate functions seem to work
 event.target.setStyle("color", colours.debtColour);
 setStyleForState(event.target, "color", "normal", colours.debtColour);
 setStyleForState(event.target, "color", "hovered",
colours.debtHoverColour);
 setStyleForState(event.target, "color", "selected",
colours.debtSelectedColour);
 }
}

private function setStyleForState(object:Object, style:String, state:String,
value:Object):void {
 var editedState:State;
for each(var s:State in this.states) {
 if(s.name == state) {
editedState = s;
 break;
}
 }
editedState.overrides = [ new SetStyle( object as IStyleClient, style,
value) ];
 }
This works fun but the problem is that as soon as I do this none of my other
state related events trigger anymore. For instance I have this code here
which works fine before I use the setStyleForState fucntion.

<s:Rect top="0" left="0" right="0" bottom="0" >
 <s:fill>
<s:LinearGradient>
 <s:GradientEntry color="0x636463"
 alpha.normal="0"
 alpha.hovered="0.1"
 alpha.selected="0.25"
 />
<s:GradientEntry color="0x636463"
 alpha.normal="0"
 alpha.selected=".25"
 alpha.hovered=".25"
 />
 <s:GradientEntry color="0x636463"
 alpha.normal="0"
 alpha.hovered="0.1"
 alpha.selected="0.25"
 />
</s:LinearGradient>
 </s:fill>
</s:Rect>
I've managed to work around it manually by firing the stateChangeComplete
event and then making two seperate rectangles visible/invisible but it would
still be interesting to know why this is happening.

Anyone run into this before?

Reply via email to