专著于富媒体技术~
本站某些作品来源于互联网,如果侵犯了您的利益,请留言说明
这是前几天遇到的一个小问题,那就是ActionScript3.0~TextField类别中的alpha属性不会起作用,为甚么会说不能够起作用呢?那是因为alpha属性在TextField类别中是有一些限制的,那就是必须将字体嵌入才能使alpha属性起作用(指动态字体),为了项办法使它alpha属性起作用且不用将字体嵌入,所以使用了一些小方法…

那就是将TextField加在(addChild)MovieClip或Sprite容器中显示,可是这样还是不足够的,举个例子来说:

var sprite:Sprite = new Sprite();
var txtField:TextField = new TextField();
txtField.alpha = .5;
txtField.appendText(”text”);
addChild(sprite);
sprite.addChild(txtField);


这样写的话,虽然已经把textField给加入了Sprite里,但是alpha的属性还是不会起作用,因为我们还未将Sprite加上Blendmode函数,我在这里有测试过…大部分的Blendmode函数中的属性都能使用,但是最好的方式是使用BlendMode.LAYER,因为它会强制为该显示对象创建一个透明度组。
所以我们现在把刚才的程序改成这样:

var sprite:Sprite = new Sprite();
var txtField:TextField = new TextField();
sprite.blendMode = BlendMode.LAYER;
txtField.alpha = .5;
txtField.appendText(”text”);
addChild(sprite);
sprite.addChild(txtField);


这样就能使文字有透明的效果了

            


作者:gdgzboy@牛C网
地址:http://www.niuc.net/post/7857/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!



Tags:
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写