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.

Comments (1)
Just ran into the Ambiguous reference issue you mentioned. Here's an easier fix even though it's a bit of a hack:
Instead of saying:
newStyleDeclaration.setStyle("titleBackgroundSkin", mx.skins.halo.TitleBackground);
use this:
newStyleDeclaration["setStyle"]("titleBackgroundSkin", mx.skins.halo.TitleBackground);
No more namespace issues!
Posted by Aaron | July 19, 2007 9:56 PM
Posted on July 19, 2007 21:56