3 Replies Latest reply on Jul 21, 2010 5:49 AM by Darrell Loverin

    Need help with getStyleDeclaration

    Santanu Karar Level 1

      Hi,

       

      I'm trying to move my Flex 3 project to new Flash Builder environ. I've a class named "CanvasButtonAccordionHeader" which is extended from an mx:Button instance.

       

      There was a code as:

      var selector:CSSStyleDeclaration = StyleManager.getStyleDeclaration( "CanvasButtonAccordionHeader" );;

       

      Though the Flash Builder compiler giving me the warning that "getStyleDeclaration' has been deprecated since 4.0.  Please use 'IStyleManager2.getStyleDeclaration on a style manager instance".

       

      When I'm trying to change the line as:

      IStyleManager2.getStyleDeclarations( "CanvasButtonAccordionHeader" );

       

      It returns me error since the line of code returns me an Array in place of CSSStyleDeclaration type, which is my requirement.

       

      Then I tried:

      var selector:CSSStyleDeclaration = IStyleManager2.getMergedStyleDeclaration( "CanvasButtonAccordionHeader" );

       

      I'm getting obvious error since I'm trying to call a method from an Static type of class (interface). I'm in turn very confused now how to overcome this problem. Though as a note, when I'm try calling "styleManager.getStyleDeclaration('someName')" from an mx type of component, it works fine!

       

      How do I fix this in a class environment then!

       

      Please suggest.

       

      Thanks.

       

      ASB.