flash builder4里面关于StyleManager和IStyleManager2

自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",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>

 

网友

应该完整写入:mx.styles.IStyleManager2.getStyleDeclarations
 

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值