user940016
user940016

Reputation: 2948

Label styleSheet property

In the Label class there's a property named styleSheet, but I'm getting a compilation error when trying to use it, although I'm using Flex 3 and Flash Player 9. What am I missing?

Here's my code:

<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;

Error: Type was not found or was not a compile-time constant: styleSheet

Upvotes: 0

Views: 122

Answers (1)

Panciz
Panciz

Reputation: 2234

I can't understand what are you trying to do.

If you want to just set the style of the component you should use the styleName property. For example to set the color red you can use:

<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>

If you are trying to loading and set an existing CSS runtime you can use the StyleSheet. See the example in the documentation .

Anyway you are getting the compile error simply because the variable is not defined.

Davide

Upvotes: 1

Related Questions