I have a simple doubt. I have made a custom ActionScript mxml component, which is a spark TitleWindow with a text area, which header (titlebar) should display a green background if it finds the word ‘success’ in its text, or red, if it doesn’t.
My problem is that I don’t know where to access and modify this property, and the only turnaround I’ve found is binding the ‘chromeColor’ of the TitleWindow to depend on a boolean that will change depending on whether I find or not the word ‘success’. And this does change the TitleBar background to the color I desire, however, it also changes the scrollbar color, for example, which is a bit nasty. The code for my class is the following:
<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400"
title="Output: "
chromeColor="{success ? ( 0x00ff6b as uint) : ( 0xFF0000 as uint)}"
close="closeHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
[Bindable]
public var success:Boolean = false;
public function setText(text:String):void
{
textContainer.text = text;
if(text.indexOf("SUCCESS")!=-1)
{
success=true;
}
}
protected function closeHandler(event:CloseEvent):void
{
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<s:TextArea id="textContainer" x="0" y="0" width="100%" height="100%"
paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"
borderVisible="false" editable="false" fontFamily="Courier New"/>
</s:TitleWindow>
So, thanks for reading, and hope anyone knows the answer 🙂
Cheers,
pepillo
I’d solve it with extending standard component and creating custom skin.
My version of component:
The skin (based on standard skin):
And the simple app to test: