Stylemanager and istylemanager2 in Flash builder4

Source: Internet
Author: User
Tags cdata

Since flex4, many classes have been abandoned. As a result, many methods need to be replaced now.

 

When I recently modified CSS in the action and found that stylemanager was used, I was prompted:

 

It has been deprecated since 4.0.Please use istylemanager2.getstyledeclaration on a style manager instance
Gets the cssstyledeclaration object that stores the specified CSS selector rule.

 

It was speechless and there was no result after searching for half a day. stylemanager was still used in the articles at the end of the 10 s,

 

Only an instance has been tested:

<? XML version = "1.0" encoding = "UTF-8"?>
<S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009"
     Xmlns: S = "Library: // ns.adobe.com/flex/spark"
     Xmlns: MX = "Library: // ns.adobe.com/flex/mx" minwidth = "955" minheight = "600" width = "645">

 <FX: SCRIPT>
  <! [CDATA [
   Import MX. Styles. cssstyledeclaration;
   Public var clickchange: Number = 0;
   Protected function button#clickhandler (Event: mouseevent): void
   {
    
    VaR newstyle: cssstyledeclaration = istylemanager2.getstyledeclarations (". textinput ");

    If (clickchange = 0 ){
     Newstyle. setstyle ("color", 0x33ff93 );
    Clickchange = 1;
    } Else {
     Newstyle. setstyle ("color", 0x9933ff );
     Clickchange = 0;
    }
   }
  ]>
 </FX: SCRIPT>

 <FX: style>
  . Textinput {
  Color: # 9933ff;
  }
 </FX: style>
 <S: textinput x = "286" Y = "28" id = "int1" text = "input" stylename = "textinput"/>
 <S: textarea x = "286" Y = "84" Height = "41" id = "out1" stylename = "textinput"/>
 <S: button x = "287" Y = "144" label = "color change" Click = "button#clickhandler (event)"/>
 <FX: binding source = "int1.text" Destination = "out1.text"/>
</S: Application>

The funny thing is that the Code prompts that getstyledeclarations may be undefined. What is the situation ???

The editor directly gives undefined, and points to the class are also available. No way. Continue to use stylemanager.

At least run properly --~~~

 

<? XML version = "1.0" encoding = "UTF-8"?>
<S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009"
     Xmlns: S = "Library: // ns.adobe.com/flex/spark"
     Xmlns: MX = "Library: // ns.adobe.com/flex/mx" minwidth = "955" minheight = "600" width = "645">

 <FX: SCRIPT>
  <! [CDATA [
   Import MX. Styles. cssstyledeclaration;
   Public var clickchange: Number = 0;
   Protected function button#clickhandler (Event: mouseevent): void
   {
    
    VaR newstyle: cssstyledeclaration = stylemanager. getstyledeclaration (". textinput ");

    If (clickchange = 0 ){
     Newstyle. setstyle ("color", 0x33ff93 );
    Clickchange = 1;
    } Else {
     Newstyle. setstyle ("color", 0x9933ff );
     Clickchange = 0;
    }
   }
  ]>
 </FX: SCRIPT>

 <FX: style>
  . Textinput {
  Color: # 9933ff;
  }
 </FX: style>
 <S: textinput x = "286" Y = "28" id = "int1" text = "input" stylename = "textinput"/>
 <S: textarea x = "286" Y = "84" Height = "41" id = "out1" stylename = "textinput"/>
 <S: button x = "287" Y = "144" label = "color change" Click = "button#clickhandler (event)"/>
 <FX: binding source = "int1.text" Destination = "out1.text"/>
</S: Application>

 

Netizens

Yangzi new home _ HXO
Full write: MX. Styles. istylemanager2.getstyledeclarations

Or is the problem solved due to incomplete paths?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.