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

Flex 修改shape颜色的方法

发布时间:2020-12-15 05:11:20 所属栏目:百科 来源:网络整理
导读:?flash打包资源成swc组件,在flex中引用 修改shape颜色的方法如下: var child:Shape = mc.getChildAt(jj) as Shape; var newTranColor:ColorTransform = child.transform.colorTransform; //var newMatrix:Matrix = child.transform.matrix; newTranColor.c

?flash打包资源成swc组件,在flex中引用

修改shape颜色的方法如下:

         var child:Shape = mc.getChildAt(jj) as Shape;
         
         var newTranColor:ColorTransform = child.transform.colorTransform;
         //var newMatrix:Matrix = child.transform.matrix;
         newTranColor.color = 0x00ff00;
         child.transform.colorTransform = newTranColor;


相关说明如下:

一个对象,具有与显示对象的矩阵、颜色转换和像素范围有关的属性。在 Transform 类的条目中对特定属性 matrix、colorTransform 和三个只读属性( concatenatedMatrixconcatenatedColorTransformpixelBounds)进行了说明。

transform 对象的每个属性本身都是一个对象。此概念很重要,因为设置 matrix 或 colorTransform 对象的新值的唯一方法是,创建新对象并将该对象复制到 transform.matrix 或 transform.colorTransform 属性。

例如,要增加显示对象矩阵的 tx 值,您必须制作整个矩阵对象的副本,然后将新对象复制到 transform 对象的 matrix 属性中:

var myMatrix:Matrix = myDisplayObject.transform.matrix;  
    myMatrix.tx += 10; 
    myDisplayObject.transform.matrix = myMatrix;

不能直接设置 tx 属性。下面的代码对 myDisplayObject 不起作用:

myDisplayObject.transform.matrix.tx += 10;

您也可以复制整个 transform 对象并为其赋予另一个显示对象的 transform 属性。例如,下面的代码将整个 transform 对象从 myOldDisplayObj 复制到 myNewDisplayObj

myNewDisplayObj.transform = myOldDisplayObj.transform;

现在,新显示对象 myNewDisplayObj 与旧显示对象 myOldDisplayObj 具有相同的矩阵、颜色转换和像素范围值。

(编辑:李大同)

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

    推荐文章
      热点阅读