加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flash builder4里面关于StyleManager和IStyleManager2

发布时间:2020-12-15 06:43:57 所属栏目:百科 来源:网络整理
导读:自flex4出来后问题不断,以前很多类被摒弃了。导致现在很多方法都要替换。 ? 最近在action里面修改CSS发现用StyleManager的时候居然提示: ? 自 4.0 以来已弃用。 ? 请使用 IStyleManager2.getStyleDeclaration on a style manager instance 获取存储指定 CS

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

还是因为路径不全·导致的 嘿嘿 问题解决了

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读