我正在使用OL 3.3中的代码在视图上使用颜色转换来设置颜色,这非常好用。
obj.setColorTransform({ab: 0, aa: 100,
bb: b-rB, ba: 100,
gb: g-rG, ga: 100,
rb: r-rR, ra: 100}); 但是当我将它升级到5.0SWF运行时时,我面临着这个问题
obj.setAttribute('colortransform',{ab: 0, aa: 100,
bb: b-rB, ba: 100,
gb: g-rG, ga: 100,
rb: r-rR, ra: 100}); 这里的obj是这种格式的视图,
<view name="borders"
width="${parent.bg.width}"
height="${parent.bg.height}"
y="10">
<simplelayout axis="x"/>
<view name="left"
resource="border_left"
stretches="height"
height="${parent.height}"
x="5"
y="1">
</view>
<view name="middle"
resource="border_mid"
y="1"
stretches="width"
height="${parent.height - 2}"
width="${parent.width - parent.left.width - parent.right.width}">
</view>
<view name="right"
resource="border_right"
stretches="height"
height="${parent.height}">
</view>
</view>你知道为什么这不起作用吗?
发布于 2012-11-20 18:06:02
当为了支持.setAttribute('colortransform', {})而弃用setColorTransform({})方法时,API发生了变化。现在,属性键不再是ra或rb,而是redMultiplier和redOffset。请参阅下面引用的相应文档部分。
API的另一个变化是值。引用setColorTransform()的文档
字典可能有以下关键字: o.ra:红色分量的alpha百分比(-100到100);o.rb:红色分量的偏移百分比(-255到255);o.ga:绿色分量的alpha百分比(-100到100);o.gb:绿色分量的偏移百分比(-255到255);o.ba:蓝色分量的alpha百分比(-100到100);o.bb:蓝色分量的偏移百分比(-255到255);o.aa:总体alpha百分比(-100到100);o.ab:整体偏移量(-255 ~ 255);
将其与视图的colortransform属性的文档进行比较:
字典可能有以下关键字: o.redMultiplier:红色分量的倍增器(0到1)默认为1 o.redOffset:红色分量的偏移量(-255到255)默认为0 o.greenMultiplier:绿色分量的倍增器(0到1)的默认值为1 o.greenOffset:绿色分量的偏移量(-255到255)的默认值为0 o.blueMultiplier:蓝色分量的倍增器(0到1)的默认值为1 o.blueOffset:蓝色分量的偏移量(-255到255)的默认值为0 o.alphaMultiplier:alpha分量(0到1)的乘数默认为1 o.alphaOffset: alpha分量(-255到255)的偏移量默认为0
正如您从文档中看到的,alpha偏移量的值范围从-100 to 100更改为0 to 1。使用setAttribute时,以下语法有效
var transformValues =
{redMultiplier: 0 to 1, redOffset: -255 to 255,
greenMultiplier: 0 to 1, greenOffset: -255 to 255,
blueMultiplier: 0 to 1, blueOffset: -255 to 255,
alphaMultiplier: 0 to 1, alphaOffset: -255 to 255}
this.setAttribute('colortransform', transformValues);https://stackoverflow.com/questions/13378090
复制相似问题