I was wondering how to assign a default style to my custom style property while developing a custom component. After some search in the Flex Help, I found this solution:
private static var classConstructed:Boolean = classConstruct();
private static function classConstruct():Boolean
{
if (!StyleManager.getStyleDeclaration("titleBackgroundSkin"))
{
// If there is no CSS definition for StyledRectangle,
// then create one and set the default value.
var newStyleDeclaration:CSSStyleDeclaration = new CSSStyleDeclaration();
newStyleDeclaration.setStyle("titleBackgroundSkin", mx.skins.halo.TitleBackground);
StyleManager.setStyleDeclaration("Chat", newStyleDeclaration, true);
}
return true;
}
This might result '1000: Ambiguous reference to setStyle' error, if you are using mx_internal namespace to call the methods declared with 'mx_internal' namespace. To solve that, try calling the method, by explicitly prefixing 'mx_internal::' before the method. Refer my previous post for more information.