Hi Martin
Let's have another go at displaying the code:
I have declared my presenter Class as [Bindable]. In my presenter I have a
property as follows:
internal var _ButtonColour:uint = 0x000000;
public function get ButtonColour():uint {
return _ButtonColour;
}
public function set ButtonColour(value:uint):void {
_ButtonColour = value;
}
I have a Switch statement to change the value depending on the value of
another property which may change:
private function setButtonColour():void
{
trace("setButtonColour called. ButtonColour = " +
String(ButtonColour));
switch(LessonType)
{
case "purpose":
ButtonColour = 0x24c07f;
break;
case "components":
ButtonColour = 0x53c7c7;
break;
case "locate":
ButtonColour = 0x88b9ff;
break;
case "process":
ButtonColour = 0xab8ff2;
break;
case "safetycase":
ButtonColour = 0xe380fe;
break;
case "interlocks":
ButtonColour = 0xf187c5;
break;
case "safetyfeatures":
ButtonColour = 0xfe6856;
break;
case "interrelation":
ButtonColour = 0xff8233;
break;
case "opex":
ButtonColour = 0xf99c38;
break;
case "other":
ButtonColour = 0xf5d846;
break;
default:
ButtonColour = 0x7ab73e;
break;
}
trace("ButtonColour set to " + String(ButtonColour));
}
In my mxml file I have defined a Rectangle as follows:
<s:Graphic
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:presenters="presenters.*">
<fx:Declarations>
<presenters:SliderView_Presenter id="presenter" />
</fx:Declarations>
<s:Rect
id="BtnColour"
width="24" height="24"
radiusX="12" radiusY="12">
<s:fill>
<s:SolidColor color="{presenter.ButtonColour}" />
</s:fill>
</s:Rect>
</s:Graphic>
To recap, my presenter class has the [Bindable] meta tag above the Class
definition. My view includes an HSlider which sets the skinClass =
SliderSkin. The SliderSkin skin class defines the Thumb button and sets its
skinClass to SliderThumbSkin.
In my SliderThumbSkin I want to bind the colour of an element in the button
definition (a Rect with a Fill of solidColour) to a value in my presenter
class.
The presenter class would be instantiated by the hostComponent, the HSlider,
so I'm wondering if I should access the property through this. Currently my
colour property in the presenter is set its initial value and the button is
set to this colour, when the colour value changes though the button does not
get notified and does not change.
Does that help?
Chris
--
View this message in context:
http://apache-flex-users.2333346.n4.nabble.com/Can-I-Bind-a-SolidColor-Fill-Value-tp4615p4633.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.