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?