在Label类中有一个名为styleSheet的属性,但我在尝试使用它时遇到编译错误,尽管我使用的是Flex3和Flash player9。
下面是我的代码:
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml" selectable="true">
<mx:Script>
override public function set data(value:Object):void
{
super.data=value;
var labelStyleSheet:StyleSheet=styleSheet;
错误:找不到类型或类型不是编译时常量: styleSheet
发布于 2013-01-24 22:36:56
我不明白你到底想做什么。
如果只想设置组件的样式,则应该使用styleName
属性。例如,要设置红色,您可以使用:
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
.test{
color:red;
}
</fx:Style>
<mx:Label styleSheet="{StyleManager.getStyleDeclaration('test').getStyle()}">
</mx:Label>
如果您正在尝试加载和设置现有的CSS运行时,您可以使用StyleSheet。请参阅documentation 中的示例。
无论如何,因为变量没有定义,所以你会得到编译错误。
戴维德
https://stackoverflow.com/questions/14501779
复制相似问题