gpt4 book ai didi

actionscript-3 - 如何使用 AS3 更改动态文本字段的字体颜色?

转载 作者:行者123 更新时间:2023-12-02 18:15:54 27 4
gpt4 key购买 nike

如何在 Flash 中使用 Actionscript 3 更改动态文本字段内的字体颜色?我想将其实现为 if 语句,如下所示:

if (randomVar == 0) {
score.color = #0xFFFFFF;
} else if (randomVar == 1) {
score.color = #0xFAFAFA;
} else {
score.color = #0xAAAAAA;
}

最佳答案

您必须使用TextFormat。这是一个例子:

//first, get the text format that you've applied in Flash at design time:
var txtFormat:TextFormat = score.defaultTextFormat;

//then later, in your if statement:
txtFormat.color = 0xFF0000; //red

//modifying the text format object doesn't actually trigger any changes to text fields
//you have to apply it to your text field to see the changes
score.setTextFormat(txtFormat);

关于actionscript-3 - 如何使用 AS3 更改动态文本字段的字体颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37574760/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com