自flex4出来后问题不断,以前很多类被摒弃了。导致现在很多方法都要替换。
?
最近在action里面修改CSS发现用StyleManager的时候居然提示:
?
自 4.0 以来已弃用。?请使用 IStyleManager2.getStyleDeclaration on a style manager instance
获取存储指定 CSS 选择器规则的 CSSStyleDeclaration 对象。
?
超级无语,搜索了半天也无结果,10年底的文章里面都还是沿用的StyleManager,
?
只有做个实例试验下了:
<?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 button1_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="输入" styleName="TextInput"/>
?<s:TextArea x="286" y="84" height="41" id="out1" styleName="TextInput"/>
?<s:Button x="287" y="144" label="变色" click="button1_clickHandler(event)"/>
?<fx:Binding source="int1.text" destination="out1.text"/>
</s:Application>
搞笑的是这样写直接提示getStyleDeclarations可能未定义。什么情况???
编辑器直接给出来的居然未定义,而且点到类里也有。没办法,继续用StyleManager
至少能正常运行- -~~~
?
<?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 button1_clickHandler(event:MouseEvent):void
???{
????
????var newStyle:CSSStyleDeclaration =StyleManager.getStyleDeclaration(".TextInput");
????if(clickChange==0){
?????newStyle.setStyle("color",0x9933ff);
?????clickChange=0;
????}
???}
??]]>
?</fx:Script>
?<fx:Style>
??.TextInput{
??color:#9933ff;
??}
?</fx:Style>
?<s:TextInput x="286" y="28" id="int1" text="输入" styleName="TextInput"/>
?<s:TextArea x="286" y="84" height="41" id="out1" styleName="TextInput"/>
?<s:Button x="287" y="144" label="变色" click="button1_clickHandler(event)"/>
?<fx:Binding source="int1.text" destination="out1.text"/>
</s:Application>
?
网友
杨子新家_hxo
-
应该完整写入:mx.styles.IStyleManager2.getStyleDeclarations
-
?
还是因为路径不全·导致的 嘿嘿 问题解决了